diff --git a/docker.sh b/docker.sh index 2c5430b..bdbff4c 100644 --- a/docker.sh +++ b/docker.sh @@ -1,5 +1,5 @@ -#!/bin/bash -export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin:/bin +#!/usr/bin/env bash + export LANG=en_US.UTF-8 WGCF_DIR='/etc/wireguard' @@ -26,11 +26,11 @@ wgcf_install(){ # 判断 wgcf 的最新版本,如因 github 接口问题未能获取,默认 v2.2.11 green " \n Install WGCF \n " latest=$(wget -qO- -4 "https://api.github.com/repos/ViRb3/wgcf/releases/latest" | grep "tag_name" | head -n 1 | cut -d : -f2 | sed 's/[ \"v,]//g') - latest=${latest:-'2.2.11'} + latest=${latest:-'2.2.13'} # 安装 wgcf,尽量下载官方的最新版本,如官方 wgcf 下载不成功,将使用 jsDelivr 的 CDN,以更好的支持双栈。并添加执行权限 - wget -4 -O /usr/local/bin/wgcf https://github.com/ViRb3/wgcf/releases/download/v"$latest"/wgcf_"$latest"_linux_$ARCHITECTURE || - wget -4 -O /usr/local/bin/wgcf https://cdn.jsdelivr.net/gh/fscarmen/warp/wgcf_"$latest"_linux_$ARCHITECTURE + wget -4 -O /usr/local/bin/wgcf https://github.com/ViRb3/wgcf/releases/download/v"$latest"/wgcf_"$latest"_linux_"$ARCHITECTURE" || + wget -4 -O /usr/local/bin/wgcf https://raw.githubusercontents.com/fscarmen/warp/main/wgcf/wgcf_"$latest"_linux_"$ARCHITECTURE" chmod +x /usr/local/bin/wgcf # 注册 WARP 账户 ( wgcf-account.toml 使用默认值加加快速度)。如有 WARP+ 账户,修改 license 并升级 @@ -67,92 +67,13 @@ wgcf_install(){ sed -i "s/^.*\:\:\/0/#&/g;s/engage.cloudflareclient.com/162.159.193.10/g" $WGCF_DIR/wgcf.conf } -# 期望解锁地区 -input_region(){ - if [[ -z "$EXPECT" ]]; then - REGION=$(curl -skm8 https://ip.gs/country-iso 2>/dev/null) - reading " The current region is $REGION. Confirm press [y] . If you want another regions, please enter the two-digit region abbreviation. (such as hk,sg. Default is $REGION): " EXPECT - until [[ -z $EXPECT || $EXPECT = [Yy] || $EXPECT =~ ^[A-Za-z]{2}$ ]]; do - reading " The current region is $REGION. Confirm press [y] . If you want another regions, please enter the two-digit region abbreviation. (such as hk,sg. Default is $REGION): " EXPECT - done - [[ -z $EXPECT || $EXPECT = [Yy] ]] && EXPECT="$REGION" - fi - } - -# Telegram Bot 日志推送 -input_tg(){ - [[ -z $CUSTOM ]] && reading " Please enter Bot Token if you need push the logs to Telegram. Leave blank to skip: " TOKEN - [[ -n $TOKEN && -z $USERID ]] && reading " Enter USERID: " USERID - [[ -n $USERID && -z $CUSTOM ]] && reading " Enter custom name: " CUSTOM - } - -# 生成解锁文件 -export_unlock_file(){ -[ ! -d $WGCF_DIR ] && mkdir $WGCF_DIR - -# 生成 warp_unlock.sh 文件,判断当前流媒体解锁状态,遇到不解锁时更换 WARP IP,直至刷成功。5分钟后还没有刷成功,将不会重复该进程而浪费系统资源 -cat < $WGCF_DIR/warp_unlock.sh -#!/bin/bash -EXPECT="$EXPECT" -TOKEN="$TOKEN" -USERID="$USERID" -CUSTOM="$CUSTOM" -NIC="-ks4m8" -RESTART="wgcf_restart" -LOG_LIMIT="1000" -UNLOCK_STATUS='Yes 🎉' -NOT_UNLOCK_STATUS='No 😰' -if [[ \$(pgrep -laf ^[/d]*bash.*warp_unlock | awk -F, '{a[\$2]++}END{for (i in a) print i" "a[i]}') -le 2 ]]; then -LMC999=\$(curl -sSLm4 https://raw.githubusercontent.com/lmc999/RegionRestrictionCheck/main/check.sh) -RESULT_TITLE=\$(echo "\$LMC999" | grep "result.*netflix.com/title/" | sed "s/.*title\/\([^\"]*\).*/\1/") -REGION_TITLE=\$(echo "\$LMC999" | grep "region.*netflix.com/title/" | sed "s/.*title\/\([^\"]*\).*/\1/") -RESULT_TITLE=\${RESULT_TITLE:-'81215567'}; REGION_TITLE=\${REGION_TITLE:-'80018499'} -tg_output="💻 \\\$CUSTOM. ⏰ \\\$(date +'%F %T'). 🛰 \\\$WAN 🌏 \\\$COUNTRY. \\\$CONTENT" -tg_message(){ curl -s -X POST "https://api.telegram.org/bot\$TOKEN/sendMessage" -d chat_id=\$USERID -d text="\$(eval echo "\$tg_output")" -d parse_mode="HTML" >/dev/null 2>&1; } - -ip(){ -unset IP_INFO WAN COUNTRY ASNORG -IP_INFO="\$(curl \$NIC https://ip.gs/json 2>/dev/null)" -WAN=\$(expr "\$IP_INFO" : '.*ip\":\"\([^"]*\).*') -COUNTRY=\$(expr "\$IP_INFO" : '.*country\":\"\([^"]*\).*') -ASNORG=\$(expr "\$IP_INFO" : '.*asn_org\":\"\([^"]*\).*') -} - -wgcf_restart(){ wg-quick down wgcf >/dev/null 2>&1; wg-quick up wgcf >/dev/null 2>&1; sleep 5; ip; } - -check0(){ -RESULT[0]=""; REGION[0]=""; R[0]=""; -RESULT[0]=\$(curl --user-agent "\${UA_Browser}" \$NIC -fsL --write-out %{http_code} --output /dev/null --max-time 10 "https://www.netflix.com/title/\$RESULT_TITLE" 2>&1) -if [[ \${RESULT[0]} = 200 ]]; then -REGION[0]=\$(curl --user-agent "\${UA_Browser}" \$NIC -fs --max-time 10 --write-out %{redirect_url} --output /dev/null "https://www.netflix.com/title/\$REGION_TITLE" | sed 's/.*com\/\([^-/]\{1,\}\).*/\1/g' | tr '[:lower:]' '[:upper:]') -REGION[0]=\${REGION[0]:-'US'} -fi -echo "\${REGION[0]}" | grep -qi "\$EXPECT" && R[0]="\$UNLOCK_STATUS" || R[0]="\$NOT_UNLOCK_STATUS" -CONTENT="Netflix: \${R[0]}." -[[ -n "\$CUSTOM" ]] && [[ \${R[0]} != \$(sed -n '1p' $DOCKER_DIR/status.log) ]] && tg_message -sed -i "1s/.*/\${R[0]}/" $DOCKER_DIR/status.log -} - -ip -UA_Browser="Mozilla/5.0 (Windows NT 10.0; Win64; x6*4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36" -[[ ! \${R[*]} =~ 'No' ]] && check0 -until [[ ! \${R[*]} =~ "\$NOT_UNLOCK_STATUS" ]]; do -unset R -\$RESTART -[[ ! \${R[*]} =~ 'No' ]] && check0 -done - -fi -EOF -} - container_build(){ green " \n Docker build and run \n " # 安装 docker,拉取镜像 + 创建容器 ! systemctl is-active docker >/dev/null 2>&1 && green " \n Install docker \n " && curl -sSL get.docker.com | sh ! systemctl is-active docker >/dev/null 2>&1 && ( systemctl enable --now docker; sleep 2 ) - docker run -dit --restart=always --name wgcf --sysctl net.ipv6.conf.all.disable_ipv6=0 --device /dev/net/tun --privileged --cap-add net_admin --cap-add sys_module --log-opt max-size=1m -v /lib/modules:/lib/modules -v $WGCF_DIR:$WGCF_DIR fscarmen/netflix_unlock:latest + docker run -dit --restart=always --name wgcf --sysctl net.ipv6.conf.all.disable_ipv6=0 --device /dev/net/tun --privileged --cap-add net_admin --cap-add sys_module --log-opt max-size=1m -v /lib/modules:/lib/modules -v $WGCF_DIR:$WGCF_DIR fscarmen/wgcf_docker:latest # 清理临时文件 rm -rf wgcf-account.toml /usr/local/bin/wgcf @@ -162,12 +83,6 @@ container_build(){ statistics_of_run-times -input_region - -input_tg - -export_unlock_file - wgcf_install container_build