2019-11-06 10:58:06 +08:00
#!/usr/bin/env bash
2020-05-23 23:21:43 +08:00
2020-09-25 17:03:29 +08:00
installType = 'yum -y install'
2020-05-24 16:28:37 +08:00
removeType = 'yum -y remove'
2020-05-23 23:21:43 +08:00
upgrade = "yum -y update"
echoType = 'echo -e'
2020-08-18 15:45:55 +08:00
domain =
2020-08-18 17:03:59 +08:00
add =
2020-08-27 16:57:42 +08:00
globalType =
2020-08-18 15:45:55 +08:00
customPath = alone
2020-08-03 17:23:14 +08:00
centosVersion = 0
2020-09-03 15:32:27 +08:00
totalProgress = 1
2020-06-11 15:39:59 +08:00
iplc = $1
2020-09-01 17:38:48 +08:00
uuidws =
uuidtcp =
2020-09-11 10:56:10 +08:00
uuidVlessWS =
2020-08-18 15:45:55 +08:00
2020-07-31 17:52:47 +08:00
trap 'onCtrlC' INT
function onCtrlC ( ) {
2020-08-02 19:14:20 +08:00
echo
2020-07-31 17:52:47 +08:00
killSleep > /dev/null 2>& 1
exit;
}
2020-05-23 23:21:43 +08:00
# echo颜色方法
echoContent( ) {
case $1 in
# 红色
"red" )
2020-08-02 19:14:20 +08:00
${ echoType } " \033[31m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
# 天蓝色
"skyBlue" )
2020-09-02 16:48:05 +08:00
${ echoType } " \033[1;36m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
# 绿色
"green" )
2020-08-02 19:14:20 +08:00
${ echoType } " \033[32m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
# 白色
"white" )
2020-08-02 19:14:20 +08:00
${ echoType } " \033[37m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
"magenta" )
2020-08-02 19:14:20 +08:00
${ echoType } " \033[31m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
"skyBlue" )
2020-08-02 19:14:20 +08:00
${ echoType } " \033[36m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
# 黄色
"yellow" )
2020-08-02 19:14:20 +08:00
${ echoType } " \033[33m ${ printN } $2 \033[0m "
2020-05-23 23:21:43 +08:00
; ;
esac
}
2020-08-02 19:14:20 +08:00
# 新建目录
mkdirTools( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 创建文件夹 "
2020-09-01 17:38:48 +08:00
mkdir -p /etc/v2ray-agent/tls
mkdir -p /etc/v2ray-agent/v2ray
2020-09-21 15:21:16 +08:00
mkdir -p /etc/v2ray-agent/trojan
2020-08-02 19:14:20 +08:00
mkdir -p /etc/systemd/system/
}
2020-05-23 23:21:43 +08:00
# 安装工具包
installTools( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 安装工具 "
2020-07-29 17:24:10 +08:00
if [ [ " ${ release } " = "centos" ] ]
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 检查安装jq、nginx epel源、yum-utils"
2020-07-29 17:24:10 +08:00
# jq epel源
2020-09-25 17:03:29 +08:00
if [ [ -z ` command -v jq` ] ]
then
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm > /dev/null 2>& 1
fi
2020-08-03 17:23:14 +08:00
nginxEpel = ""
if [ [ ! -z ` rpm -qa| grep -v grep| grep nginx` ] ]
then
2020-09-25 17:03:29 +08:00
local nginxVersion = ` rpm -qa| grep -v grep| grep nginx| head -1| awk -F '[-]' '{print $2}' ` ;
if [ [ ` echo ${ nginxVersion } | awk -F '[.]' '{print $1}' ` < 1 ] ] && [ [ ` echo ${ nginxVersion } | awk -F '[.]' '{print $2}' ` < 17 ] ]
then
rpm -qa| grep -v grep| grep nginx| xargs rpm -e > /dev/null 2>& 1
fi
2020-08-03 17:23:14 +08:00
fi
if [ [ " ${ centosVersion } " = "6" ] ]
then
nginxEpel = "http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-1.18.0-1.el6.ngx.x86_64.rpm"
elif [ [ " ${ centosVersion } " = "7" ] ]
then
nginxEpel = "http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm"
elif [ [ " ${ centosVersion } " = "8" ] ]
then
nginxEpel = "http://nginx.org/packages/centos/8/x86_64/RPMS/nginx-1.18.0-1.el8.ngx.x86_64.rpm"
fi
2020-07-29 17:24:10 +08:00
# nginx epel源
2020-09-01 17:38:48 +08:00
rpm -ivh ${ nginxEpel } > /etc/v2ray-agent/error.log 2>& 1
2020-09-25 17:03:29 +08:00
2020-08-02 19:14:20 +08:00
# yum-utils
2020-09-25 17:03:29 +08:00
if [ [ " ${ centosVersion } " = "8" ] ]
then
2020-09-25 17:42:16 +08:00
upgrade = "yum update -y --skip-broken --nobest"
2020-09-25 17:03:29 +08:00
installType = "yum -y install --nobest"
${ installType } yum-utils > /etc/v2ray-agent/error.log 2>& 1
else
${ installType } yum-utils > /etc/v2ray-agent/error.log 2>& 1
fi
2020-07-29 17:24:10 +08:00
fi
2020-08-27 16:57:42 +08:00
# 修复ubuntu个别系统问题
if [ [ " ${ release } " = "ubuntu" ] ]
then
dpkg --configure -a
fi
2020-07-29 17:24:10 +08:00
2020-07-01 20:48:57 +08:00
if [ [ ! -z ` ps -ef| grep -v grep| grep apt` ] ]
then
ps -ef| grep -v grep| grep apt| awk '{print $2}' | xargs kill -9
fi
2020-05-24 16:28:37 +08:00
2020-09-02 16:48:05 +08:00
echoContent green " ---> 检查、安装更新【新机器会很慢,耐心等待】"
2020-07-24 17:51:32 +08:00
# if [[ "${release}" = "centos" ]]
# then
# yum-complete-transaction --cleanup-only
# fi
2020-09-02 17:09:25 +08:00
${ upgrade } > /dev/null
2020-09-01 17:38:48 +08:00
if [ [ " ${ release } " = "centos" ] ]
then
rm -rf /var/run/yum.pid
fi
2020-05-23 23:21:43 +08:00
2020-09-10 17:25:20 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w wget` ] ]
2020-09-02 16:48:05 +08:00
then
echoContent green " ---> 安装wget"
${ installType } wget > /dev/null
fi
2020-09-10 17:25:20 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w unzip` ] ]
2020-09-02 16:48:05 +08:00
then
echoContent green " ---> 安装unzip"
${ installType } unzip > /dev/null
fi
2020-09-10 17:25:20 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w socat` ] ]
2020-09-02 16:48:05 +08:00
then
echoContent green " ---> 安装socat"
${ installType } socat > /dev/null
fi
2020-05-23 23:21:43 +08:00
2020-09-10 17:17:32 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w tar` ] ]
2020-09-02 16:48:05 +08:00
then
echoContent green " ---> 安装tar"
${ installType } tar > /dev/null
fi
2020-05-23 23:21:43 +08:00
2020-09-02 16:48:05 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep cron` ] ]
2020-05-24 16:28:37 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 安装crontabs"
if [ [ " ${ release } " = "ubuntu" ] ] || [ [ " ${ release } " = "debian" ] ]
then
${ installType } cron > /dev/null
else
${ installType } crontabs > /dev/null
fi
fi
2020-09-10 17:25:20 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w jq` ] ]
2020-09-02 16:48:05 +08:00
then
echoContent green " ---> 安装jq"
${ installType } jq > /dev/null
2020-05-24 16:28:37 +08:00
fi
2020-05-23 23:21:43 +08:00
2020-09-02 16:48:05 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep binutils` ] ]
then
echoContent green " ---> 安装binutils"
${ installType } binutils > /dev/null 2>& 1
fi
2020-09-10 17:25:20 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w nginx` ] ]
2020-08-02 19:14:20 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 安装nginx"
${ installType } nginx > /dev/null
2020-08-02 19:14:20 +08:00
fi
2020-09-02 16:48:05 +08:00
2020-09-11 14:13:51 +08:00
if [ [ -z ` find /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin | grep -v grep| grep -w sudo` ] ]
then
echoContent green " ---> 安装sudo"
${ installType } sudo > /dev/null
fi
2020-09-02 16:48:05 +08:00
# todo 关闭防火墙
2020-09-01 17:38:48 +08:00
2020-08-03 21:02:56 +08:00
# 新建所需目录
2020-09-01 17:38:48 +08:00
# mkdirTools
2020-08-03 21:02:56 +08:00
2020-09-04 10:35:14 +08:00
if [ [ ! -d "/root/.acme.sh" ] ]
2020-08-02 19:14:20 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 安装acme.sh"
2020-09-04 10:35:14 +08:00
curl -s https://get.acme.sh | sh > /etc/v2ray-agent/tls/acme.log
2020-09-02 16:48:05 +08:00
if [ [ -d "~/.acme.sh" ] ] && [ [ -z ` ls -F ~/.acme.sh/| grep -w "acme.sh" ` ] ]
then
echoContent red " acme安装失败--->"
echoContent yellow "错误排查:"
echoContent red " 1.获取Github文件失败, 请等待GitHub恢复后尝试, 恢复进度可查看 [https://www.githubstatus.com/]"
echoContent red " 2.acme.sh脚本出现bug, 可查看[https://github.com/acmesh-official/acme.sh] issues"
echoContent red " 3.反馈给开发者[私聊: https://t.me/mack_a] 或 [提issues]"
killSleep > /dev/null 2>& 1
exit 0
fi
2020-08-02 19:14:20 +08:00
fi
2020-09-04 10:35:14 +08:00
if [ [ -d "/root/.acme.sh" ] ] && [ [ -z ` find /root/.acme.sh/ -name "acme.sh" ` ] ]
then
echoContent green " ---> 安装acme.sh"
curl -s https://get.acme.sh | sh > /etc/v2ray-agent/tls/acme.log
if [ [ -d "~/.acme.sh" ] ] && [ [ -z ` find /root/.acme.sh/ -name "acme.sh" ` ] ]
then
echoContent red " acme安装失败--->"
echoContent yellow "错误排查:"
echoContent red " 1.获取Github文件失败, 请等待GitHub恢复后尝试, 恢复进度可查看 [https://www.githubstatus.com/]"
echoContent red " 2.acme.sh脚本出现bug, 可查看[https://github.com/acmesh-official/acme.sh] issues"
echoContent red " 3.反馈给开发者[私聊: https://t.me/mack_a] 或 [提issues]"
killSleep > /dev/null 2>& 1
exit 0
fi
fi
2020-05-23 23:21:43 +08:00
}
2020-08-18 15:45:55 +08:00
# 初始化Nginx申请证书配置
initTLSNginxConfig( ) {
2020-09-01 17:38:48 +08:00
handleNginx stop
2020-08-02 19:14:20 +08:00
killSleep > /dev/null 2>& 1
killSleep > /dev/null 2>& 1
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 初始化Nginx申请证书配置 "
2020-08-18 15:45:55 +08:00
echoContent yellow "请输入要配置的域名 例: blog.v2ray-agent.com --->"
read -p "域名:" domain
2020-05-23 23:21:43 +08:00
if [ [ -z ${ domain } ] ]
then
echoContent red " 域名不可为空--->"
2020-08-18 15:45:55 +08:00
initTLSNginxConfig
2019-11-06 10:58:06 +08:00
else
2020-05-23 23:21:43 +08:00
# 修改配置
2020-09-02 16:48:05 +08:00
echoContent green " ---> 配置Nginx"
2020-05-24 16:28:37 +08:00
touch /etc/nginx/conf.d/alone.conf
echo " server {listen 80;server_name ${ domain } ;root /usr/share/nginx/html;location ~ /.well-known {allow all;}location /test {return 200 'fjkvymb6len';}} " > /etc/nginx/conf.d/alone.conf
2020-05-23 23:21:43 +08:00
# 启动nginx
2020-09-01 17:38:48 +08:00
handleNginx start
2020-05-23 23:21:43 +08:00
# 测试nginx
2020-09-02 16:48:05 +08:00
echoContent green " ---> 检查Nginx是否正常访问"
2020-05-23 23:21:43 +08:00
domainResult = ` curl -s ${ domain } /test| grep fjkvymb6len`
if [ [ ! -z ${ domainResult } ] ]
2019-11-06 10:58:06 +08:00
then
2020-09-01 17:38:48 +08:00
handleNginx stop
2020-09-02 16:48:05 +08:00
echoContent green " ---> Nginx配置成功"
2019-11-06 10:58:06 +08:00
else
2020-07-01 20:48:57 +08:00
echoContent red " 无法正常访问服务器, 请检测域名是否正确、域名的DNS解析以及防火墙设置是否正确--->"
2020-07-29 17:24:10 +08:00
killSleep > /dev/null 2>& 1
2020-05-24 11:50:07 +08:00
exit 0;
2019-11-06 10:58:06 +08:00
fi
fi
}
2020-05-23 23:21:43 +08:00
# 安装TLS
installTLS( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 申请TLS证书 "
2020-08-18 15:45:55 +08:00
if [ [ -z ` find /etc/v2ray-agent/tls/ -name " ${ domain } * " ` ] ]
2020-05-23 23:21:43 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 安装TLS证书"
2020-07-13 17:46:39 +08:00
2020-08-18 15:45:55 +08:00
sudo ~/.acme.sh/acme.sh --issue -d ${ domain } --standalone -k ec-256 >/dev/null
2020-09-01 17:38:48 +08:00
~/.acme.sh/acme.sh --installcert -d ${ domain } --fullchainpath /etc/v2ray-agent/tls/${ domain } .crt --keypath /etc/v2ray-agent/tls/${ domain } .key --ecc >/dev/null
if [ [ -z ` cat /etc/v2ray-agent/tls/${ domain } .crt` ] ]
2020-05-23 23:21:43 +08:00
then
2020-08-02 19:14:20 +08:00
progressTools "yellow" " TLS安装失败, 请检查acme日志--->"
2020-05-23 23:21:43 +08:00
exit 0
2020-09-01 17:38:48 +08:00
elif [ [ -z ` cat /etc/v2ray-agent/tls/${ domain } .key` ] ]
2020-05-23 23:21:43 +08:00
then
2020-08-02 19:14:20 +08:00
progressTools "yellow" " TLS安装失败, 请检查acme日志--->"
2020-05-23 23:21:43 +08:00
exit 0
fi
2020-09-02 16:48:05 +08:00
echoContent green " ---> TLS生成成功"
# 记录证书生成的时间
2020-09-11 14:13:51 +08:00
# echo ${domain} `date +%s` > /etc/v2ray-agent/tls/config
2020-08-18 15:45:55 +08:00
elif [ [ -z ` cat /etc/v2ray-agent/tls/${ domain } .crt` ] ] || [ [ -z ` cat /etc/v2ray-agent/tls/${ domain } .key` ] ]
2020-05-23 23:21:43 +08:00
then
2020-08-06 16:33:33 +08:00
progressTools "red" " 检测到错误证书,需重新生成,重新生成中--->" 18
2020-09-02 16:48:05 +08:00
rm -rf /etc/v2ray-agent/tls/*
2020-08-18 15:45:55 +08:00
installTLS
2020-05-23 23:21:43 +08:00
else
2020-09-02 16:48:05 +08:00
echoContent green " ---> 检测到证书"
read -p "是否重新生成?[y/n]:" reInstalTLStatus
if [ [ " ${ reInstalTLStatus } " = "y" ] ]
then
rm -rf /etc/v2ray-agent/tls/*
installTLS $1
fi
2020-05-23 23:21:43 +08:00
fi
2020-08-10 17:17:14 +08:00
}
2020-09-25 16:08:25 +08:00
# 配置伪装博客
2020-08-18 13:44:19 +08:00
initNginxConfig( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $2 / ${ totalProgress } : 配置Nginx "
2020-08-18 13:44:19 +08:00
installType = $1
2020-08-18 16:22:06 +08:00
2020-09-25 16:08:25 +08:00
if [ [ " ${ installType } " = "vlesstcpws" ] ]
2020-08-18 13:44:19 +08:00
then
2020-08-29 23:12:20 +08:00
cat << EOF > /etc/nginx/conf.d/alone.conf
server {
listen 80;
server_name ${ domain } ;
root /usr/share/nginx/html;
location ~ /.well-known { allow all; }
location /test { return 200 'fjkvymb6len' ; }
}
EOF
2020-08-18 13:44:19 +08:00
fi
}
# 自定义/随机路径
randomPathFunction( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 生成随机路径 "
2020-09-01 17:38:48 +08:00
progressTools "yellow" "请输入自定义路径[例: alone],不需要斜杠,[回车]随机路径"
read -p '路径:' customPath
2020-06-11 15:39:59 +08:00
2020-09-01 17:38:48 +08:00
if [ [ -z " ${ customPath } " ] ]
2020-06-11 15:39:59 +08:00
then
2020-08-06 16:33:33 +08:00
customPath = ` head -n 50 /dev/urandom| sed 's/[^a-z]//g' | strings -n 4| tr 'A-Z' 'a-z' | head -1`
2020-06-11 15:39:59 +08:00
fi
2020-08-06 16:33:33 +08:00
echoContent yellow " path: ${ customPath } "
2020-08-18 13:44:19 +08:00
}
2020-08-18 15:45:55 +08:00
# Nginx伪装博客
2020-08-18 13:44:19 +08:00
nginxBlog( ) {
2020-09-02 16:48:05 +08:00
# echoContent yellow "添加伪装博客--->"
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 添加伪装博客 "
2020-05-24 21:05:38 +08:00
rm -rf /usr/share/nginx/html
2020-09-10 17:25:20 +08:00
wget -q -P /usr/share/nginx https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html.zip > /dev/null
2020-05-24 22:04:37 +08:00
unzip /usr/share/nginx/html.zip -d /usr/share/nginx/html > /dev/null
2020-09-02 16:48:05 +08:00
echoContent green " ---> 添加伪装博客成功"
2020-08-18 13:44:19 +08:00
}
# 操作Nginx
handleNginx( ) {
2020-08-18 17:03:59 +08:00
if [ [ -z ` ps -ef| grep -v grep| grep nginx` ] ] && [ [ " $1 " = "start" ] ]
2020-05-23 23:21:43 +08:00
then
2020-08-18 13:44:19 +08:00
nginx
2020-09-25 17:03:29 +08:00
sleep 0.5
2020-08-18 13:44:19 +08:00
if [ [ -z ` ps -ef| grep -v grep| grep nginx` ] ]
then
progressTools "red" " Nginx启动失败, 请检查日志--->"
exit 0
fi
2020-08-18 16:22:06 +08:00
elif [ [ " $1 " = "stop" ] ] && [ [ ! -z ` ps -ef| grep -v grep| grep nginx` ] ]
2020-08-18 13:44:19 +08:00
then
2020-09-18 17:50:02 +08:00
nginx -s stop > /dev/null 2>& 1
2020-09-24 15:03:28 +08:00
sleep 0.5
2020-09-18 17:50:02 +08:00
if [ [ ! -z ` ps -ef| grep -v grep| grep nginx` ] ]
then
ps -ef| grep -v grep| grep nginx| awk '{print $2}' | xargs kill -9
fi
2020-05-23 23:21:43 +08:00
fi
2019-11-06 10:58:06 +08:00
}
2020-08-18 13:44:19 +08:00
# 定时任务更新tls证书
installCronTLS( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 添加定时维护证书 "
2020-07-13 17:46:39 +08:00
if [ [ -z ` crontab -l| grep -v grep| grep 'reloadInstallTLS' ` ] ]
then
2020-09-01 17:38:48 +08:00
crontab -l >> /etc/v2ray-agent/backup_crontab.cron
2020-07-13 17:46:39 +08:00
# 定时任务
2020-09-01 17:38:48 +08:00
echo "30 1 * * * /bin/bash /etc/v2ray-agent/reloadInstallTLS.sh" >> /etc/v2ray-agent/backup_crontab.cron
crontab /etc/v2ray-agent/backup_crontab.cron
2020-07-13 17:46:39 +08:00
fi
2020-07-07 18:05:18 +08:00
# 备份
2020-07-13 17:46:39 +08:00
2020-09-01 17:38:48 +08:00
cat << EOF > /etc/v2ray-agent/reloadInstallTLS.sh
2020-09-11 16:36:29 +08:00
#!/usr/bin/env bash
echoContent( ) {
2020-09-11 23:26:55 +08:00
case \$ 1 in
2020-09-11 16:36:29 +08:00
# 红色
"red" )
2020-09-11 23:26:55 +08:00
echo -e "\033[31m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
# 天蓝色
"skyBlue" )
2020-09-11 23:26:55 +08:00
echo -e "\033[1;36m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
# 绿色
"green" )
2020-09-11 23:26:55 +08:00
echo -e "\033[32m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
# 白色
"white" )
2020-09-11 23:26:55 +08:00
echo -e "\033[37m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
"magenta" )
2020-09-11 23:26:55 +08:00
echo -e "\033[31m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
"skyBlue" )
2020-09-11 23:26:55 +08:00
echo -e "\033[36m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
# 黄色
"yellow" )
2020-09-11 23:26:55 +08:00
echo -e "\033[33m\${printN}\$2 \033[0m"
2020-09-11 16:36:29 +08:00
; ;
esac
}
echoContent skyBlue "\n进度 1/1 : 更新证书"
if [ [ -d "/etc/v2ray-agent" ] ] && [ [ -d "/etc/v2ray-agent/v2ray" ] ] && [ [ -d "/etc/v2ray-agent/tls" ] ] && [ [ -d "/etc/v2ray-agent" ] ] && [ [ -d "/etc/v2ray-agent/v2ray" ] ] && [ [ -f "/etc/v2ray-agent/v2ray/config.json" ] ] && [ [ -d "/root/.acme.sh" ] ]
then
2020-09-11 23:26:55 +08:00
tcp = \` cat /etc/v2ray-agent/v2ray/config.json| jq .inbounds[ 0] \`
2020-09-27 17:57:20 +08:00
host = \` echo \$ { tcp} | jq .streamSettings.xtlsSettings.certificates[ 0] .certificateFile| awk -F '[t][l][s][/]' '{print \$2}' | awk -F '["]' '{print \$1}' | awk -F '[.][c][r][t]' '{print \$1}' \`
2020-09-11 23:26:55 +08:00
if [ [ -d "/root/.acme.sh/\${host}_ecc" ] ] && [ [ -f "/root/.acme.sh/\${host}_ecc/\${host}.key" ] ] && [ [ -f "/root/.acme.sh/\${host}_ecc/\${host}.cer" ] ]
2020-09-11 16:36:29 +08:00
then
2020-09-11 23:26:55 +08:00
modifyTime = \` stat /root/.acme.sh/\$ { host} _ecc/\$ { host} .key| sed -n '6,6p' | awk '{print \$2" "\$3" "\$4" "\$5}' \`
2020-09-11 16:36:29 +08:00
2020-09-11 23:26:55 +08:00
modifyTime = \` date +%s -d "\${modifyTime}" \`
currentTime = \` date +%s\`
# currentTime=\`date +%s -d "2021-09-04 02:15:56.438105732 +0000"\`
2020-09-11 16:36:29 +08:00
# currentTIme=1609459200
2020-09-11 23:26:55 +08:00
stampDiff = \` expr \$ { currentTime} - \$ { modifyTime} \`
days = \` expr \$ { stampDiff} / 86400\`
remainingDays = \` expr 90 - \$ { days} \`
tlsStatus = \$ { remainingDays}
if [ [ \$ { remainingDays} -le 0 ] ]
2020-09-11 16:36:29 +08:00
then
tlsStatus = "已过期"
fi
2020-09-11 23:26:55 +08:00
echoContent skyBlue " ---> 证书生成日期:" \` date -d @\$ { modifyTime} +"%F %H:%M:%S" \`
echoContent skyBlue " ---> 证书生成天数:" \$ { days}
echoContent skyBlue " ---> 证书剩余天数:" \$ { tlsStatus}
if [ [ \$ { remainingDays} -le 1 ] ]
2020-08-04 16:56:55 +08:00
then
2020-09-11 16:36:29 +08:00
echoContent yellow " ---> 重新生成证书"
2020-09-11 23:26:55 +08:00
if [ [ \` ps -ef| grep -v grep| grep nginx\` ] ]
2020-08-04 16:56:55 +08:00
then
nginx -s stop
fi
2020-09-11 23:26:55 +08:00
sudo ~/.acme.sh/acme.sh --installcert -d \$ { host} --fullchainpath /etc/v2ray-agent/tls/\$ { host} .crt --keypath /etc/v2ray-agent/tls/\$ { host} .key --ecc >> /etc/v2ray-agent/tls/acme.log
2020-09-11 16:36:29 +08:00
nginx
2020-09-11 23:26:55 +08:00
if [ [ \` ps -ef| grep -v grep| grep nginx\` ] ]
2020-09-11 16:36:29 +08:00
then
echoContent green " ---> nginx启动成功"
else
echoContent red " ---> nginx启动失败, 请检查[/etc/v2ray-agent/tls/acme.log]"
fi
2020-08-04 16:56:55 +08:00
else
2020-09-11 16:36:29 +08:00
echoContent green " ---> 证书有效"
2020-08-04 16:56:55 +08:00
fi
2020-09-11 16:36:29 +08:00
else
echoContent red " ---> 无法找到相应路径,请使用脚本重新安装"
fi
else
echoContent red " ---> 无法找到相应路径,请使用脚本重新安装"
fi
2020-08-04 16:56:55 +08:00
EOF
2020-07-13 17:46:39 +08:00
if [ [ ! -z ` crontab -l| grep -v grep| grep 'reloadInstallTLS' ` ] ]
2020-07-07 18:05:18 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 添加定时维护证书成功"
2020-07-07 18:05:18 +08:00
else
2020-09-01 17:38:48 +08:00
crontab -l >> /etc/v2ray-agent/backup_crontab.cron
2020-07-13 17:46:39 +08:00
# 定时任务
2020-09-01 17:38:48 +08:00
crontab /etc/v2ray-agent/backup_crontab.cron
2020-09-02 16:48:05 +08:00
echoContent green " ---> 添加定时维护证书成功"
2020-07-07 18:05:18 +08:00
fi
2020-07-03 18:01:32 +08:00
}
2020-09-11 16:36:29 +08:00
# 更新证书
renewalTLS( ) {
echoContent skyBlue "\n进度 1/1 : 更新证书"
if [ [ -d "/etc/v2ray-agent" ] ] && [ [ -d "/etc/v2ray-agent/v2ray" ] ] && [ [ -d "/etc/v2ray-agent/tls" ] ] && [ [ -d "/etc/v2ray-agent" ] ] && [ [ -d "/etc/v2ray-agent/v2ray" ] ] && [ [ -f "/etc/v2ray-agent/v2ray/config.json" ] ] && [ [ -d "/root/.acme.sh" ] ]
then
tcp = ` cat /etc/v2ray-agent/v2ray/config.json| jq .inbounds[ 0] `
2020-09-27 17:57:20 +08:00
host = ` echo ${ tcp } | jq .streamSettings.xtlsSettings.certificates[ 0] .certificateFile| awk -F '[t][l][s][/]' '{print $2}' | awk -F '["]' '{print $1}' | awk -F '[.][c][r][t]' '{print $1}' `
2020-09-11 16:36:29 +08:00
if [ [ -d " /root/.acme.sh/ ${ host } _ecc " ] ] && [ [ -f " /root/.acme.sh/ ${ host } _ecc/ ${ host } .key " ] ] && [ [ -f " /root/.acme.sh/ ${ host } _ecc/ ${ host } .cer " ] ]
then
modifyTime = ` stat /root/.acme.sh/${ host } _ecc/${ host } .key| sed -n '6,6p' | awk '{print $2" "$3" "$4" "$5}' `
modifyTime = ` date +%s -d " ${ modifyTime } " `
currentTime = ` date +%s`
# currentTime=`date +%s -d "2021-09-04 02:15:56.438105732 +0000"`
# currentTIme=1609459200
stampDiff = ` expr ${ currentTime } - ${ modifyTime } `
days = ` expr ${ stampDiff } / 86400`
remainingDays = ` expr 90 - ${ days } `
tlsStatus = ${ remainingDays }
if [ [ ${ remainingDays } -le 0 ] ]
then
tlsStatus = "已过期"
fi
echoContent skyBlue " ---> 证书生成日期:" ` date -d @${ modifyTime } +"%F %H:%M:%S" `
echoContent skyBlue " ---> 证书生成天数:" ${ days }
echoContent skyBlue " ---> 证书剩余天数:" ${ tlsStatus }
if [ [ ${ remainingDays } -le 1 ] ]
then
echoContent yellow " ---> 重新生成证书"
if [ [ ` ps -ef| grep -v grep| grep nginx` ] ]
then
nginx -s stop
fi
sudo ~/.acme.sh/acme.sh --installcert -d ${ host } --fullchainpath /etc/v2ray-agent/tls/${ host } .crt --keypath /etc/v2ray-agent/tls/${ host } .key --ecc >> /etc/v2ray-agent/tls/acme.log
nginx
if [ [ ` ps -ef| grep -v grep| grep nginx` ] ]
then
echoContent green " ---> nginx启动成功"
else
echoContent red " ---> nginx启动失败, 请检查[/etc/v2ray-agent/tls/acme.log]"
fi
else
echoContent green " ---> 证书有效"
fi
else
echoContent red " ---> 无法找到相应路径,请使用脚本重新安装"
fi
else
echoContent red " ---> 无法找到相应路径,请使用脚本重新安装"
fi
}
2020-08-18 13:44:19 +08:00
# 安装V2Ray
2019-11-06 10:58:06 +08:00
installV2Ray( ) {
2020-09-01 17:38:48 +08:00
# ls -F /usr/bin/v2ray/|grep "v2ray"
# mkdir -p /usr/bin/v2ray/
# mkdir -p /etc/v2ray-agent/v2ray/
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 安装V2Ray "
2020-08-04 16:20:52 +08:00
if [ [ -z ` ls -F /etc/v2ray-agent/v2ray/| grep "v2ray" ` ] ] || [ [ -z ` ls -F /etc/v2ray-agent/v2ray/| grep "v2ctl" ` ] ]
2020-05-23 23:21:43 +08:00
then
2020-09-01 17:38:48 +08:00
version = ` curl -s https://github.com/v2fly/v2ray-core/releases| grep /v2ray-core/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
2020-09-11 14:13:51 +08:00
# version="v4.27.4"
2020-09-02 16:48:05 +08:00
echoContent green " ---> v2ray-core版本: ${ version } "
2020-09-02 17:09:25 +08:00
wget -q -P /etc/v2ray-agent/v2ray/ https://github.com/v2fly/v2ray-core/releases/download/${ version } /v2ray-linux-64.zip
2020-09-01 17:38:48 +08:00
unzip /etc/v2ray-agent/v2ray/v2ray-linux-64.zip -d /etc/v2ray-agent/v2ray > /dev/null
rm -rf /etc/v2ray-agent/v2ray/v2ray-linux-64.zip
2020-05-23 23:21:43 +08:00
else
2020-09-11 14:13:51 +08:00
# progressTools "green" " v2ray-core版本:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2}'|head -1`"
2020-09-02 16:48:05 +08:00
echoContent green " ---> v2ray-core版本:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2 }'|head -1` "
2020-09-02 17:12:17 +08:00
read -p "是否重新安装?[y/n]:" reInstalV2RayStatus
2020-09-04 11:55:08 +08:00
if [ [ " ${ reInstalV2RayStatus } " = "y" ] ]
2020-09-02 17:12:17 +08:00
then
rm -rf /etc/v2ray-agent/v2ray/*
installV2Ray $1
fi
2020-05-23 23:21:43 +08:00
fi
2020-08-18 13:44:19 +08:00
}
2020-09-21 15:21:16 +08:00
# 安装Trojan-go
installTrojanGo( ) {
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 安装Trojan-Go "
if [ [ -z ` ls -F /etc/v2ray-agent/trojan/| grep "trojan-go" ` ] ] || [ [ -z ` ls -F /etc/v2ray-agent/trojan/| grep "trojan-go" ` ] ]
then
version = ` curl -s https://github.com/p4gefau1t/trojan-go/releases| grep /trojan-go/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
# version="v4.27.4"
echoContent green " ---> Trojan-Go版本: ${ version } "
wget -q -P /etc/v2ray-agent/trojan/ https://github.com/p4gefau1t/trojan-go/releases/download/${ version } /trojan-go-linux-amd64.zip
unzip /etc/v2ray-agent/trojan/trojan-go-linux-amd64.zip -d /etc/v2ray-agent/trojan > /dev/null
rm -rf /etc/v2ray-agent/trojan/trojan-go-linux-amd64.zip
else
# progressTools "green" " v2ray-core版本:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2}'|head -1`"
echoContent green " ---> Trojan-Go版本:`/etc/v2ray-agent/trojan/trojan-go --version|awk '{print $2 }'|head -1` "
read -p "是否重新安装?[y/n]:" reInstalTrojanStatus
if [ [ " ${ reInstalV2RayStatus } " = "y" ] ]
then
rm -rf /etc/v2ray-agent/trojan/*
installTrojanGo $1
fi
fi
}
2020-09-03 15:32:27 +08:00
# 更新V2Ray
updateV2Ray( ) {
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 更新V2Ray "
if [ [ ! -d "/etc/v2ray-agent/v2ray/" ] ]
then
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
menu
exit 0;
fi
if [ [ -z ` ls -F /etc/v2ray-agent/v2ray/| grep "v2ray" ` ] ] || [ [ -z ` ls -F /etc/v2ray-agent/v2ray/| grep "v2ctl" ` ] ]
then
version = ` curl -s https://github.com/v2fly/v2ray-core/releases| grep /v2ray-core/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
echoContent green " ---> v2ray-core版本: ${ version } "
wget -q -P /etc/v2ray-agent/v2ray/ https://github.com/v2fly/v2ray-core/releases/download/${ version } /v2ray-linux-64.zip
unzip /etc/v2ray-agent/v2ray/v2ray-linux-64.zip -d /etc/v2ray-agent/v2ray > /dev/null
2020-09-04 15:25:07 +08:00
if [ [ " $2 " = "backup" ] ]
then
cp /tmp/config.json /etc/v2ray-agent/v2ray/config.json
fi
2020-09-03 15:32:27 +08:00
rm -rf /etc/v2ray-agent/v2ray/v2ray-linux-64.zip
2020-09-04 15:25:07 +08:00
handleV2Ray stop
2020-09-03 15:32:27 +08:00
handleV2Ray start
else
echoContent green " ---> 当前v2ray-core版本:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2 }'|head -1` "
if [ [ ! -z ` /etc/v2ray-agent/v2ray/v2ray --version` ] ]
then
version = ` curl -s https://github.com/v2fly/v2ray-core/releases| grep /v2ray-core/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
2020-09-11 14:13:51 +08:00
# echo version:${version}
# echo version2:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2}'|head -1`
2020-09-03 15:32:27 +08:00
if [ [ " ${ version } " = " v`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2 }'|head -1` " ] ]
then
read -p "当前版本与最新版相同,是否重新安装?[y/n]:" reInstalV2RayStatus
if [ [ " ${ reInstalV2RayStatus } " = "y" ] ]
then
handleV2Ray stop
2020-09-04 15:25:07 +08:00
cp /etc/v2ray-agent/v2ray/config.json /tmp/config.json
2020-09-03 15:32:27 +08:00
rm -rf /etc/v2ray-agent/v2ray/*
2020-09-04 15:25:07 +08:00
updateV2Ray $1 backup
else
echoContent green " ---> 放弃重新安装"
fi
else
read -p " 最新版本为: ${ version } ,是否更新?[y/n]: " installV2RayStatus
if [ [ " ${ installV2RayStatus } " = "y" ] ]
then
cp /etc/v2ray-agent/v2ray/config.json /tmp/config.json
rm -rf /etc/v2ray-agent/v2ray/*
updateV2Ray $1 backup
2020-09-03 15:32:27 +08:00
else
echoContent green " ---> 放弃更新"
fi
2020-09-04 15:25:07 +08:00
2020-09-03 15:32:27 +08:00
fi
fi
fi
}
2020-09-24 15:03:28 +08:00
# 更新Trojan-Go
updateTrojanGo( ) {
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 更新Trojan-Go "
if [ [ ! -d "/etc/v2ray-agent/trojan/" ] ]
then
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
menu
exit 0;
fi
if [ [ -z ` ls -F /etc/v2ray-agent/trojan/| grep "trojan-go" ` ] ]
then
version = ` curl -s https://github.com/p4gefau1t/trojan-go/releases| grep /trojan-go/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
echoContent green " ---> Trojan-Go版本: ${ version } "
wget -q -P /etc/v2ray-agent/trojan/ https://github.com/p4gefau1t/trojan-go/releases/download/${ version } /trojan-go-linux-amd64.zip
unzip /etc/v2ray-agent/trojan/trojan-go-linux-amd64.zip -d /etc/v2ray-agent/trojan > /dev/null
if [ [ " $2 " = "backup" ] ]
then
cp /tmp/trojan_config.json /etc/v2ray-agent/trojan/config.json
fi
rm -rf /etc/v2ray-agent/trojan/trojan-go-linux-amd64.zip
handleTrojanGo stop
handleTrojanGo start
else
echoContent green " ---> 当前Trojan-Go版本:`/etc/v2ray-agent/trojan/trojan-go --version|awk '{print $2 }'|head -1` "
if [ [ ! -z ` /etc/v2ray-agent/trojan/trojan-go --version` ] ]
then
version = ` curl -s https://github.com/p4gefau1t/trojan-go/releases| grep /trojan-go/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
# echo version:${version}
# echo version2:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2}'|head -1`
if [ [ " ${ version } " = " `/etc/v2ray-agent/trojan/trojan-go --version|awk '{print $2 }'|head -1` " ] ]
then
read -p "当前版本与最新版相同,是否重新安装?[y/n]:" reInstalTrojanGoStatus
if [ [ " ${ reInstalTrojanGoStatus } " = "y" ] ]
then
handleTrojanGo stop
cp /etc/v2ray-agent/trojan/config.json /tmp/trojan_config.json
rm -rf /etc/v2ray-agent/trojan/*
updateTrojanGo $1 backup
else
echoContent green " ---> 放弃重新安装"
fi
else
read -p " 最新版本为: ${ version } ,是否更新?[y/n]: " installTrojanGoStatus
if [ [ " ${ installTrojanGoStatus } " = "y" ] ]
then
cp /etc/v2ray-agent/trojan/config.json /tmp/trojan_config.json
rm -rf /etc/v2ray-agent/trojan/*
updateTrojanGo $1 backup
else
echoContent green " ---> 放弃更新"
fi
fi
fi
fi
}
2020-09-07 17:42:10 +08:00
# 自动升级
automaticUpgrade( ) {
if [ [ -f "/root/install.sh" ] ] && [ [ ! -z ` cat ~/install.sh| grep -v grep| grep mack-a` ] ] && [ [ -d "/etc/v2ray-agent" ] ]
then
local currentTime = ` date +%s`
local version = 0
local currentVersion = 0
# 首次安装完毕后再次使用时出发
if [ [ ! -f "/etc/v2ray-agent/upgradeStatus" ] ]
then
echo " firstUpgrade| ${ currentTime } " > /etc/v2ray-agent/upgradeStatus
fi
if [ [ -z ` cat /etc/v2ray-agent/upgradeStatus` ] ]
then
echo " firstUpgrade| ${ currentTime } " > /etc/v2ray-agent/upgradeStatus
fi
# 第一次升级不计算时间
if [ [ " `cat /etc/v2ray-agent/upgradeStatus|awk -F '[|]' '{print $1 }'` " = "firstUpgrade" ] ]
then
version = ` curl -s https://github.com/mack-a/v2ray-agent/releases| grep -v grep| grep /mack-a/v2ray-agent/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
currentVersion = ` cat /root/install.sh| grep -v grep| grep "当前版本:" | awk '{print $3}' | awk -F "[\"]" '{print $2}' | awk -F "[v]" '{print $2}' `
echo " upgrade| ${ currentTime } " > /etc/v2ray-agent/upgradeStatus
2020-09-11 17:13:22 +08:00
elif [ [ " `cat /etc/v2ray-agent/upgradeStatus|awk -F '[|]' '{print $1 }'` " = "upgrade" ] ] && [ [ ! -z ` cat /etc/v2ray-agent/upgradeStatus| awk -F '[|]' '{print $2}' ` ] ]
2020-09-07 17:42:10 +08:00
then
# 第二次计算时间 三天
local lastTime = ` cat /etc/v2ray-agent/upgradeStatus| awk -F '[|]' '{print $2}' `
local stampDiff = ` expr ${ currentTime } - ${ lastTime } `
dayDiff = ` expr ${ stampDiff } / 86400`
if [ [ ${ dayDiff } -gt 3 ] ]
then
version = ` curl -s https://github.com/mack-a/v2ray-agent/releases| grep -v grep| grep /mack-a/v2ray-agent/releases/tag/| head -1| awk -F "[/]" '{print $6}' | awk -F "[>]" '{print $2}' | awk -F "[<]" '{print $1}' `
currentVersion = ` cat /root/install.sh| grep -v grep| grep "当前版本:" | awk '{print $3}' | awk -F "[\"]" '{print $2}' | awk -F "[v]" '{print $2}' `
echo " upgrade| ${ currentTime } " > /etc/v2ray-agent/upgradeStatus
fi
fi
if [ [ " v ${ currentVersion } " != " ${ version } " ] ] && [ [ " ${ version } " != "0" ] ] && [ [ " ${ currentVersion } " != "0" ] ]
then
echoContent yellow " ---> 当前版本:`echo ${ version } |grep -v grep|awk -F '[v]' '{print $2 }'` "
echoContent green " ---> 新 版 本: ${ currentVersion } "
read -p "发现新版本,是否更新[y/n]? : " upgradeStatus
if [ [ " ${ upgradeStatus } " = "y" ] ]
then
updateV2RayAgent 1
menu
else
echo " notUpgrade| ${ currentTime } " > /etc/v2ray-agent/upgradeStatus
menu
exit;
fi
fi
fi
}
2020-09-03 17:58:25 +08:00
updateV2RayAgent( ) {
2020-09-11 17:13:22 +08:00
local currentTime = ` date +%s`
2020-09-07 17:42:10 +08:00
echo " upgrade| ${ currentTime } " > /etc/v2ray-agent/upgradeStatus
2020-09-03 17:58:25 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 更新v2ray-agent脚本 "
2020-09-12 22:42:00 +08:00
wget -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod +x install.sh && ./install.sh
2020-09-03 17:58:25 +08:00
}
2020-08-18 13:44:19 +08:00
# 验证整个服务是否可用
checkGFWStatue( ) {
2020-08-27 16:57:42 +08:00
# 验证整个服务是否可用
2020-09-02 16:48:05 +08:00
# progressTools "yellow" "验证服务是否可用--->"
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 验证服务是否可用 "
2020-08-27 16:57:42 +08:00
if [ [ " ${ globalType } " = "wss" ] ]
2020-05-23 23:21:43 +08:00
then
2020-08-27 16:57:42 +08:00
2020-09-01 17:59:22 +08:00
sleep 3
2020-08-27 16:57:42 +08:00
if [ [ ! -z ` curl -s -L https://${ domain } /${ customPath } | grep -v grep| grep "Bad Request" ` ] ]
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 服务可用"
2020-08-27 16:57:42 +08:00
else
2020-09-21 15:21:16 +08:00
echoContent red " ---> 服务不可用"
progressTools "red" " 1.请检查Cloudflare->域名->SSL/TLS->Overview->Your SSL/TLS encryption mode is 是否是Full--->"
progressTools "red" " 2.请执行[ps -ef|grep v2ray]查看结果是否有如下信息,如果存在则执行脚本选择[4查看账号]即可--->"
progressTools "red" " /etc/v2ray-agent/trojan/trojan-go -config /etc/v2ray-agent/trojan/config.json"
progressTools "red" " /etc/v2ray-agent/v2ray/v2ray -config /etc/v2ray-agent/v2ray/config.json"
progressTools "red" " 3.如以上都无法解决,请联系开发者[https://t.me/mack_a]"
2020-08-27 16:57:42 +08:00
progressTools "red" " 错误日志:`curl -s -L https:// ${ domain } / ${ customPath } ` "
exit 0
fi
elif [ [ " ${ globalType } " = "tcp" ] ]
then
2020-09-04 15:25:07 +08:00
echo '' > /etc/v2ray-agent/v2ray/v2ray_access.log
2020-08-27 16:57:42 +08:00
curl --connect-time 3 --max-time 1 --url https://${ domain } > /dev/null 2>& 1
sleep 0.1
2020-09-04 15:25:07 +08:00
if [ [ ! -z ` cat /etc/v2ray-agent/v2ray/v2ray_access.log| grep -v grep| grep "Not Found" ` ] ]
2020-08-27 16:57:42 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 服务可用"
2020-08-27 16:57:42 +08:00
else
progressTools "red" " 服务不可用"
progressTools "red" " 1.请检查云朵是否关闭"
2020-09-04 15:25:07 +08:00
progressTools "red" " 2.请手动尝试使用账号并观察日志,日志路径[/etc/v2ray-agent/v2ray/v2ray_access.log]"
2020-08-27 16:57:42 +08:00
exit 0
fi
2020-08-29 23:12:20 +08:00
elif [ [ " ${ globalType } " = "vlesstcpws" ] ]
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 等待三秒"
2020-09-01 17:59:22 +08:00
sleep 3
2020-08-29 23:12:20 +08:00
if [ [ ! -z ` curl -s -L https://${ domain } /${ customPath } | grep -v grep| grep "Bad Request" ` ] ]
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> 服务可用"
2020-08-29 23:12:20 +08:00
else
progressTools "red" " 服务不可用, 请检查Cloudflare->域名->SSL/TLS->Overview->Your SSL/TLS encryption mode is 是否是Full--->"
progressTools "red" " 错误日志:`curl -s -L https:// ${ domain } / ${ customPath } ` "
exit 0
fi
2020-05-23 23:21:43 +08:00
fi
}
2020-09-21 15:21:16 +08:00
# V2Ray开机自启
2020-05-23 23:21:43 +08:00
installV2RayService( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 配置V2Ray开机自启 "
2020-08-18 13:44:19 +08:00
if [ [ ! -z ` find /bin /usr/bin -name "systemctl" ` ] ]
then
rm -rf /etc/systemd/system/v2ray.service
touch /etc/systemd/system/v2ray.service
2020-08-02 19:14:20 +08:00
2020-08-18 13:44:19 +08:00
cat << EOF > /etc/systemd/system/v2ray.service
[ Unit]
Description = V2Ray - A unified platform for anti-censorship
Documentation = https://v2ray.com https://guide.v2fly.org
After = network.target nss-lookup.target
Wants = network-online.target
2020-08-04 16:56:55 +08:00
2020-08-18 13:44:19 +08:00
[ Service]
Type = simple
User = root
CapabilityBoundingSet = CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges = yes
2020-09-01 17:38:48 +08:00
ExecStart = /etc/v2ray-agent/v2ray/v2ray -config /etc/v2ray-agent/v2ray/config.json
2020-08-18 13:44:19 +08:00
Restart = on-failure
RestartPreventExitStatus = 23
2020-08-04 16:56:55 +08:00
2020-08-18 13:44:19 +08:00
[ Install]
WantedBy = multi-user.target
2020-08-04 16:56:55 +08:00
EOF
2020-08-18 13:44:19 +08:00
systemctl daemon-reload
systemctl enable v2ray.service
2020-09-02 16:48:05 +08:00
echoContent green " ---> 配置V2Ray开机自启成功"
2020-08-18 13:44:19 +08:00
fi
}
2020-09-21 15:21:16 +08:00
# Trojan开机自启
installTrojanService( ) {
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 配置Trojan开机自启 "
if [ [ ! -z ` find /bin /usr/bin -name "systemctl" ` ] ]
then
rm -rf /etc/systemd/system/trojan-go.service
touch /etc/systemd/system/trojan-go.service
cat << EOF > /etc/systemd/system/trojan-go.service
2020-09-25 18:01:23 +08:00
[ Unit]
Description = Trojan-Go - A unified platform for anti-censorship
Documentation = Trojan-Go
After = network.target nss-lookup.target
Wants = network-online.target
[ Service]
Type = simple
User = root
CapabilityBoundingSet = CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges = yes
ExecStart = /etc/v2ray-agent/trojan/trojan-go -config /etc/v2ray-agent/trojan/config.json
Restart = on-failure
RestartPreventExitStatus = 23
[ Install]
WantedBy = multi-user.target
2020-09-21 15:21:16 +08:00
EOF
systemctl daemon-reload
systemctl enable trojan-go.service
echoContent green " ---> 配置Trojan开机自启成功"
fi
}
2020-08-18 13:44:19 +08:00
# 操作V2Ray
handleV2Ray( ) {
if [ [ ! -z ` find /bin /usr/bin -name "systemctl" ` ] ] && [ [ ! -z ` ls /etc/systemd/system/| grep -v grep| grep v2ray.service` ] ]
then
2020-09-21 15:21:16 +08:00
if [ [ -z ` ps -ef| grep -v grep| grep "v2ray/v2ray" ` ] ] && [ [ " $1 " = "start" ] ]
2020-08-18 13:44:19 +08:00
then
systemctl start v2ray.service
2020-09-21 15:21:16 +08:00
elif [ [ ! -z ` ps -ef| grep -v grep| grep "v2ray/v2ray" ` ] ] && [ [ " $1 " = "stop" ] ]
2020-08-18 13:44:19 +08:00
then
systemctl stop v2ray.service
fi
elif [ [ -z ` find /bin /usr/bin -name "systemctl" ` ] ]
then
if [ [ -z ` ps -ef| grep -v grep| grep v2ray` ] ] && [ [ " $1 " = "start" ] ]
then
2020-09-01 17:38:48 +08:00
/usr/bin/v2ray/v2ray -config /etc/v2ray-agent/v2ray/config.json & > /dev/null 2>& 1
2020-08-18 16:22:06 +08:00
elif [ [ ! -z ` ps -ef| grep -v grep| grep v2ray` ] ] && [ [ " $1 " = "stop" ] ]
2020-08-18 13:44:19 +08:00
then
ps -ef| grep -v grep| grep v2ray| awk '{print $2}' | xargs kill -9
fi
fi
2020-09-25 17:03:29 +08:00
sleep 0.5
2020-08-18 13:44:19 +08:00
if [ [ " $1 " = "start" ] ]
then
2020-09-21 15:21:16 +08:00
if [ [ ! -z ` ps -ef| grep -v grep| grep "v2ray/v2ray" ` ] ]
2020-08-18 13:44:19 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> V2Ray启动成功"
2020-08-18 13:44:19 +08:00
else
2020-09-02 16:48:05 +08:00
echoContent red "V2Ray启动失败"
2020-09-21 15:21:16 +08:00
echoContent red "请手动执行【/etc/v2ray-agent/v2ray/v2ray -config /etc/v2ray-agent/v2ray/config.json】,查看错误日志"
2020-08-18 15:45:55 +08:00
exit 0;
2020-08-18 13:44:19 +08:00
fi
elif [ [ " $1 " = "stop" ] ]
then
2020-09-21 15:21:16 +08:00
if [ [ -z ` ps -ef| grep -v grep| grep "v2ray/v2ray" ` ] ]
2020-08-18 13:44:19 +08:00
then
2020-09-02 16:48:05 +08:00
echoContent green " ---> V2Ray关闭成功"
2020-08-18 13:44:19 +08:00
else
2020-09-02 16:48:05 +08:00
echoContent red "V2Ray关闭失败"
echoContent red "请手动执行【ps -ef|grep -v grep|grep v2ray|awk '{print \$2}'|xargs kill -9】"
2020-08-18 15:45:55 +08:00
exit 0;
2020-08-18 13:44:19 +08:00
fi
fi
2020-05-23 23:21:43 +08:00
}
2020-09-21 15:21:16 +08:00
# 操作Trojan-Go
handleTrojanGo( ) {
if [ [ ! -z ` find /bin /usr/bin -name "systemctl" ` ] ] && [ [ ! -z ` ls /etc/systemd/system/| grep -v grep| grep trojan-go.service` ] ]
then
if [ [ -z ` ps -ef| grep -v grep| grep trojan-go` ] ] && [ [ " $1 " = "start" ] ]
then
systemctl start trojan-go.service
elif [ [ ! -z ` ps -ef| grep -v grep| grep trojan-go` ] ] && [ [ " $1 " = "stop" ] ]
then
systemctl stop trojan-go.service
fi
elif [ [ -z ` find /bin /usr/bin -name "systemctl" ` ] ]
then
if [ [ -z ` ps -ef| grep -v grep| grep trojan-go` ] ] && [ [ " $1 " = "start" ] ]
then
2020-09-25 17:42:16 +08:00
/etc/v2ray-agent/trojan/trojan-go -config /etc/v2ray-agent/trojan/config.json & > /dev/null 2>& 1
2020-09-21 15:21:16 +08:00
elif [ [ ! -z ` ps -ef| grep -v grep| grep trojan-go` ] ] && [ [ " $1 " = "stop" ] ]
then
ps -ef| grep -v grep| grep trojan-go| awk '{print $2}' | xargs kill -9
fi
fi
2020-09-25 17:03:29 +08:00
sleep 0.5
2020-09-21 15:21:16 +08:00
if [ [ " $1 " = "start" ] ]
then
2020-09-25 17:42:16 +08:00
if [ [ ! -z ` ps -ef| grep -v grep| grep trojan-go` ] ]
2020-09-21 15:21:16 +08:00
then
echoContent green " ---> Trojan-Go启动成功"
else
echoContent red "Trojan-Go启动失败"
2020-09-27 17:57:20 +08:00
echoContent red "请手动执行【/etc/v2ray-agent/trojan/trojan-go -config /etc/v2ray-agent/trojan/config.json】,查看错误日志"
2020-09-21 15:21:16 +08:00
exit 0;
fi
elif [ [ " $1 " = "stop" ] ]
then
if [ [ -z ` ps -ef| grep -v grep| grep trojan-go` ] ]
then
echoContent green " ---> Trojan-Go关闭成功"
else
echoContent red "Trojan-Go关闭失败"
echoContent red "请手动执行【ps -ef|grep -v grep|grep trojan-go|awk '{print \$2}'|xargs kill -9】"
exit 0;
fi
fi
}
2020-05-23 23:21:43 +08:00
# 初始化V2Ray 配置文件
initV2RayConfig( ) {
2020-08-02 19:14:20 +08:00
2020-09-01 17:38:48 +08:00
uuidtcp = ` /etc/v2ray-agent/v2ray/v2ctl uuid`
uuidws = ` /etc/v2ray-agent/v2ray/v2ctl uuid`
2020-09-08 14:21:30 +08:00
uuidVmessTcp = ` /etc/v2ray-agent/v2ray/v2ctl uuid`
2020-09-11 10:56:10 +08:00
uuidVlessWS = ` /etc/v2ray-agent/v2ray/v2ctl uuid`
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $2 / ${ totalProgress } : 初始化V2Ray配置 "
2020-08-04 17:27:37 +08:00
2020-09-25 16:08:25 +08:00
if [ [ " $1 " = "vlesstcpws" ] ]
2020-08-29 23:12:20 +08:00
then
2020-09-01 17:38:48 +08:00
cat << EOF > /etc/v2ray-agent/v2ray/config.json
2020-08-29 23:12:20 +08:00
{
"log" : {
2020-09-12 17:56:56 +08:00
"access" : "/etc/v2ray-agent/v2ray/v2ray_access.log" ,
"error" : "/etc/v2ray-agent/v2ray/v2ray_error.log" ,
2020-08-29 23:12:20 +08:00
"loglevel" : "debug"
} ,
"inbounds" : [
{
"port" : 443,
"protocol" : "vless" ,
"settings" : {
"clients" : [
{
2020-09-01 17:38:48 +08:00
"id" : " ${ uuidtcp } " ,
2020-08-29 23:12:20 +08:00
"alterId" : 0,
2020-09-27 17:57:20 +08:00
"flow" :"xtls-rprx-origin" ,
2020-09-04 15:25:07 +08:00
"email" : " ${ domain } _VLESS_TCP "
2020-08-29 23:12:20 +08:00
}
] ,
"decryption" : "none" ,
"fallbacks" : [
{
2020-09-21 15:21:16 +08:00
"dest" : 31296,
"xver" : 0
2020-08-29 23:12:20 +08:00
} ,
{
"path" : " / ${ customPath } " ,
"dest" : 31299,
"xver" : 1
2020-09-08 14:21:30 +08:00
} ,
{
"path" : " / ${ customPath } tcp " ,
"dest" : 31298,
"xver" : 1
2020-09-11 10:56:10 +08:00
} ,
{
"path" : " / ${ customPath } ws " ,
"dest" : 31297,
"xver" : 1
2020-08-29 23:12:20 +08:00
}
]
} ,
"streamSettings" : {
"network" : "tcp" ,
2020-09-27 17:57:20 +08:00
"security" : "xtls" ,
"xtlsSettings" : {
2020-08-29 23:12:20 +08:00
"alpn" : [
"http/1.1"
] ,
"certificates" : [
{
2020-09-01 17:38:48 +08:00
"certificateFile" : " /etc/v2ray-agent/tls/ ${ domain } .crt " ,
"keyFile" : " /etc/v2ray-agent/tls/ ${ domain } .key "
2020-08-29 23:12:20 +08:00
}
]
}
}
} ,
{
"port" : 31299,
"protocol" : "vmess" ,
"settings" : {
"clients" : [
{
2020-09-01 17:38:48 +08:00
"id" : " ${ uuidws } " ,
2020-09-12 20:08:29 +08:00
"alterId" : 1,
2020-09-11 10:56:10 +08:00
"add" : " ${ add } " ,
2020-09-12 20:08:29 +08:00
"level" : 0,
2020-09-04 15:25:07 +08:00
"email" : " ${ domain } _vmess_ws "
2020-08-29 23:12:20 +08:00
}
]
} ,
"streamSettings" : {
"network" : "ws" ,
"security" : "none" ,
"wsSettings" : {
"acceptProxyProtocol" : true,
"path" : " / ${ customPath } "
}
}
2020-09-08 14:21:30 +08:00
} ,
{
2020-09-11 10:56:10 +08:00
"port" : 31298,
"listen" : "127.0.0.1" ,
"protocol" : "vmess" ,
"settings" : {
"clients" : [
{
"id" : " ${ uuidVmessTcp } " ,
"level" : 0,
2020-09-12 20:11:24 +08:00
"alterId" : 1,
2020-09-11 10:56:10 +08:00
"email" : " ${ domain } _vmess_tcp "
}
]
} ,
"streamSettings" : {
"network" : "tcp" ,
"security" : "none" ,
"tcpSettings" : {
"acceptProxyProtocol" : true,
"header" : {
"type" : "http" ,
"request" : {
"path" : [
" / ${ customPath } tcp "
]
2020-09-08 14:21:30 +08:00
}
2020-09-11 10:56:10 +08:00
}
2020-09-08 14:21:30 +08:00
}
2020-09-11 10:56:10 +08:00
}
} ,
{
"port" : 31297,
"listen" : "127.0.0.1" ,
"protocol" : "vless" ,
"settings" : {
"clients" : [
{
"id" : " ${ uuidVlessWS } " ,
"level" : 0,
"email" : " ${ domain } _vless_ws "
}
] ,
"decryption" : "none"
} ,
"streamSettings" : {
"network" : "ws" ,
"security" : "none" ,
"wsSettings" : {
"acceptProxyProtocol" : true,
"path" : " / ${ customPath } ws "
}
}
}
2020-08-29 23:12:20 +08:00
] ,
"outbounds" : [
{
"protocol" : "freedom" ,
2020-09-12 17:56:56 +08:00
"settings" : {
"domainStrategy" : "UseIP"
}
2020-08-29 23:12:20 +08:00
}
] ,
"dns" : {
"servers" : [
2020-09-12 17:56:56 +08:00
"74.82.42.42" ,
2020-08-29 23:12:20 +08:00
"8.8.8.8" ,
2020-09-12 17:56:56 +08:00
"8.8.4.4" ,
"1.1.1.1" ,
"localhost"
]
2020-08-29 23:12:20 +08:00
}
}
2020-08-04 17:27:37 +08:00
EOF
2020-06-11 15:39:59 +08:00
fi
2019-11-06 10:58:06 +08:00
}
2020-09-21 15:21:16 +08:00
# 初始化Trojan-Go配置
initTrojanGoConfig( ) {
uuidTrojanGo = ` /etc/v2ray-agent/v2ray/v2ctl uuid`
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 初始化Trojan配置 "
cat << EOF > /etc/v2ray-agent/trojan/config.json
{
"run_type" : "server" ,
2020-09-27 17:57:20 +08:00
"local_addr" : "127.0.0.1" ,
2020-09-21 15:21:16 +08:00
"local_port" : 31296,
"remote_addr" : "127.0.0.1" ,
"remote_port" : 80,
"log_level" :0,
"log_file" :"/etc/v2ray-agent/trojan/trojan.log" ,
"password" : [
" ${ uuidTrojanGo } "
] ,
"transport_plugin" :{
"enabled" :true,
"type" :"plaintext"
2020-09-27 17:57:20 +08:00
} ,
"websocket" : {
"enabled" : true,
"path" : " / ${ customPath } tws " ,
2020-09-28 11:28:04 +08:00
"host" : " ${ domain } " ,
"add" :" ${ add } "
2020-09-27 17:57:20 +08:00
} ,
"router" : {
"enabled" : false
2020-09-21 15:21:16 +08:00
}
}
EOF
}
2020-08-18 13:44:19 +08:00
# 自定义CDN IP
customCDNIP( ) {
2020-09-02 16:48:05 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 添加DNS智能解析 "
echoContent yellow " 移动:104.19.41.56"
echoContent yellow " 联通:104.16.160.136"
2020-09-16 11:29:26 +08:00
echoContent yellow " 电信:104.17.78.198"
2020-09-02 16:48:05 +08:00
read -p '是否使用?[y/n]:' dnsProxy
2020-06-05 16:42:21 +08:00
if [ [ " ${ dnsProxy } " = "y" ] ]
2020-06-05 11:44:02 +08:00
then
2020-08-02 19:14:20 +08:00
add = "domain08.qiu4.ml"
2020-09-04 11:55:08 +08:00
else
add = " ${ domain } "
2020-06-05 11:44:02 +08:00
fi
2020-08-18 13:44:19 +08:00
}
2020-09-12 22:08:23 +08:00
2020-08-18 15:45:55 +08:00
# 通用
defaultBase64Code( ) {
2020-09-04 11:55:08 +08:00
local type = $1
local ps = $2
local id = $3
local host = $4
local path = $5
local add = $6
if [ [ ${ type } = "tcp" ] ]
2020-08-27 16:57:42 +08:00
then
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","net":"tcp","add":"' ${ host } '","allowInsecure":0,"method":"none","peer":""}' | sed 's#/#\\\/#g' | base64`
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
2020-09-02 16:48:05 +08:00
echoContent yellow " ---> 通用json(tcp+tls)"
2020-08-27 16:57:42 +08:00
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","net":"tcp","add":"' ${ host } '","allowInsecure":0,"method":"none","peer":""}\n'
2020-08-29 23:12:20 +08:00
# 通用Vmess
2020-09-02 16:48:05 +08:00
echoContent yellow " ---> 通用vmess(tcp+tls)链接"
2020-08-29 23:12:20 +08:00
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
2020-09-01 17:38:48 +08:00
echo "通用vmess(tcp+tls)链接: " > /etc/v2ray-agent/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Default } " >> /etc/v2ray-agent/v2ray/usersv2ray.conf
2020-09-04 11:55:08 +08:00
elif [ [ ${ type } = "wss" ] ]
2020-08-27 16:57:42 +08:00
then
2020-08-29 23:12:20 +08:00
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"ws","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}' | sed 's#/#\\\/#g' | base64`
2020-08-27 16:57:42 +08:00
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
2020-09-02 16:48:05 +08:00
echoContent yellow " ---> 通用json(ws+tls)"
2020-08-29 23:12:20 +08:00
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"ws","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}\n'
2020-09-02 16:48:05 +08:00
echoContent yellow " ---> 通用vmess(ws+tls)链接"
2020-08-29 23:12:20 +08:00
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
2020-09-01 17:38:48 +08:00
echo "通用vmess(ws+tls)链接: " > /etc/v2ray-agent/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Default } " >> /etc/v2ray-agent/v2ray/usersv2ray.conf
2020-09-04 11:55:08 +08:00
elif [ [ " ${ type } " = "h2" ] ]
2020-08-27 16:57:42 +08:00
then
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"h2","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":""}' | sed 's#/#\\\/#g' | base64`
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
2020-09-02 16:48:05 +08:00
echoContent red "通用json--->"
2020-08-27 16:57:42 +08:00
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"h2","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":""}\n'
2020-09-04 11:55:08 +08:00
elif [ [ " ${ type } " = "vlesstcp" ] ]
2020-08-29 23:12:20 +08:00
then
2020-09-08 14:21:30 +08:00
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"tcp","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}' | sed 's#/#\\\/#g' | base64`
2020-08-29 23:12:20 +08:00
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
2020-09-11 11:24:56 +08:00
echo "通用vmess(VLESS+TCP+TLS)链接: " > /etc/v2ray-agent/v2ray/usersv2ray.conf
2020-09-01 17:38:48 +08:00
echo " vmess:// ${ qrCodeBase64Default } " >> /etc/v2ray-agent/v2ray/usersv2ray.conf
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 通用json(VLESS+TCP+TLS)"
2020-08-29 23:12:20 +08:00
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"host":"' ${ host } '","type":"none","net":"tcp","add":"' ${ host } '","allowInsecure":0,"method":"none","peer":""}\n'
2020-09-08 14:21:30 +08:00
echoContent green ' V2Ray v4.27.4+ 目前无通用订阅, 需要手动配置, VLESS和tcp大部分一样, 其余内容不变\n'
2020-09-04 11:55:08 +08:00
elif [ [ " ${ type } " = "vmessws" ] ]
then
2020-09-12 22:08:23 +08:00
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"1","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"ws","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}' | sed 's#/#\\\/#g' | base64`
2020-09-04 11:55:08 +08:00
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 通用json(VMess+WS+TLS)"
2020-09-12 22:08:23 +08:00
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"1","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"ws","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}\n'
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 通用vmess(VMess+WS+TLS)链接"
2020-09-04 11:55:08 +08:00
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 二维码 vmess(VMess+WS+TLS)"
2020-09-08 14:21:30 +08:00
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess:// ${ qrCodeBase64Default } \n "
elif [ [ " ${ type } " = "vmesstcp" ] ]
then
2020-09-12 22:08:23 +08:00
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"1","v":"2","host":"' ${ host } '","type":"http","path":' ${ path } ',"net":"tcp","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '","obfs":"http","obfsParam":"' ${ host } '"}' | sed 's#/#\\\/#g' | base64`
2020-09-08 14:21:30 +08:00
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 通用json(VMess+TCP+TLS)"
2020-09-12 22:08:23 +08:00
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"1","v":"2","host":"' ${ host } '","type":"http","path":' ${ path } ',"net":"tcp","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '","obfs":"http","obfsParam":"' ${ host } '"}\n'
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 通用vmess(VMess+TCP+TLS)链接"
2020-09-08 14:21:30 +08:00
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
2020-09-11 11:24:56 +08:00
echoContent yellow " ---> 二维码 vmess(VMess+TCP+TLS)"
2020-09-08 14:21:30 +08:00
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess:// ${ qrCodeBase64Default } \n "
2020-09-11 11:24:56 +08:00
elif [ [ " ${ type } " = "vlessws" ] ]
then
qrCodeBase64Default = ` echo -n '{"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"ws","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}' | sed 's#/#\\\/#g' | base64`
qrCodeBase64Default = ` echo ${ qrCodeBase64Default } | sed 's/ //g' `
echoContent yellow " ---> 通用json(VLESS+WS+TLS)"
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"aid":"0","v":"2","host":"' ${ host } '","type":"none","path":' ${ path } ',"net":"ws","add":"' ${ add } '","allowInsecure":0,"method":"none","peer":"' ${ host } '"}\n'
2020-09-21 15:21:16 +08:00
elif [ [ " ${ type } " = "trojan" ] ]
then
2020-09-27 21:23:55 +08:00
# URLEncode
2020-09-21 15:21:16 +08:00
echoContent yellow " ---> Trojan(TLS)"
echoContent green " trojan:// ${ id } @ ${ host } :443?peer= ${ host } &sni= ${ host } \n "
2020-09-27 17:57:20 +08:00
echoContent yellow " ---> 二维码 Trojan(TLS)"
2020-09-28 11:28:04 +08:00
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f ${ id } %40 ${ host } %3a443%3fpeer%3d ${ host } %26sni%3d ${ host } %23 ${ host } _trojan\n "
2020-09-27 17:57:20 +08:00
elif [ [ " ${ type } " = "trojangows" ] ]
then
2020-09-27 21:23:55 +08:00
# URLEncode
2020-09-27 17:57:20 +08:00
echoContent yellow " ---> Trojan-Go(WS+TLS)"
2020-09-28 17:28:00 +08:00
echoContent green " trojan:// ${ id } @ ${ add } :443?allowInsecure=0&&peer= ${ host } &sni= ${ host } &plugin=obfs-local;obfs=websocket;obfs-host= ${ host } ;obfs-uri= ${ path } # ${ host } _trojan_ws\n "
2020-09-27 17:57:20 +08:00
echoContent yellow " ---> 二维码 Trojan-Go(WS+TLS)"
2020-09-28 11:28:04 +08:00
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f ${ id } %40 ${ add } %3a443%3fallowInsecure%3d0%26peer%3d ${ host } %26plugin%3dobfs-local%3bobfs%3dwebsocket%3bobfs-host%3d ${ host } %3bobfs-uri%3d ${ path } %23 ${ host } _trojan_ws\n "
2020-08-27 16:57:42 +08:00
fi
2020-08-18 15:45:55 +08:00
}
# quanMult base64Code
quanMultBase64Code( ) {
local ps = $1
local id = $2
local host = $3
local path = $4
2020-06-05 16:42:21 +08:00
qrCodeBase64Quanmult = ` echo -n '' ${ ps } ' = vmess, ' ${ add } ', 443, aes-128-cfb, ' ${ id } ', over-tls=true, tls-host=' ${ host } ', certificate=1, obfs=ws, obfs-path=' ${ path } ', obfs-header="Host: ' ${ host } '[Rr][Nn]User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D100"' | base64`
qrCodeBase64Quanmult = ` echo ${ qrCodeBase64Quanmult } | sed 's/ //g' `
2020-09-02 16:48:05 +08:00
echoContent red "Quantumult vmess--->"
2020-06-05 16:42:21 +08:00
echoContent green " vmess:// ${ qrCodeBase64Quanmult } \n "
2020-09-01 17:38:48 +08:00
echo '' >> /etc/v2ray-agent/v2ray/usersv2ray.conf
echo "Quantumult:" >> /etc/v2ray-agent/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Quanmult } " >> /etc/v2ray-agent/v2ray/usersv2ray.conf
2020-09-02 16:48:05 +08:00
echoContent red "Quantumult 明文--->"
2020-06-05 16:42:21 +08:00
echoContent green ' ' ${ ps } ' = vmess, ' ${ add } ', 443, aes-128-cfb, ' ${ id } ', over-tls=true, tls-host=' ${ host } ', certificate=1, obfs=ws, obfs-path=' ${ path } ', obfs-header="Host: ' ${ host } '[Rr][Nn]User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_2_6 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) Mobile/15D100"'
2020-05-23 23:21:43 +08:00
}
2020-09-25 16:08:25 +08:00
# 进度条工具 废弃
2020-05-23 23:21:43 +08:00
progressTool( ) {
#
i = 0
toolName = $1
sp = '/-\|'
n = ${# sp }
printf ' '
if [ [ " ${ toolName } " = "crontabs" ] ]
2019-11-06 10:58:06 +08:00
then
2020-05-23 23:21:43 +08:00
toolName = "crontab"
2019-11-06 10:58:06 +08:00
fi
2020-05-23 23:21:43 +08:00
while true; do
status =
if [ [ -z ` find /usr/bin/ -name ${ toolName } ` ] ] && [ [ -z ` find /usr/sbin/ -name ${ toolName } ` ] ]
then
2020-08-02 19:14:20 +08:00
printf '\b%s' " ${ sp : i ++%n : 1 } " > /dev/null
2020-05-23 23:21:43 +08:00
else
break;
fi
sleep 0.1
done
echoContent green " $1 已安装---> "
2019-11-06 10:58:06 +08:00
}
2020-08-02 19:14:20 +08:00
progressTools( ) {
color = $1
content = $2
installProgress = $3
# echo ${color},${content},${installProgress}
echoContent ${ color } " ${ content } "
killSleep > /dev/null 2>& 1
if [ [ ! -z " ${ installProgress } " ] ]
then
installProgressFunction ${ installProgress } ${ totalProgress } &
fi
2020-07-31 17:52:47 +08:00
2020-08-02 19:14:20 +08:00
sleep 0.5
}
2020-07-31 17:52:47 +08:00
installProgressFunction( ) {
installProgress = $1
totalProgress = $2
currentProgress = 0
i = 0
sp = '/-\|'
n = ${# sp }
2020-08-02 19:14:20 +08:00
progressNum = ` awk 'BEGIN{printf "%.0f\n",(' ${ installProgress } '/' ${ totalProgress } ')*100}' `
printf '\b%s' " [ ${ progressNum } %] "
2020-07-31 17:52:47 +08:00
while true; do
if [ [ ${ installProgress } -gt ${ currentProgress } ] ] && [ [ ${ installProgress } -lt ${ totalProgress } ] ]
then
printf '\b%s' " ${ sp : i ++%n : 1 } "
else
break
fi
sleep 0.1
done
}
2020-09-25 16:08:25 +08:00
2020-09-04 15:25:07 +08:00
# 账号
2020-09-04 11:55:08 +08:00
showAccounts( ) {
2020-09-21 15:21:16 +08:00
showStatus =
local host =
2020-09-04 15:25:07 +08:00
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 账号 "
2020-09-04 11:55:08 +08:00
if [ [ -d "/etc/v2ray-agent/" ] ] && [ [ -d "/etc/v2ray-agent/v2ray/" ] ] && [ [ -f "/etc/v2ray-agent/v2ray/config.json" ] ]
then
2020-09-21 15:21:16 +08:00
showStatus = true
2020-09-08 14:21:30 +08:00
# VLESS tcp
2020-09-04 11:55:08 +08:00
local tcp = ` cat /etc/v2ray-agent/v2ray/config.json| jq .inbounds[ 0] `
local tcpID = ` echo ${ tcp } | jq .settings.clients[ 0] .id`
2020-09-08 14:21:30 +08:00
local tcpEmail = " `echo ${ tcp } |jq .settings.clients[0].email|awk -F '[ " ] ' ' { print $2 } ' ` "
2020-09-27 17:57:20 +08:00
host = ` echo ${ tcp } | jq .streamSettings.xtlsSettings.certificates[ 0] .certificateFile| awk -F '[t][l][s][/]' '{print $2}' | awk -F '["]' '{print $1}' | awk -F '[.][c][r][t]' '{print $1}' `
2020-09-12 22:08:23 +08:00
# VLESS ws
local vlessWS = ` cat /etc/v2ray-agent/v2ray/config.json| jq .inbounds[ 3] `
local vlessWSID = ` echo ${ vlessWS } | jq .settings.clients[ 0] .id`
local vlessWSAdd = ` echo ${ vlessWS } | jq .settings.clients[ 0] .add| awk -F '["]' '{print $2}' `
local vlessWSEmail = " `echo ${ vlessWS } |jq .settings.clients[0].email|awk -F '[ " ] ' ' { print $2 } ' ` "
local vlessWSPath = ` echo ${ vlessWS } | jq .streamSettings.wsSettings.path`
2020-09-08 14:21:30 +08:00
# Vmess ws
2020-09-04 11:55:08 +08:00
local ws = ` cat /etc/v2ray-agent/v2ray/config.json| jq .inbounds[ 1] `
local wsID = ` echo ${ ws } | jq .settings.clients[ 0] .id`
local wsAdd = ` echo ${ ws } | jq .settings.clients[ 0] .add| awk -F '["]' '{print $2}' `
2020-09-08 14:21:30 +08:00
local wsEmail = " `echo ${ ws } |jq .settings.clients[0].email|awk -F '[ " ] ' ' { print $2 } ' ` "
2020-09-04 11:55:08 +08:00
local wsPath = ` echo ${ ws } | jq .streamSettings.wsSettings.path`
2020-09-08 14:21:30 +08:00
# Vmess tcp
local vmessTCP = ` cat /etc/v2ray-agent/v2ray/config.json| jq .inbounds[ 2] `
local vmessTCPID = ` echo ${ vmessTCP } | jq .settings.clients[ 0] .id`
local vmessTCPAdd = ` echo ${ vmessTCP } | jq .settings.clients[ 0] .add| awk -F '["]' '{print $2}' `
local vmessTCPEmail = " `echo ${ vmessTCP } |jq .settings.clients[0].email|awk -F '[ " ] ' ' { print $2 } ' ` "
local vmessTCPath = ` echo ${ vmessTCP } | jq .streamSettings.tcpSettings.header.request.path[ 0] `
2020-09-11 11:24:56 +08:00
2020-09-27 17:57:20 +08:00
echoContent skyBlue "\n=============================== VLESS TCP TLS ==============================="
2020-09-04 11:55:08 +08:00
defaultBase64Code vlesstcp ${ tcpEmail } " ${ tcpID } " " ${ host } " ${ add }
2020-09-12 22:08:23 +08:00
2020-09-27 17:57:20 +08:00
echoContent skyBlue "\n===============================VLESS WS TLS CDN==============================="
2020-09-11 11:24:56 +08:00
defaultBase64Code vlessws ${ vlessWSEmail } " ${ vlessWSID } " " ${ host } " " ${ vlessWSPath } " ${ vlessWSAdd }
2020-09-12 22:08:23 +08:00
2020-09-27 17:57:20 +08:00
echoContent skyBlue "\n===============================VMess WS TLS CDN==============================="
2020-09-12 22:08:23 +08:00
defaultBase64Code vmessws ${ wsEmail } " ${ wsID } " " ${ host } " " ${ wsPath } " ${ wsAdd }
2020-09-27 17:57:20 +08:00
echoContent skyBlue "\n=============================== VMess TCP TLS ==============================="
2020-09-08 14:21:30 +08:00
defaultBase64Code vmesstcp ${ vmessTCPEmail } " ${ vmessTCPID } " " ${ host } " " ${ vmessTCPath } " " ${ host } "
2020-09-21 15:21:16 +08:00
fi
if [ [ -d "/etc/v2ray-agent/" ] ] && [ [ -d "/etc/v2ray-agent/trojan/" ] ] && [ [ -f "/etc/v2ray-agent/trojan/config.json" ] ]
then
showStatus = true
local trojanUUID = ` cat /etc/v2ray-agent/trojan/config.json | jq .password[ 0] | awk -F '["]' '{print $2}' `
2020-09-28 11:28:04 +08:00
local trojanGoPath = ` cat /etc/v2ray-agent/trojan/config.json| jq .websocket.path| awk -F '["]' '{print $2}' `
local trojanGoAdd = ` cat /etc/v2ray-agent/trojan/config.json| jq .websocket.add| awk -F '["]' '{print $2}' `
2020-09-21 15:21:16 +08:00
echoContent skyBlue "\n=============================== Trojan TLS ==============================="
defaultBase64Code trojan trojan ${ trojanUUID } ${ host }
2020-09-27 17:57:20 +08:00
echoContent skyBlue "\n=============================== Trojan WS TLS ==============================="
2020-09-28 11:28:04 +08:00
if [ [ -z ${ trojanGoAdd } ] ]
then
trojanGoAdd = ${ host }
fi
defaultBase64Code trojangows trojan ${ trojanUUID } ${ host } ${ trojanGoPath } ${ trojanGoAdd }
2020-09-21 15:21:16 +08:00
fi
if [ [ -z ${ showStatus } ] ]
then
2020-09-04 11:55:08 +08:00
echoContent red " ---> 未安装"
fi
}
2020-07-31 17:52:47 +08:00
2020-09-02 16:48:05 +08:00
# 卸载脚本
unInstall( ) {
2020-09-24 15:03:28 +08:00
read -p "是否确认卸载安装内容?[y/n]:" unInstallStatus
if [ [ " ${ unInstallStatus } " != "y" ] ]
then
echoContent green " ---> 放弃卸载"
menu
exit;
fi
2020-09-02 16:48:05 +08:00
handleNginx stop
if [ [ -z ` ps -ef| grep -v grep| grep nginx` ] ]
then
2020-09-14 14:32:30 +08:00
echoContent green " ---> 停止Nginx成功"
2020-09-02 16:48:05 +08:00
fi
handleV2Ray stop
rm -rf /etc/systemd/system/v2ray.service
2020-09-14 14:32:30 +08:00
echoContent green " ---> 删除V2Ray开机自启完成"
2020-09-21 15:21:16 +08:00
rm -rf /etc/systemd/system/trojan-go.service
echoContent green " ---> 删除Trojan-Go开机自启完成"
2020-09-02 16:48:05 +08:00
if [ [ -d "/etc/v2ray-agent/tls" ] ] && [ [ ! -z ` find /etc/v2ray-agent/tls/ -name "*.key" ` ] ] && [ [ ! -z ` find /etc/v2ray-agent/tls/ -name "*.crt" ` ] ]
then
mv /etc/v2ray-agent/tls /tmp
if [ [ ! -z ` find /tmp/tls -name '*.key' ` ] ]
then
2020-09-14 14:32:30 +08:00
echoContent yellow " ---> 备份证书成功,请注意留存。[/tmp/tls]"
2020-09-02 16:48:05 +08:00
fi
fi
rm -rf /etc/v2ray-agent
2020-09-14 14:32:30 +08:00
rm -rf /etc/nginx/conf.d/alone.conf
echoContent green " ---> 卸载V2Ray完成"
echoContent green " ---> 卸载完成"
2020-07-21 14:03:18 +08:00
}
2020-09-07 17:42:10 +08:00
# 检查错误
checkFail( ) {
echoContent skyBlue " \n进度 $1 / ${ totalProgress } : 检查错误 "
if [ [ -d "/etc/v2ray-agent" ] ]
then
if [ [ -d "/etc/v2ray-agent/v2ray/" ] ]
then
if [ [ -z ` ls -F /etc/v2ray-agent/v2ray/| grep "v2ray" ` ] ] || [ [ -z ` ls -F /etc/v2ray-agent/v2ray/| grep "v2ctl" ` ] ]
then
echoContent red " ---> V2Ray 未安装"
else
echoContent green " ---> v2ray-core版本:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2 }'|head -1` "
if [ [ -z ` /etc/v2ray-agent/v2ray/v2ray --test /etc/v2ray-agent/v2ray/config.json| tail -n +3| grep "Configuration OK" ` ] ]
then
echoContent red " ---> V2Ray 配置文件异常"
/etc/v2ray-agent/v2ray/v2ray --test /etc/v2ray-agent/v2ray/config.json
elif [ [ -z ` ps -ef| grep -v grep| grep v2ray` ] ]
then
echoContent red " ---> V2Ray 未启动"
else
echoContent green " ---> V2Ray 正常运行"
fi
fi
else
echoContent red " ---> V2Ray 未安装"
fi
if [ [ -z ` ps -ef| grep -v grep| grep nginx` ] ]
then
echoContent red " ---> Nginx 未启动,伪装博客无法使用"
else
echoContent green " ---> Nginx 正常运行"
fi
else
echoContent red " ---> 未使用脚本安装"
fi
}
2020-09-25 16:08:25 +08:00
# 主菜单
2020-08-18 15:45:55 +08:00
menu( ) {
2020-06-23 10:22:15 +08:00
cd
2020-09-02 16:48:05 +08:00
echoContent red "\n=============================================================="
echoContent green "作者: mack-a"
2020-09-28 11:31:42 +08:00
echoContent green "当前版本: v2.0.10"
2020-09-28 11:37:06 +08:00
echoContent green "Github: https://github.com/mack-a/v2ray-agent"
echoContent green "描述:七合一共存脚本"
2020-09-02 16:48:05 +08:00
echoContent red "=============================================================="
2020-09-28 11:37:06 +08:00
echoContent yellow "1.安装"
2020-09-28 11:28:04 +08:00
echoContent skyBlue "-------------------------工具管理-----------------------------"
echoContent yellow "2.查看账号"
echoContent yellow "3.自动排错"
echoContent yellow "4.更新证书"
2020-09-28 16:43:14 +08:00
echoContent yellow "更换CDN节点[todo]"
2020-09-28 11:28:04 +08:00
echoContent skyBlue "-------------------------版本管理-----------------------------"
2020-09-14 13:43:07 +08:00
echoContent yellow "5.升级V2Ray"
2020-09-24 15:03:28 +08:00
echoContent yellow "6.升级Trojan-Go"
2020-09-21 15:21:16 +08:00
echoContent yellow "7.升级脚本"
echoContent yellow "8.安装BBR"
2020-09-28 11:28:04 +08:00
echoContent skyBlue "-------------------------脚本管理-----------------------------"
echoContent yellow "9.查看日志[todo]"
echoContent yellow "10.卸载脚本"
echoContent yellow "11.重置uuid[todo]"
echoContent yellow "12.任意组合安装[todo]"
2020-09-02 16:48:05 +08:00
echoContent red "=============================================================="
2020-09-07 17:42:10 +08:00
automaticUpgrade
2020-09-02 16:48:05 +08:00
read -p "请选择:" selectInstallType
2020-08-28 09:45:06 +08:00
case ${ selectInstallType } in
1)
2020-08-29 23:12:20 +08:00
installV2RayVLESSTCPWSTLS
2020-08-28 09:45:06 +08:00
; ;
2020-09-28 11:28:04 +08:00
2)
2020-09-14 13:43:07 +08:00
showAccounts 1
2020-09-28 11:28:04 +08:00
; ;
3)
checkFail 1
; ;
4)
renewalTLS 1
2020-09-03 15:32:27 +08:00
; ;
2020-09-07 17:42:10 +08:00
5)
2020-09-14 13:43:07 +08:00
updateV2Ray 1
2020-09-07 17:42:10 +08:00
; ;
2020-09-24 15:03:28 +08:00
6)
updateTrojanGo 1
; ;
2020-09-28 11:28:04 +08:00
7)
updateV2RayAgent 1
; ;
2020-09-21 15:21:16 +08:00
8)
2020-09-04 11:55:08 +08:00
bbrInstall
2020-09-03 17:58:25 +08:00
; ;
2020-09-21 15:21:16 +08:00
10)
2020-09-14 14:32:30 +08:00
unInstall 1
2020-09-02 16:48:05 +08:00
; ;
2020-08-28 09:45:06 +08:00
esac
2020-08-18 13:44:19 +08:00
exit 0;
}
2020-09-02 16:48:05 +08:00
# 安装BBR
bbrInstall( ) {
echoContent red "\n=============================================================="
2020-09-24 15:15:42 +08:00
echoContent green "BBR脚本用的[ylx2016]的成熟作品,地址[https://github.com/ylx2016/Linux-NetSpeed],请熟知"
echoContent red " 1.安装【推荐原版BBR+FQ】"
echoContent red " 2.回退主目录"
2020-09-02 16:48:05 +08:00
echoContent red "=============================================================="
read -p "请选择:" installBBRStatus
if [ [ " ${ installBBRStatus } " = "1" ] ]
then
wget -N --no-check-certificate "https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
else
menu
fi
}
2020-08-29 23:12:20 +08:00
installV2RayVLESSTCPWSTLS( ) {
2020-09-21 15:21:16 +08:00
totalProgress = 17
2020-08-29 23:12:20 +08:00
globalType = vlesstcpws
2020-09-02 16:48:05 +08:00
mkdirTools 1
installTools 2
2020-08-29 23:12:20 +08:00
# 申请tls
2020-09-02 16:48:05 +08:00
initTLSNginxConfig 3
installTLS 4
2020-08-29 23:12:20 +08:00
handleNginx stop
2020-09-02 16:48:05 +08:00
initNginxConfig vlesstcpws 5
randomPathFunction 6
2020-08-29 23:12:20 +08:00
# 安装V2Ray
2020-09-11 23:26:55 +08:00
installV2Ray 7
installV2RayService 8
2020-09-21 15:21:16 +08:00
installTrojanGo 9
installTrojanService 10
customCDNIP 11
initTrojanGoConfig 12
initV2RayConfig vlesstcpws 13
installCronTLS 14
nginxBlog 15
2020-09-04 15:25:07 +08:00
handleV2Ray stop
2020-08-29 23:12:20 +08:00
handleV2Ray start
handleNginx start
2020-09-21 15:21:16 +08:00
handleTrojanGo stop
handleTrojanGo start
2020-08-29 23:12:20 +08:00
# 生成账号
2020-09-21 15:21:16 +08:00
checkGFWStatue 16
showAccounts 17
2020-05-23 23:21:43 +08:00
}
2020-07-29 17:24:10 +08:00
# 杀死sleep
killSleep( ) {
if [ [ ! -z ` ps -ef| grep -v grep| grep sleep` ] ]
then
ps -ef| grep -v grep| grep sleep| awk '{print $3}' | xargs kill -9 > /dev/null 2>& 1
killSleep > /dev/null 2>& 1
fi
}
2020-08-18 13:44:19 +08:00
# 检查系统
2020-05-23 23:21:43 +08:00
checkSystem( ) {
2020-05-24 16:28:37 +08:00
if [ [ ! -z ` find /etc -name "redhat-release" ` ] ] || [ [ ! -z ` cat /proc/version | grep -i "centos" | grep -v grep ` ] ] || [ [ ! -z ` cat /proc/version | grep -i "red hat" | grep -v grep ` ] ] || [ [ ! -z ` cat /proc/version | grep -i "redhat" | grep -v grep ` ] ]
then
2020-09-25 17:42:16 +08:00
centosVersion = ` rpm -q centos-release| awk -F "[-]" '{print $3}' | awk -F "[.]" '{print $1}' `
2020-05-23 23:21:43 +08:00
release = "centos"
2020-05-24 16:28:37 +08:00
installType = 'yum -y install'
2020-05-23 23:21:43 +08:00
removeType = 'yum -y remove'
2020-07-17 20:33:49 +08:00
upgrade = "yum update -y --skip-broken"
2020-05-24 16:28:37 +08:00
elif [ [ ! -z ` cat /etc/issue | grep -i "debian" | grep -v grep` ] ] || [ [ ! -z ` cat /proc/version | grep -i "debian" | grep -v grep` ] ]
then
2020-05-23 23:21:43 +08:00
release = "debian"
2020-05-24 16:28:37 +08:00
installType = 'apt -y install'
upgrade = "apt update -y"
2020-05-23 23:21:43 +08:00
removeType = 'apt -y autoremove'
2020-05-24 16:28:37 +08:00
elif [ [ ! -z ` cat /etc/issue | grep -i "ubuntu" | grep -v grep` ] ] || [ [ ! -z ` cat /proc/version | grep -i "ubuntu" | grep -v grep` ] ]
then
2020-05-23 23:21:43 +08:00
release = "ubuntu"
2020-05-24 16:28:37 +08:00
installType = 'apt -y install'
upgrade = "apt update -y"
removeType = 'apt --purge remove'
fi
if [ [ -z ${ release } ] ]
then
echoContent red "本脚本不支持此系统,请将下方日志反馈给开发者"
cat /etc/issue
cat /proc/version
2020-07-29 17:24:10 +08:00
killSleep > /dev/null 2>& 1
2020-05-24 16:28:37 +08:00
exit 0;
2019-11-06 10:58:06 +08:00
fi
}
2020-08-18 15:45:55 +08:00
2020-05-24 16:28:37 +08:00
checkSystem
2020-08-18 15:45:55 +08:00
menu