2019-11-06 10:58:06 +08:00
#!/usr/bin/env bash
2020-05-23 23:21:43 +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-07-31 17:52:47 +08:00
installProgress = 0
2020-08-02 19:14:20 +08:00
totalProgress = 20
2020-06-11 15:39:59 +08:00
iplc = $1
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( ) {
2020-08-02 19:14:20 +08:00
printN = '\n'
if [ [ ! -z " $3 " ] ]
then
printN = ''
fi
2020-05-23 23:21:43 +08:00
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-08-02 19:14:20 +08:00
${ echoType } " \033[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( ) {
mkdir -p /etc/v2ray/
mkdir -p /etc/systemd/system/
mkdir -p /etc/nginx/v2ray-agent-https/
mkdir -p /usr/bin/v2ray/
mkdir -p /tmp/v2ray/
mkdir -p /tmp/tls/
}
2020-05-23 23:21:43 +08:00
# 安装工具包
installTools( ) {
# echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
# source /etc/profile
2020-07-01 20:48:57 +08:00
# kill lock
2020-07-29 17:24:10 +08:00
if [ [ " ${ release } " = "centos" ] ]
then
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查安装jq、nginx epel源、yum-utils--->" 0
2020-07-29 17:24:10 +08:00
# jq epel源
rpm -ivh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm > /dev/null 2>& 1
2020-08-03 17:23:14 +08:00
nginxEpel = ""
if [ [ ! -z ` rpm -qa| grep -v grep| grep nginx` ] ]
then
rpm -qa| grep -v grep| grep nginx| xargs rpm -e > /dev/null 2>& 1
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-08-03 17:23:14 +08:00
rpm -ivh ${ nginxEpel } > /dev/null 2>& 1
2020-08-02 19:14:20 +08:00
# yum-utils
yum install yum-utils -y > /dev/null 2>& 1
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-08-02 19:14:20 +08:00
progressTools "yellow" "卸载Nginx--->" 1
# echoContent yellow "删除Nginx、V2Ray, 请等待--->"
2020-05-23 23:21:43 +08:00
if [ [ ! -z ` find /usr/sbin/ -name nginx` ] ]
then
if [ [ ! -z ` ps -ef| grep nginx| grep -v grep` ] ]
then
2020-06-05 11:44:02 +08:00
ps -ef| grep nginx| grep -v grep| awk '{print $2}' | xargs kill -9
2020-05-23 23:21:43 +08:00
fi
2020-05-24 16:28:37 +08:00
if [ [ " ${ release } " = "ubuntu" ] ] || [ [ " ${ release } " = "debian" ] ]
then
dpkg --get-selections | grep nginx| awk '{print $1}' | xargs sudo apt --purge remove -y > /dev/null
else
removeLog = ` ${ removeType } nginx`
fi
rm -rf /etc/nginx/nginx.conf
2020-05-24 21:10:55 +08:00
rm -rf /usr/share/nginx/html.zip
2020-05-23 23:21:43 +08:00
fi
2020-08-02 19:14:20 +08:00
progressTools "yellow" "卸载V2Ray--->" 2
2020-05-23 23:21:43 +08:00
if [ [ ! -z ` find /usr/bin/ -name "v2ray*" ` ] ]
2019-11-06 10:58:06 +08:00
then
2020-05-23 23:21:43 +08:00
if [ [ ! -z ` ps -ef| grep v2ray| grep -v grep` ] ]
then
ps -ef| grep v2ray| grep -v grep| awk '{print $2}' | xargs kill -9
fi
rm -rf /usr/bin/v2ray
fi
2020-08-02 19:14:20 +08:00
progressTools "yellow" "卸载V2Ray开机自启--->" 3
2020-05-23 23:21:43 +08:00
rm -rf /etc/systemd/system/v2ray.service
2020-07-21 15:33:18 +08:00
if [ [ ! -z ` find /bin /usr/bin -name "systemctl" ` ] ]
2020-07-21 14:03:18 +08:00
then
systemctl daemon-reload
else
2020-08-03 17:23:14 +08:00
echo
2020-07-21 14:03:18 +08:00
fi
2020-05-23 23:21:43 +08:00
2020-08-18 17:45:11 +08:00
# progressTools "yellow" "卸载acme.sh--->" 4
# rm -rf ~/.acme.sh > /dev/null
# if [[ ! -z `cat /root/.bashrc|grep -n acme` ]]
# then
# acmeBashrcLine=`cat /root/.bashrc|grep -n acme|awk -F "[:]" '{print $1}'|head -1`
# sed -i "${acmeBashrcLine}d" /root/.bashrc
# fi
2020-05-23 23:21:43 +08:00
2020-08-03 17:23:14 +08:00
progressTools "yellow" "检查、安装更新【新机器会很慢,耐心等待】--->" 5
2020-07-24 17:51:32 +08:00
# if [[ "${release}" = "centos" ]]
# then
# yum-complete-transaction --cleanup-only
# fi
2020-05-23 23:21:43 +08:00
${ upgrade } > /dev/null
2020-08-02 19:14:20 +08:00
# yum要删除pid
2020-05-23 23:21:43 +08:00
rm -rf /var/run/yum.pid
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查、安装wget--->" 6
2020-05-23 23:21:43 +08:00
${ installType } wget > /dev/null
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查、安装unzip--->" 7
2020-05-23 23:21:43 +08:00
${ installType } unzip > /dev/null
# echoContent yellow "检查、安装qrencode--->"
2020-08-02 19:14:20 +08:00
# # progressTool qrencode &
2020-05-23 23:21:43 +08:00
# ${installType} qrencode > /dev/null
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查、安装socat--->" 8
2020-05-23 23:21:43 +08:00
${ installType } socat > /dev/null
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查、安装tar--->" 9
2020-08-02 15:36:48 +08:00
${ installType } tar > /dev/null
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查、安装crontabs--->" 10
2020-07-01 20:48:57 +08:00
if [ [ " ${ release } " = "ubuntu" ] ] || [ [ " ${ release } " = "debian" ] ]
2020-05-24 16:28:37 +08:00
then
${ installType } cron > /dev/null
else
${ installType } crontabs > /dev/null
fi
2020-05-23 23:21:43 +08:00
2020-08-02 19:14:20 +08:00
progressTools "yellow" "检查、安装jq--->" 11
2020-05-23 23:21:43 +08:00
${ installType } jq > /dev/null
2020-07-31 17:52:47 +08:00
2020-05-23 23:21:43 +08:00
# echoContent skyBlue "检查、安装bind-utils--->"
2020-08-02 19:14:20 +08:00
# # progressTool bind-utils
2020-05-23 23:21:43 +08:00
# 关闭防火墙
2020-08-02 19:14:20 +08:00
# 安装nginx
progressTools "yellow" "检查、安装Nginx--->" 12
# progressTool nginx &
${ installType } nginx > /dev/null
if [ [ ! -z ` ps -ef| grep -v grep| grep nginx` ] ]
then
nginx -s stop
fi
2020-08-06 16:33:33 +08:00
progressTools "yellow" "检查、安装binutils--->" 13
# progressTool nginx &
${ installType } binutils > /dev/null
2020-08-03 21:02:56 +08:00
# 新建所需目录
mkdirTools
2020-08-06 16:33:33 +08:00
progressTools "yellow" "检查、安装acme--->" 14
2020-08-04 16:20:52 +08:00
mkdir -p /etc/tls/
curl -s https://get.acme.sh | sh > /etc/tls/acme.log
2020-08-02 19:14:20 +08:00
if [ [ -z ` find ~/.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
2020-05-23 23:21:43 +08:00
}
2020-08-18 15:45:55 +08:00
# 初始化Nginx申请证书配置
initTLSNginxConfig( ) {
2020-08-02 19:14:20 +08:00
killSleep > /dev/null 2>& 1
killSleep > /dev/null 2>& 1
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-08-06 16:33:33 +08:00
progressTools "yellow" "配置Nginx--->" 15
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
nginx
# 测试nginx
2020-08-06 16:33:33 +08:00
progressTools "yellow" "检查Nginx是否正常访问--->" 16
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-06-05 11:44:02 +08:00
ps -ef| grep nginx| grep -v grep| awk '{print $2}' | xargs kill -9
2020-08-02 19:14:20 +08:00
progressTools "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-08-03 17:23:14 +08:00
mkdir -p /etc/nginx/v2ray-agent-https/
2020-08-04 16:20:52 +08:00
mkdir -p /etc/v2ray-agent/tls/
2020-07-01 20:48:57 +08:00
touch /etc/nginx/v2ray-agent-https/config
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-08-06 16:33:33 +08:00
progressTools "yellow" "检查、安装TLS证书--->" 17
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
~/.acme.sh/acme.sh --installcert -d ${ domain } --fullchainpath /etc/nginx/v2ray-agent-https/${ domain } .crt --keypath /etc/nginx/v2ray-agent-https/${ domain } .key --ecc >/dev/null
if [ [ -z ` cat /etc/nginx/v2ray-agent-https/${ 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-08-18 15:45:55 +08:00
elif [ [ -z ` cat /etc/nginx/v2ray-agent-https/${ 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-08-03 17:23:14 +08:00
progressTools "green" " TLS生成成功--->>"
2020-07-31 17:52:47 +08:00
2020-08-18 15:45:55 +08:00
echo ${ domain } ` date +%s` > /etc/nginx/v2ray-agent-https/config
2020-07-13 17:46:39 +08:00
2020-08-04 16:20:52 +08:00
cp -R /etc/nginx/v2ray-agent-https/config /etc/v2ray-agent/tls/config
2020-08-18 15:45:55 +08:00
cp -R /etc/nginx/v2ray-agent-https/${ domain } .crt /etc/v2ray-agent/tls/${ domain } .crt
2020-08-18 16:22:06 +08:00
cp -R /etc/nginx/v2ray-agent-https/${ domain } .key /etc/v2ray-agent/tls/${ domain } .key
2020-08-04 16:20:52 +08:00
progressTools "yellow" " TLS证书备份成功, 证书位置: /etc/v2ray-agent/tls--->"
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-08-04 16:20:52 +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-08-02 19:14:20 +08:00
progressTools "yellow" "检测到备份证书,使用--->"
2020-08-18 15:45:55 +08:00
cp -R /etc/v2ray-agent/tls/${ domain } .crt /etc/nginx/v2ray-agent-https/${ domain } .crt
cp -R /etc/v2ray-agent/tls/${ domain } .key /etc/nginx/v2ray-agent-https/${ domain } .key
2020-08-04 16:20:52 +08:00
cp -R /etc/v2ray-agent/tls/config /etc/nginx/v2ray-agent-https/config
2020-05-23 23:21:43 +08:00
fi
2020-08-10 17:17:14 +08:00
}
2020-08-18 15:45:55 +08:00
# 安装Nginx科学上网配置
2020-08-18 13:44:19 +08:00
initNginxConfig( ) {
installType = $1
2020-08-27 16:57:42 +08:00
if [ [ " ${ installType } " = "wss" ] ]
2020-08-18 13:44:19 +08:00
then
2020-08-18 16:22:06 +08:00
cat << EOF > /etc/nginx/conf.d/alone.conf
2020-08-18 13:44:19 +08:00
server {
listen 443 ssl;
2020-08-18 15:45:55 +08:00
server_name ${ domain } ;
2020-08-18 13:44:19 +08:00
root /usr/share/nginx/html;
2020-08-18 15:45:55 +08:00
ssl_certificate /etc/nginx/v2ray-agent-https/${ domain } .crt; ssl_certificate_key /etc/nginx/v2ray-agent-https/${ domain } .key;
2020-08-18 13:44:19 +08:00
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_prefer_server_ciphers on;
location / { }
location /alone {
proxy_redirect off;
proxy_pass http://127.0.0.1:31299;
proxy_http_version 1.1;
proxy_set_header Upgrade \$ http_upgrade;
proxy_set_header Connection "upgrade" ;
proxy_set_header X-Real-IP \$ remote_addr;
proxy_set_header Host \$ host;
proxy_set_header X-Forwarded-For \$ proxy_add_x_forwarded_for;
}
location /vlesspath {
proxy_redirect off;
proxy_pass http://127.0.0.1:31298;
proxy_http_version 1.1;
proxy_set_header Upgrade \$ http_upgrade;
proxy_set_header Connection "upgrade" ;
proxy_set_header X-Real-IP \$ remote_addr;
proxy_set_header Host \$ host;
proxy_set_header X-Forwarded-For \$ proxy_add_x_forwarded_for;
}
}
2020-08-10 17:17:14 +08:00
EOF
2020-08-18 16:22:06 +08:00
2020-08-29 23:12:20 +08:00
elif [ [ " ${ 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-08-11 11:32:26 +08:00
progressTools "yellow" "请输入自定义路径Vmess[例: alone],不需要斜杠,[回车]随机路径, VLESS则为随机路径"
2020-06-11 15:39:59 +08:00
read customPath
if [ [ ! -z " ${ customPath } " ] ]
then
sed -i " s/alone/ ${ customPath } /g " ` grep alone -rl /etc/nginx/conf.d/alone.conf`
2020-08-11 11:32:26 +08:00
sed -i " s/vlesspath/ ${ customPath } vld/g " ` grep vlesspath -rl /etc/nginx/conf.d/alone.conf`
2020-08-05 17:53:55 +08:00
else
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`
if [ [ ! -z " ${ customPath } " ] ]
2020-08-05 17:53:55 +08:00
then
2020-08-06 16:33:33 +08:00
sed -i " s/alone/ ${ customPath } /g " ` grep alone -rl /etc/nginx/conf.d/alone.conf`
2020-08-11 11:32:26 +08:00
sed -i " s/vlesspath/ ${ customPath } vld/g " ` grep vlesspath -rl /etc/nginx/conf.d/alone.conf`
2020-08-05 17:53:55 +08:00
fi
2020-06-11 15:39:59 +08:00
fi
2020-08-06 16:33:33 +08:00
echoContent yellow " path: ${ customPath } "
2020-08-11 11:32:26 +08:00
echoContent yellow " vlessPath: ${ customPath } vld "
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-05-24 21:05:38 +08:00
rm -rf /usr/share/nginx/html
2020-05-24 22:04:37 +08:00
wget -q -P /usr/share/nginx https://raw.githubusercontent.com/mack-a/v2ray-agent/master/blog/unable/html.zip >> /dev/null
unzip /usr/share/nginx/html.zip -d /usr/share/nginx/html > /dev/null
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
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
nginx -s stop
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-08-06 16:33:33 +08:00
progressTools "yellow" "检查、添加定时维护证书--->" 19
2020-07-03 18:01:32 +08:00
touch /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
2020-07-07 18:05:18 +08:00
touch /etc/nginx/v2ray-agent-https/backup_crontab.cron
2020-08-04 16:20:52 +08:00
touch /etc/v2ray-agent/tls/tls.log
2020-07-13 17:46:39 +08:00
if [ [ -z ` crontab -l| grep -v grep| grep 'reloadInstallTLS' ` ] ]
then
crontab -l >> /etc/nginx/v2ray-agent-https/backup_crontab.cron
# 定时任务
echo "30 1 * * * /bin/bash /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh" >> /etc/nginx/v2ray-agent-https/backup_crontab.cron
crontab /etc/nginx/v2ray-agent-https/backup_crontab.cron
fi
2020-07-07 18:05:18 +08:00
# 备份
2020-07-13 17:46:39 +08:00
2020-08-04 16:56:55 +08:00
cat << EOF > /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh
2020-08-18 15:45:55 +08:00
domain = ${ domain }
2020-08-04 16:56:55 +08:00
eccPath = \` find ~/.acme.sh -name "\${domain}_ecc" | head -1\`
mkdir -p /etc/v2ray-agent/tls
touch /etc/v2ray-agent/tls/tls.log
touch /etc/v2ray-agent/tls/acme.log
if [ [ ! -z \$ { eccPath} ] ]
then
modifyTime = \` stat \$ { eccPath} /\$ { domain} .key| sed -n '6,6p' | awk '{print \$2" "\$3" "\$4" "\$5}' \`
modifyTime = \` date +%s -d "\${modifyTime}" \`
currentTime = \` date +%s\`
stampDiff = \` expr \$ { currentTime} - \$ { modifyTime} \`
minutes = \` expr \$ { stampDiff} / 60\`
status = "正常"
reloadTime = "暂无"
if [ [ ! -z \$ { modifyTime} ] ] && [ [ ! -z \$ { currentTime} ] ] && [ [ ! -z \$ { stampDiff} ] ] && [ [ ! -z \$ { minutes} ] ] && [ [ \$ { minutes} -lt '120' ] ]
then
nginx -s stop
~/.acme.sh/acme.sh --installcert -d \$ { domain} --fullchainpath /etc/nginx/v2ray-agent-https/\$ { domain} .crt --keypath /etc/nginx/v2ray-agent-https/\$ { domain} .key --ecc >> /tmp/tls/acme.log
nginx
reloadTime = \` date -d @\$ { currentTime} +"%F %H:%M:%S" \`
fi
echo "域名:\${domain}, modifyTime:" \` date -d @\$ { modifyTime} +"%F %H:%M:%S" \` ,"检查时间:" \` date -d @\$ { currentTime} +"%F %H:%M:%S" \` ,上次生成证书的时:\` expr \$ { minutes} / 1440\` "天前" ,"证书状态:" \$ { status} ,"重新生成日期:" \$ { reloadTime} >> /etc/v2ray-agent/tls/tls.log
else
echo '无法找到证书路径' >> /etc/v2ray-agent/tls/tls.log
fi
EOF
2020-07-09 17:56:05 +08:00
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-08-02 19:14:20 +08:00
progressTools "green" " 添加定时维护证书成功"
2020-07-07 18:05:18 +08:00
else
2020-07-13 17:46:39 +08:00
crontab -l >> /etc/nginx/v2ray-agent-https/backup_crontab.cron
# 定时任务
crontab /etc/nginx/v2ray-agent-https/backup_crontab.cron
2020-08-02 19:14:20 +08:00
progressTools "green" " 检测到已添加定时任务"
2020-07-07 18:05:18 +08:00
fi
2020-07-03 18:01:32 +08:00
}
2020-08-18 13:44:19 +08:00
# 安装V2Ray
2019-11-06 10:58:06 +08:00
installV2Ray( ) {
2020-08-02 19:14:20 +08:00
# ls -F /usr/bin/v2ray/|grep "v2ray"
mkdir -p /usr/bin/v2ray/
2020-08-04 16:20:52 +08:00
mkdir -p /etc/v2ray-agent/v2ray/
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-08-03 17:23:14 +08:00
if [ [ -z ` ls -F /usr/bin/v2ray/| grep "v2ray" ` ] ] || [ [ -z ` ls -F /usr/bin/v2ray/| grep "v2ctl" ` ] ]
2020-05-23 23:21:43 +08:00
then
2020-08-06 16:33:33 +08:00
progressTools "yellow" "检查、安装V2Ray--->" 20
2020-08-30 10:13:17 +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-08-02 19:14:20 +08:00
progressTools "green" " v2ray-core版本: ${ version } "
2020-08-04 16:20:52 +08:00
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
cp /etc/v2ray-agent/v2ray/v2ray /usr/bin/v2ray/v2ray && cp /etc/v2ray-agent/v2ray/v2ctl /usr/bin/v2ray/v2ctl
rm -rf /etc/v2ray-agent/v2ray/v2ray-linux-64.zip
2020-05-23 23:21:43 +08:00
fi
else
2020-08-04 16:20:52 +08:00
progressTools "green" " v2ray-core版本:`/etc/v2ray-agent/v2ray/v2ray --version|awk '{print $2 }'|head -1` "
cp /etc/v2ray-agent/v2ray/v2ray /usr/bin/v2ray/v2ray && cp /etc/v2ray-agent/v2ray/v2ctl /usr/bin/v2ray/v2ctl
2020-05-23 23:21:43 +08:00
fi
2020-08-02 19:14:20 +08:00
2020-08-18 13:44:19 +08:00
# todo
# echoContent yellow "V2Ray日志目录: "
# echoContent green " access: /etc/v2ray/v2ray_access_ws_tls.log"
# echoContent green " error: /etc/v2ray/v2ray_error_ws_tls.log"
2020-07-21 14:03:18 +08:00
2020-08-18 15:45:55 +08:00
# qrEncode $1 $2
2020-08-18 13:44:19 +08:00
# progressTools "yellow" "安装完毕[100%]--->"
# echoContent yellow "============================成功分界线============================="
2020-08-02 19:14:20 +08:00
2020-08-18 13:44:19 +08:00
# progressTools "yellow" "监听V2Ray日志中, 请使用上方生成的vmess访问, 如有日志出现则证明线路可用, 退出监听也无妨, Ctrl+c退出监听日志, --->"
# echo '' > /etc/v2ray/v2ray_access_ws_tls.log
# killSleep > /dev/null 2>&1
# tail -f /etc/v2ray/v2ray_access_ws_tls.log
}
# 验证整个服务是否可用
checkGFWStatue( ) {
2020-08-27 16:57:42 +08:00
# 验证整个服务是否可用
2020-08-02 19:14:20 +08:00
progressTools "yellow" "验证服务是否可用--->"
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
sleep 1
if [ [ ! -z ` curl -s -L https://${ domain } /${ customPath } | grep -v grep| grep "Bad Request" ` ] ]
then
progressTools "green" " 服务可用--->"
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
elif [ [ " ${ globalType } " = "tcp" ] ]
then
echo '' > /etc/v2ray/v2ray_access_ws_tls.log
curl --connect-time 3 --max-time 1 --url https://${ domain } > /dev/null 2>& 1
sleep 0.1
if [ [ ! -z ` cat /etc/v2ray/v2ray_access_ws_tls.log| grep -v grep| grep "Not Found" ` ] ]
then
progressTools "green" " 服务可用--->"
else
progressTools "red" " 服务不可用"
progressTools "red" " 1.请检查云朵是否关闭"
progressTools "red" " 2.请手动尝试使用账号并观察日志,日志路径[/etc/v2ray/v2ray_access_ws_tls.log]"
exit 0
fi
2020-08-29 23:12:20 +08:00
elif [ [ " ${ globalType } " = "vlesstcpws" ] ]
then
sleep 1
if [ [ ! -z ` curl -s -L https://${ domain } /${ customPath } | grep -v grep| grep "Bad Request" ` ] ]
then
progressTools "green" " 服务可用--->"
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-08-27 16:57:42 +08:00
2020-05-23 23:21:43 +08:00
}
# 开机自启
installV2RayService( ) {
2020-08-02 19:14:20 +08:00
progressTools "yellow" " 配置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
ExecStart = /usr/bin/v2ray/v2ray -config /etc/v2ray/config.json
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
progressTools "green" " 配置V2Ray开机自启成功--->"
fi
}
# 操作V2Ray
handleV2Ray( ) {
if [ [ ! -z ` find /bin /usr/bin -name "systemctl" ` ] ] && [ [ ! -z ` ls /etc/systemd/system/| grep -v grep| grep v2ray.service` ] ]
then
if [ [ -z ` ps -ef| grep -v grep| grep v2ray` ] ] && [ [ " $1 " = "start" ] ]
then
systemctl start v2ray.service
elif [ [ ! -z ` ps -ef| grep -v grep| grep v2ray` ] ] && [ [ " $1 " = "stop" ] ]
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
/usr/bin/v2ray/v2ray -config /etc/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
if [ [ " $1 " = "start" ] ]
then
2020-08-18 16:22:06 +08:00
if [ [ ! -z ` ps -ef| grep -v grep| grep v2ray` ] ]
2020-08-18 13:44:19 +08:00
then
echoContent green "V2Ray启动成功" no
else
echoContent red "V2Ray启动失败" no
echoContent red "请手动执行【/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json】,查看错误日志" no
2020-08-18 15:45:55 +08:00
exit 0;
2020-08-18 13:44:19 +08:00
fi
elif [ [ " $1 " = "stop" ] ]
then
if [ [ -z ` ps -ef| grep -v grep| grep v2ray` ] ]
then
echoContent green "V2Ray关闭成功" no
else
echoContent red "V2Ray关闭失败" no
echoContent red "请手动执行【ps -ef|grep -v grep|grep v2ray|awk '{print \$2}'|xargs kill -9】" no
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
}
# 初始化V2Ray 配置文件
initV2RayConfig( ) {
2020-08-02 19:14:20 +08:00
2020-05-23 23:21:43 +08:00
touch /etc/v2ray/config.json
uuid = ` /usr/bin/v2ray/v2ctl uuid`
2020-06-11 15:39:59 +08:00
# 自定义IPLC端口
if [ [ ! -z ${ iplc } ] ]
then
2020-08-04 17:27:37 +08:00
cat << EOF > /etc/v2ray/config.json
{
"log" :{
"access" :"/etc/v2ray/v2ray_access_ws_tls.log" ,
"error" :"/etc/v2ray/v2ray_error_ws_tls.log" ,
"loglevel" :"debug"
} ,
"stats" :{
} ,
"api" :{
"services" :[
"StatsService"
] ,
"tag" :"api"
} ,
"policy" :{
"levels" :{
"1" :{
"handshake" :4,
"connIdle" :300,
"uplinkOnly" :2,
"downlinkOnly" :5,
"statsUserUplink" :false,
"statsUserDownlink" :false
}
} ,
"system" :{
"statsInboundUplink" :true,
"statsInboundDownlink" :true
}
} ,
"allocate" :{
"strategy" :"always" ,
"refresh" :5,
"concurrency" :3
} ,
"inbounds" :[
{
"port" :31299,
"protocol" :"vmess" ,
"settings" :{
"clients" :[
{
2020-08-18 15:45:55 +08:00
"id" :" ${ uuid } " ,
2020-08-04 17:27:37 +08:00
"alterId" :64,
"level" :1,
"email" :"test@v2ray.com"
}
]
} ,
"streamSettings" :{
"network" :"ws" ,
"wsSettings" :{
2020-08-18 15:45:55 +08:00
"path" :" / ${ customPath } "
2020-08-04 17:27:37 +08:00
}
}
} ,
2020-08-10 17:17:14 +08:00
{
"port" :31298,
"protocol" :"vless" ,
"settings" :{
"clients" :[
{
2020-08-18 15:45:55 +08:00
"id" :" ${ uuid } " ,
2020-08-10 17:17:14 +08:00
"level" :1,
2020-08-11 11:32:26 +08:00
"email" :"test_vless@v2ray.com"
2020-08-10 17:17:14 +08:00
}
] ,
2020-08-11 11:32:26 +08:00
"decryption" : "none"
2020-08-10 17:17:14 +08:00
} ,
"streamSettings" :{
"network" :"ws" ,
"wsSettings" :{
2020-08-18 15:45:55 +08:00
"path" :" / ${ customPath } vld "
2020-08-10 17:17:14 +08:00
}
}
} ,
2020-08-04 17:27:37 +08:00
{
"port" :31294,
"protocol" :"vmess" ,
"settings" :{
"clients" :[
{
"id" :"ab11e002-7008-ef16-4363-217aea8dc81c" ,
"alterId" :64,
"level" :1,
"email" :"HK_深港0.35x IPLC@v2ray.com"
} ,
{
"id" :"246d748a-dd07-2172-a397-ab110aa5ad2a" ,
"alterId" :64,
"level" :1,
"email" :"HK_莞港IPLC@v2ray.com"
}
]
}
}
] ,
"outbounds" :[
{
"protocol" :"freedom" ,
"settings" :{
"OutboundConfigurationObject" :{
"domainStrategy" :"AsIs" ,
"userLevel" :0
}
}
}
] ,
"routing" :{
"settings" :{
"rules" :[
{
"inboundTag" :[
"api"
] ,
"outboundTag" :"api" ,
"type" :"field"
}
]
} ,
"strategy" :"rules"
} ,
"dns" :{
"servers" :[
"8.8.8.8" ,
"8.8.4.4"
] ,
"tag" :"dns_inbound"
}
}
EOF
2020-08-27 16:57:42 +08:00
elif [ [ " $1 " = "wss" ] ]
2020-08-18 13:44:19 +08:00
then
2020-08-04 17:27:37 +08:00
cat << EOF > /etc/v2ray/config.json
{
"log" :{
"access" :"/etc/v2ray/v2ray_access_ws_tls.log" ,
"error" :"/etc/v2ray/v2ray_error_ws_tls.log" ,
"loglevel" :"debug"
} ,
"allocate" :{
"strategy" :"always" ,
"refresh" :5,
"concurrency" :3
} ,
"inbounds" :[
{
"port" :31299,
"protocol" :"vmess" ,
"settings" :{
"clients" :[
{
2020-08-18 15:45:55 +08:00
"id" :" ${ uuid } " ,
2020-08-27 16:57:42 +08:00
"alterId" :0,
2020-08-04 17:27:37 +08:00
"level" :1,
"email" :"test@v2ray.com"
}
]
} ,
"streamSettings" :{
"network" :"ws" ,
"wsSettings" :{
2020-08-18 15:45:55 +08:00
"path" :" / ${ customPath } "
2020-08-04 17:27:37 +08:00
}
}
2020-08-10 17:17:14 +08:00
} ,
{
"port" :31298,
"protocol" :"vless" ,
"settings" :{
"clients" :[
{
2020-08-18 15:45:55 +08:00
"id" :" ${ uuid } " ,
2020-08-27 16:57:42 +08:00
"alterId" :0,
2020-08-10 17:17:14 +08:00
"level" :1,
2020-08-11 11:32:26 +08:00
"email" :"test_vless@v2ray.com"
2020-08-10 17:17:14 +08:00
}
] ,
2020-08-11 11:32:26 +08:00
"decryption" : "none"
2020-08-10 17:17:14 +08:00
} ,
"streamSettings" :{
"network" :"ws" ,
"wsSettings" :{
2020-08-18 15:45:55 +08:00
"path" :" / ${ customPath } vld "
2020-08-10 17:17:14 +08:00
}
}
2020-08-04 17:27:37 +08:00
}
] ,
"outbounds" :[
{
"protocol" :"freedom" ,
"settings" :{
"OutboundConfigurationObject" :{
"domainStrategy" :"AsIs" ,
"userLevel" :0
}
}
}
] ,
2020-08-27 16:57:42 +08:00
"dns" :{
"servers" :[
"8.8.8.8" ,
"8.8.4.4"
] ,
"tag" :"dns_inbound"
}
}
EOF
2020-08-27 21:12:40 +08:00
elif [ [ " $1 " = "tcp" ] ]
2020-08-27 16:57:42 +08:00
then
cat << EOF > /etc/v2ray/config.json
{
"log" :{
"access" :"/etc/v2ray/v2ray_access_ws_tls.log" ,
"error" :"/etc/v2ray/v2ray_error_ws_tls.log" ,
"loglevel" :"debug"
2020-08-04 17:27:37 +08:00
} ,
2020-08-27 16:57:42 +08:00
"inbounds" : [
{
"port" : 443,
"protocol" : "vmess" ,
"settings" : {
"clients" : [
{
"id" : " ${ uuid } " ,
2020-08-29 23:12:20 +08:00
"alterId" : 0,
"email" :"test@v2ray.com"
2020-08-27 16:57:42 +08:00
}
]
} ,
"streamSettings" : {
"network" : "tcp" ,
"security" : "tls" ,
"tlsSettings" : {
"certificates" : [
{
"certificateFile" : " /etc/nginx/v2ray-agent-https/ ${ domain } .crt " ,
"keyFile" : " /etc/nginx/v2ray-agent-https/ ${ domain } .key "
}
]
}
}
}
] ,
"outbounds" :[
{
"protocol" : "freedom" ,
"settings" : { }
}
] ,
2020-08-04 17:27:37 +08:00
"dns" :{
"servers" :[
"8.8.8.8" ,
"8.8.4.4"
] ,
"tag" :"dns_inbound"
}
}
2020-08-29 23:12:20 +08:00
EOF
elif [ [ " $1 " = "vlesstcpws" ] ]
then
cat << EOF > /etc/v2ray/config.json
{
"log" : {
"access" : "/etc/v2ray/v2ray_access_ws_tls.log" ,
"error" : "/etc/v2ray/v2ray_error_ws_tls.log" ,
"loglevel" : "debug"
} ,
"inbounds" : [
{
"port" : 443,
"protocol" : "vless" ,
"settings" : {
"clients" : [
{
"id" : " ${ uuid } " ,
"alterId" : 0,
"email" : "test@v2ray.com"
}
] ,
"decryption" : "none" ,
"fallbacks" : [
{
"dest" : 80
} ,
{
"path" : " / ${ customPath } " ,
"dest" : 31299,
"xver" : 1
}
]
} ,
"streamSettings" : {
"network" : "tcp" ,
"security" : "tls" ,
"tlsSettings" : {
"alpn" : [
"http/1.1"
] ,
"certificates" : [
{
"certificateFile" : " /etc/nginx/v2ray-agent-https/ ${ domain } .crt " ,
"keyFile" : " /etc/nginx/v2ray-agent-https/ ${ domain } .key "
}
]
}
}
} ,
{
"port" : 31299,
"protocol" : "vmess" ,
"settings" : {
"clients" : [
{
"id" : " ${ uuid } " ,
"alterId" : 0,
"level" : 1,
"email" : "test@v2ray.com"
}
]
} ,
"streamSettings" : {
"network" : "ws" ,
"security" : "none" ,
"wsSettings" : {
"acceptProxyProtocol" : true,
"path" : " / ${ customPath } "
}
}
}
] ,
"outbounds" : [
{
"protocol" : "freedom" ,
"settings" : { }
}
] ,
"dns" : {
"servers" : [
"8.8.8.8" ,
"8.8.4.4"
] ,
"tag" : "dns_inbound"
}
}
2020-08-04 17:27:37 +08:00
EOF
2020-08-27 16:57:42 +08:00
2020-06-11 15:39:59 +08:00
fi
2019-11-06 10:58:06 +08:00
}
2020-08-18 13:44:19 +08:00
# 自定义CDN IP
customCDNIP( ) {
2020-08-02 19:14:20 +08:00
echoContent green "是否使用DNS智能解析进行自定义CDN IP? "
echoContent yellow " 智能DNS提供一下自定义CDN IP, 会根据运营商自动切换ip, 测试结果请查看[https://github.com/mack-a/v2ray-agent/blob/master/optimize_V2Ray.md]" "no"
2020-08-30 15:03:19 +08:00
echoContent yellow " 移动:104.19.16.102" "no"
2020-08-02 19:14:20 +08:00
echoContent yellow " 联通:104.16.160.136" "no"
2020-08-29 23:12:20 +08:00
echoContent yellow " 电信:104.16.160.136" "no"
2020-08-02 19:14:20 +08:00
echoContent green "输入[y]使用,[任意]不使用" "no"
2020-06-05 11:44:02 +08:00
read 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-06-05 11:44:02 +08:00
fi
2020-08-18 13:44:19 +08:00
}
2020-08-18 15:45:55 +08:00
# 生成账号base64链接
buildAccounts( ) {
2020-08-18 13:44:19 +08:00
user = ` cat /etc/v2ray/config.json| jq .inbounds[ 0] `
2020-08-18 17:03:59 +08:00
ps = " ${ domain } "
2020-08-18 13:44:19 +08:00
id = ` echo ${ user } | jq .settings.clients[ 0] .id`
aid = ` echo ${ user } | jq .settings.clients[ 0] .alterId`
2020-08-18 17:03:59 +08:00
host = " ${ domain } "
add = " ${ add } "
2020-08-18 13:44:19 +08:00
path = ` echo ${ user } | jq .streamSettings.wsSettings.path`
2020-08-29 23:12:20 +08:00
if [ [ " ${ path } " = "null" ] ]
then
path = \" /${ customPath } \"
fi
echoContent red path:${ path }
echoContent red customPath:${ customPath }
2020-06-05 11:44:02 +08:00
echoContent yellow "客户端链接--->\n"
2020-08-18 15:45:55 +08:00
defaultBase64Code " ${ ps } " " ${ id } " " ${ host } " " ${ path } " " ${ add } "
2020-08-27 16:57:42 +08:00
# quanMultBase64Code "${ps}" "${id}" "${host}" "${path}" "${add}"
2020-08-18 15:45:55 +08:00
}
# 通用
defaultBase64Code( ) {
local ps = $1
local id = $2
local host = $3
local path = $4
local add = $5
2020-08-27 16:57:42 +08:00
if [ [ ${ globalType } = "tcp" ] ]
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-08-29 23:12:20 +08:00
echoContent red "通用json(tcp+tls)--->" "no"
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
echoContent red "通用vmess(tcp+tls)链接--->" "no"
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
echo "通用vmess(tcp+tls)链接: " > /etc/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Default } " >> /etc/v2ray/usersv2ray.conf
2020-08-27 16:57:42 +08:00
elif [ [ ${ globalType } = "wss" ] ]
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-08-29 23:12:20 +08:00
echoContent red "通用json(ws+tls)--->" "no"
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'
echoContent red "通用vmess(ws+tls)链接--->" "no"
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
echo "通用vmess(ws+tls)链接: " > /etc/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Default } " >> /etc/v2ray/usersv2ray.conf
2020-08-27 16:57:42 +08:00
elif [ [ " ${ globalType } " = "h2" ] ]
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' `
echoContent red "通用json--->" "no"
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-08-29 23:12:20 +08:00
elif [ [ " ${ globalType } " = "vlesstcpws" ] ]
then
echoContent red path:${ path }
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 red "通用json(ws+tls)--->" "no"
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'
echoContent red "通用vmess(ws+tls)链接--->" "no"
echoContent green " vmess:// ${ qrCodeBase64Default } \n "
echo "通用vmess(ws+tls)链接: " > /etc/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Default } " >> /etc/v2ray/usersv2ray.conf
echoContent red "通用json(VLESS+tcp+tls)--->" "no"
echoContent green ' {"port":"443","ps":"' ${ ps } '","tls":"tls","id":' " ${ id } " ',"host":"' ${ host } '","type":"none","net":"tcp","add":"' ${ host } '","allowInsecure":0,"method":"none","peer":""}\n'
echoContent green ' V2Ray v4.27.4 目前无通用订阅需要手动配置, VLESS和tcp大部分一样, 其余内容不变'
2020-08-27 16:57:42 +08:00
fi
2020-08-18 15:45:55 +08:00
2020-08-29 23:12:20 +08:00
# echoContent green ' V2Ray v4.27.0 目前无通用订阅需要手动配置, VLESS和上面大部分一样, path则是"'/${2}vld'",其余内容不变'
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-08-02 19:14:20 +08:00
echoContent red "Quantumult vmess--->" "no"
2020-06-05 16:42:21 +08:00
echoContent green " vmess:// ${ qrCodeBase64Quanmult } \n "
2020-06-05 18:07:40 +08:00
echo '' >> /etc/v2ray/usersv2ray.conf
echo "Quantumult:" >> /etc/v2ray/usersv2ray.conf
echo " vmess:// ${ qrCodeBase64Quanmult } " >> /etc/v2ray/usersv2ray.conf
2020-08-02 19:14:20 +08:00
echoContent red "Quantumult 明文--->" "no"
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
}
# 查看本机ip
checkDomainIP( ) {
currentIP = ` curl -s ifconfig.me| awk '{print}' `
echoContent skyBlue ${ currentIP }
}
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}' `
# echoContent red ${progressNum}
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-07-21 14:03:18 +08:00
# 卸载安装的内容
removeInstall( ) {
2020-08-04 16:20:52 +08:00
rm -rf /etc/v2ray-agent/v2ray
rm -rf /etc/v2ray-agent/tls
2020-07-21 14:03:18 +08:00
rm -rf /etc/v2ray
rm -rf /root/.acme.sh
echo ${ removeType } ,${ installType }
` ${ removeType } nginx` > /dev/null 2>& 1
}
2020-08-18 15:45:55 +08:00
menu( ) {
2020-08-02 19:14:20 +08:00
# 新建所需目录
mkdirTools
2020-06-23 10:22:15 +08:00
cd
2020-08-28 09:45:06 +08:00
echoContent red "==============================================================" "no"
echoContent green "V2Ray+wss+Nginx+Web/TLS+TCP+V2Ray/VLESS+TCP+V2Ray+Web一键脚本" "no"
2020-08-27 16:57:42 +08:00
echoContent green "作者: mack-a" no
echoContent green "Version: v1.0.9" no
2020-08-28 09:45:06 +08:00
echoContent red "==============================================================" "no"
2020-08-29 23:12:20 +08:00
echoContent yellow "1.V2Ray+WS+TLS+Nginx+Web" "no"
echoContent yellow "2.V2Ray+TCP+TLS" "no"
echoContent yellow "3.V2Ray+VLESS+TLS+TCP+Web/V2Ray+Vmess+TLS+WS+Web[CDN 云朵必须为灰色]" "no"
2020-08-28 09:45:06 +08:00
# echoContent yellow "4.状态展示" "no"
# echoContent yellow "5.安装BBR" "no"
# echoContent yellow "6.卸载脚本" "no"
echoContent red "==============================================================" "no"
read -n1 -p "请选择:" selectInstallType
case ${ selectInstallType } in
1)
2020-08-29 23:12:20 +08:00
installV2RayVmessWSSNginxWeb
2020-08-28 09:45:06 +08:00
; ;
2)
2020-08-29 23:12:20 +08:00
installV2RayVmessTCPTLS
; ;
3)
installV2RayVLESSTCPWSTLS
2020-08-28 09:45:06 +08:00
; ;
esac
2020-08-18 13:44:19 +08:00
exit 0;
# ===============
# todo 这里判断每次安装的内容
installSelect = 0
if [ [ ${ tlsStatus } = "1" ] ] && [ [ ${ v2rayStatus } = "1" ] ]
then
echoContent green "检测到已使用本脚本安装" "no"
echoContent yellow " 1.重新安装【使用缓存的文件( TLS证书、V2Ray) 】" "no"
echoContent yellow " 2.完全重装【会清理tmp缓存文件( TLS证书、V2Ray) 】" "no"
else
echoContent green "未监测到使用本脚本安装" "no"
echoContent yellow " 1.安装【未安装】" "no"
echoContent yellow " 2.完全安装【会清理tmp缓存文件( TLS证书、V2Ray) 】" "no"
fi
echoContent yellow " 3.BBR安装[推荐BBR+FQ 或者 BBR+Cake]" "no"
echoContent yellow " 4.完全卸载[清理Nginx、TLS证书、V2Ray、acme.sh]" "no"
echoContent red "==============================================================" "no"
echoContent green "请输入上列数字,[任意]结束:" "no"
read installStatus
if [ [ " ${ installStatus } " = "1" ] ]
then
rm -rf /etc/v2ray/usersv2ray.conf
installTools
installNginx
elif [ [ " ${ installStatus } " = "2" ] ]
then
rm -rf /usr/bin/v2ray
rm -rf /etc/v2ray-agent/v2ray
rm -rf /etc/v2ray-agent/tls
rm -rf /etc/v2ray
installTools
installNginx
elif [ [ " ${ installStatus } " = "3" ] ]
then
echoContent red "==============================================================" "no"
echoContent green "BBR脚本用的[ylx2016]的成熟作品,地址[https://github.com/ylx2016/Linux-NetSpeed/releases/download/sh/tcp.sh],请熟知" "no"
echoContent red " 1.安装" "no"
echoContent red " 2.回退主目录" "no"
echoContent red "==============================================================" "no"
echoContent green "请输入[1]安装,[2]回到上层目录" "no"
read installBBRStatus
if [ [ " ${ installBBRStatus } " = "1" ] ]
then
wget -N --no-check-certificate "https://github.com/ylx2016/Linux-NetSpeed/releases/download/sh/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
else
init
fi
elif [ [ " ${ installStatus } " = "4" ] ]
then
removeInstall
echoContent yellow "卸载完成" "no"
killSleep > /dev/null 2>& 1
exit 0;
else
echoContent yellow "欢迎下次使用--->" "no"
killSleep > /dev/null 2>& 1
exit 0;
fi
}
2020-08-27 16:57:42 +08:00
# 安装V2Ray+wss+Nginx+Web
2020-08-29 23:12:20 +08:00
installV2RayVmessWSSNginxWeb( ) {
2020-08-27 16:57:42 +08:00
globalType = wss
2020-08-18 15:45:55 +08:00
installTools
initTLSNginxConfig
installTLS
handleNginx stop
2020-08-27 16:57:42 +08:00
initNginxConfig wss
2020-08-18 15:45:55 +08:00
randomPathFunction
installCronTLS
installV2Ray
installV2RayService
2020-08-27 16:57:42 +08:00
initV2RayConfig wss
2020-08-18 15:45:55 +08:00
handleV2Ray start
2020-08-18 17:03:59 +08:00
handleNginx start
customCDNIP
buildAccounts
checkGFWStatue
progressTools "yellow" "安装完毕[100%]--->"
2020-08-18 15:45:55 +08:00
}
2020-08-27 16:57:42 +08:00
# 安装V2Ray+TLS
2020-08-29 23:12:20 +08:00
installV2RayVmessTCPTLS( ) {
2020-08-27 16:57:42 +08:00
globalType = tcp
installTools
# 申请tls
initTLSNginxConfig
installTLS
handleNginx stop
2020-08-29 23:12:20 +08:00
installCronTLS
2020-08-27 16:57:42 +08:00
# 安装V2Ray
installV2Ray
installV2RayService
2020-08-27 21:12:40 +08:00
initV2RayConfig tcp
2020-08-27 16:57:42 +08:00
handleV2Ray start
# 生成账号
2020-08-29 23:12:20 +08:00
checkGFWStatue
buildAccounts
progressTools "yellow" "安装完毕[100%]--->"
}
installV2RayVLESSTCPWSTLS( ) {
globalType = vlesstcpws
installTools
# 申请tls
initTLSNginxConfig
installTLS
handleNginx stop
initNginxConfig vlesstcpws
randomPathFunction
installCronTLS
# 安装V2Ray
installV2Ray
installV2RayService
initV2RayConfig vlesstcpws
nginxBlog
handleV2Ray start
handleNginx start
customCDNIP
# 生成账号
checkGFWStatue
2020-08-27 16:57:42 +08:00
buildAccounts
progressTools "yellow" "安装完毕[100%]--->"
}
2020-08-18 13:44:19 +08:00
# 注意事项
warningMessage( ) {
echoContent green "1.脚本会检查并安装工具包"
echoContent green "2.如果使用此脚本生成过TLS证书、V2Ray, 会继续使用上次生成、安装的内容。" "no"
echoContent green "3.会删除、卸载已经安装的应用, 包括V2Ray、Nginx。" "no"
echoContent green "4.如果显示Nginx不可用, 请检查防火墙端口是否开放。" "no"
echoContent green "5.证书会在每天的1点30分检查更新" "no"
echoContent red "==============================================================" "no"
}
# 错误信息处理
errorMessage( ) {
echoContent yellow "Debian: " "no"
echoContent green " 错误1: WARNING: apt does not have a stable CLI interface. Use with caution in scripts.【这个错误无需处理】" "no"
echoContent green " 错误2: 如果错误很多, 且安装失败, 则需要重启vps, 无需重新安装OS。这种情况是在安装过程中意外断开导致。" "no"
echoContent red "==============================================================" "no"
}
# 状态展示
state( ) {
2020-06-28 18:17:49 +08:00
echoContent red "状态展示"
2020-06-23 10:22:15 +08:00
echoContent green "已安装账号:"
if [ [ ! -z ` find /etc| grep usersv2ray.conf` ] ] && [ [ ! -z ` cat /etc/v2ray/usersv2ray.conf` ] ]
2020-06-28 18:17:49 +08:00
then
cat /etc/v2ray/usersv2ray.conf
else
echoContent yellow " 暂无配置"
fi
echoContent green "\nV2Ray信息: "
2020-08-02 19:14:20 +08:00
2020-07-01 20:48:57 +08:00
v2rayStatus = 0
2020-06-28 18:17:49 +08:00
if [ [ ! -z ` ls -F /usr/bin/v2ray/| grep "v2ray" ` ] ] && [ [ ! -z ` find /etc/v2ray/ -name "config.json" ` ] ]
then
v2rayVersion = ` /usr/bin/v2ray/v2ray -version| awk '{print $2}' | head -1`
2020-07-01 20:48:57 +08:00
v2rayStatus = 1
2020-06-28 18:17:49 +08:00
echoContent yellow " version: ${ v2rayVersion } "
echoContent yellow " 安装路径:/usr/bin/v2ray/"
2020-07-13 17:46:39 +08:00
echoContent yellow " 配置文件:/etc/v2ray/config.json"
2020-06-28 18:35:05 +08:00
echoContent yellow " 日志路径:"
2020-07-22 13:54:11 +08:00
echoContent yellow " access: /etc/v2ray/v2ray_access_ws_tls.log"
echoContent yellow " error: /etc/v2ray/v2ray_error_ws_tls.log"
2020-06-28 18:17:49 +08:00
else
echoContent yellow " 暂未安装"
2020-06-23 10:22:15 +08:00
fi
2020-07-01 20:48:57 +08:00
tlsStatus = 0
2020-06-28 18:17:49 +08:00
echoContent green "\nTLS证书状态: "
2020-08-02 19:14:20 +08:00
2020-06-28 18:17:49 +08:00
if [ [ ! -z ` find /etc/nginx/v2ray-agent-https/ -name config` ] ] && [ [ ! -z ` cat /etc/nginx/v2ray-agent-https/config` ] ]
then
2020-07-01 20:48:57 +08:00
tlsStatus = 1
2020-06-28 18:17:49 +08:00
domain = ` cat /etc/nginx/v2ray-agent-https/config| awk '{print $1}' `
tlsCreateTime = ` cat /etc/nginx/v2ray-agent-https/config| awk '{print $2}' `
currentTime = ` date +%s`
stampDiff = ` expr ${ currentTime } - ${ tlsCreateTime } `
dayDiff = ` expr ${ stampDiff } / 86400`
echoContent yellow " 证书域名: ${ domain } "
echoContent yellow " 安装日期:`date -d @ ${ tlsCreateTime } + " %F %H:%M:%S" `,剩余天数:`expr 90 - ${ dayDiff } ` "
2020-07-13 17:46:39 +08:00
echoContent yellow " 证书路径:"
echoContent yellow " /etc/nginx/v2ray-agent-https/ ${ domain } .key "
echoContent yellow " /etc/nginx/v2ray-agent-https/ ${ domain } .crt "
2020-06-28 18:17:49 +08:00
else
2020-07-21 14:03:18 +08:00
echoContent yellow " 暂未安装或未使用最新的脚本安装"
2020-06-28 18:17:49 +08:00
fi
2020-07-13 17:46:39 +08:00
echoContent green "\n定时任务相关文件路径: "
if [ [ ! -z ` find /etc/nginx/v2ray-agent-https/ -name backup_crontab.cron` ] ]
then
echoContent yellow " 定时更新tls脚本路径: /etc/nginx/v2ray-agent-https/reloadInstallTLS.sh"
echoContent yellow " 定时任务文件路径:/etc/nginx/v2ray-agent-https/backup_crontab.cron"
2020-08-04 16:20:52 +08:00
echoContent yellow " 定时任务日志路径:/etc/v2ray-agent/tls/tls.log"
echoContent yellow " acme.sh日志路径: /etc/v2ray-agent/tls/acme.log"
2020-07-13 17:46:39 +08:00
else
2020-07-21 14:03:18 +08:00
echoContent yellow " 暂未安装或未使用最新的脚本安装"
fi
echoContent green "\n软件运行状态: "
if [ [ ! -z ` ps -ef| grep -v grep| grep nginx` ] ]
then
echoContent yellow " Nginx:【运行中】"
elif [ [ ! -z ` find /usr/sbin/ -name 'nginx' ` ] ]
then
echoContent yellow " Nginx:【未运行】, 执行【nginx】运行"
else
echoContent yellow " Nginx:【未安装】"
fi
if [ [ ! -z ` ps -ef| grep -v grep| grep v2ray` ] ]
then
echoContent yellow " V2Ray:【运行中】"
2020-07-21 15:33:18 +08:00
elif [ [ ! -z ` ls -F /usr/bin/v2ray/| grep "v2ray" ` ] ]
2020-07-21 14:03:18 +08:00
then
echoContent yellow " V2Ray:【未运行】,执行【/usr/bin/v2ray/v2ray -config /etc/v2ray/config.json &】运行"
else
echoContent yellow " V2Ray:【未安装】"
2020-07-13 17:46:39 +08:00
fi
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-08-03 17:23:14 +08:00
centosVersion = ` rpm -q centos-release| awk -F "[-]" '{print $3}' `
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