feat(脚本): 重写快捷方式

pull/534/merge
mack-a 2020-10-15 16:06:53 +08:00
parent 923259c180
commit 4d8f594b15
2 changed files with 29 additions and 36 deletions

View File

@ -41,7 +41,7 @@
- 支持个性化安装VLESS+TCP为必选其余为可选项。 - 支持个性化安装VLESS+TCP为必选其余为可选项。
- 脚本自动检查升级 - 脚本自动检查升级
- 自动更新TLS证书 - 自动更新TLS证书
- 支持快捷方式启动安装完毕后shell输入[vas]即可打开脚本,脚本执行路径[/etc/v2ray-agent/install.sh] - 支持快捷方式启动安装完毕后shell输入[vasma]即可打开脚本,脚本执行路径[/etc/v2ray-agent/install.sh]
## 注意事项 ## 注意事项
@ -53,7 +53,7 @@
## 安装脚本 ## 安装脚本
``` ```
wget -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod +x install.sh && ./install.sh wget -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh
``` ```
- 示例图 - 示例图
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/install/install.jpg" width=700> <img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/install/install.jpg" width=700>

View File

@ -61,6 +61,11 @@ mkdirTools(){
mkdir -p /etc/v2ray-agent/v2ray/conf mkdir -p /etc/v2ray-agent/v2ray/conf
mkdir -p /etc/v2ray-agent/trojan mkdir -p /etc/v2ray-agent/trojan
mkdir -p /etc/systemd/system/ mkdir -p /etc/systemd/system/
mkdir -p /tmp/v2ray-agent-tls/
}
# 创建基础的文件目录
mkdirBaseDIR(){
mkdir -p /etc/v2ray-agent
} }
# 安装工具包 # 安装工具包
installTools(){ installTools(){
@ -777,12 +782,8 @@ updateV2RayAgent(){
local currentTime=`date +%s` local currentTime=`date +%s`
echo "upgrade|${currentTime}" > /etc/v2ray-agent/upgradeStatus echo "upgrade|${currentTime}" > /etc/v2ray-agent/upgradeStatus
echoContent skyBlue "\n进度 $1/${totalProgress} : 更新v2ray-agent脚本" echoContent skyBlue "\n进度 $1/${totalProgress} : 更新v2ray-agent脚本"
if [[ -d "/etc/v2ray-agent" ]] mkidr -p /etc/v2ray-agent
then wget -P /etc/v2ray-agent/ -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /etc/v2ray-agent/install.sh && vasma
wget -P /etc/v2ray-agent/ -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod +x /etc/v2ray-agent/install.sh && /etc/v2ray-agent/install.sh
else
wget -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod +x install.sh && ./install.sh
fi
} }
# 验证整个服务是否可用 # 验证整个服务是否可用
@ -1710,27 +1711,22 @@ unInstall(){
echoContent green " ---> 删除V2Ray开机自启完成" echoContent green " ---> 删除V2Ray开机自启完成"
rm -rf /etc/systemd/system/trojan-go.service rm -rf /etc/systemd/system/trojan-go.service
echoContent green " ---> 删除Trojan-Go开机自启完成" echoContent green " ---> 删除Trojan-Go开机自启完成"
rm -rf /tmp/v2ray-agent-tls/*
if [[ -d "/etc/v2ray-agent/tls" ]] && [[ ! -z `find /etc/v2ray-agent/tls/ -name "*.key"` ]] && [[ ! -z `find /etc/v2ray-agent/tls/ -name "*.crt"` ]] if [[ -d "/etc/v2ray-agent/tls" ]] && [[ ! -z `find /etc/v2ray-agent/tls/ -name "*.key"` ]] && [[ ! -z `find /etc/v2ray-agent/tls/ -name "*.crt"` ]]
then then
mv /etc/v2ray-agent/tls /tmp mv /etc/v2ray-agent/tls /tmp/v2ray-agent-tls
if [[ ! -z `find /tmp/tls -name '*.key'` ]] if [[ ! -z `find /tmp/tls -name '*.key'` ]]
then then
echoContent yellow " ---> 备份证书成功,请注意留存。[/tmp/tls]" echoContent yellow " ---> 备份证书成功,请注意留存。[/tmp/v2ray-agent-tls]"
fi fi
fi fi
rm -rf /etc/v2ray-agent rm -rf /etc/v2ray-agent
rm -rf /etc/nginx/conf.d/alone.conf rm -rf /etc/nginx/conf.d/alone.conf
if [[ -f "/root/.bashrc" ]] && [[ ! -z `cat /root/.bashrc|grep "/etc/v2ray-agent/install.sh"` ]] rm -rf /usr/bin/vasma
then rm -rf /usr/sbin/vasma
lineNumber=`nl -b a .bashrc |grep /etc/v2ray-agent/install.sh|awk '{print $1}'` echoContent green " ---> 卸载快捷方式完成"
sed -i "${lineNumber}d" /root/.bashrc echoContent green " ---> 卸载v2ray-agent完成"
source /etc/profile
echoContent green " ---> 卸载快捷方式完成"
fi
echoContent green " ---> 卸载V2Ray完成"
echoContent green " ---> 卸载完成"
} }
# 检查错误 # 检查错误
checkFail(){ checkFail(){
@ -1940,7 +1936,6 @@ customInstall(){
totalProgress=17 totalProgress=17
globalType=vlesstcpws globalType=vlesstcpws
mkdirTools 1 mkdirTools 1
aliasInstall
installTools 2 installTools 2
# 申请tls # 申请tls
initTLSNginxConfig 3 initTLSNginxConfig 3
@ -2015,7 +2010,7 @@ menu(){
cd cd
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v2.0.22" echoContent green "当前版本v2.0.23"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:七合一共存脚本" echoContent green "描述:七合一共存脚本"
echoContent red "==============================================================" echoContent red "=============================================================="
@ -2038,7 +2033,8 @@ menu(){
echoContent red "==============================================================" echoContent red "=============================================================="
automaticUpgrade automaticUpgrade
initCustomInstallType initCustomInstallType
mkdirBaseDIR
aliasInstall
read -p "请选择:" selectInstallType read -p "请选择:" selectInstallType
case ${selectInstallType} in case ${selectInstallType} in
1) 1)
@ -2159,22 +2155,20 @@ checkLog(){
aliasInstall(){ aliasInstall(){
if [[ -f "/root/install.sh" ]] && [[ -d "/etc/v2ray-agent" ]] && [[ ! -z `cat /root/install.sh|grep "作者mack-a"` ]] if [[ -f "/root/install.sh" ]] && [[ -d "/etc/v2ray-agent" ]] && [[ ! -z `cat /root/install.sh|grep "作者mack-a"` ]]
then then
mv /root/install.sh /etc/v2ray-agent/install.sh
cp -Rf /root/install.sh /etc/v2ray-agent/install.sh if [[ -d "/usr/bin/" ]] && [[ ! -f "/usr/bin/vasma" ]]
rm -rf /root/install.sh
if [[ ! -f "/root/.bashrc" ]]
then then
touch /root/.bashrc ln -s /etc/v2ray-agent/install.sh /usr/bin/vasma
fi chmod 700 /usr/bin/vasma
if [[ -z `cat /root/.bashrc|grep '/etc/v2ray-agent/install.sh'` ]] rm -rf /root/install.sh
elif [[ -d "/usr/sbin" ]] && [[ ! -f "/usr/sbin/vasma" ]]
then then
echo alias vas=\'bash /etc/v2ray-agent/install.sh\' >> /root/.bashrc ln -s /etc/v2ray-agent/install.sh /usr/sbin/vasma
chmod 700 /usr/sbin/vasma
rm -rf /root/install.sh
fi fi
source /etc/profile echoContent green "快捷方式创建成功,可执行[vasma]重新打开脚本"
else
echo noAliasInstall
fi fi
echoContent green " ---> 安装完毕,可执行[vas]重新回到打开脚本"
} }
# 默认安装 # 默认安装
defaultInstall(){ defaultInstall(){
@ -2182,7 +2176,6 @@ defaultInstall(){
totalProgress=17 totalProgress=17
globalType=vlesstcpws globalType=vlesstcpws
mkdirTools 1 mkdirTools 1
aliasInstall
installTools 2 installTools 2
# 申请tls # 申请tls
initTLSNginxConfig 3 initTLSNginxConfig 3