代码拉取完成,页面将自动刷新
同步操作将从 孟帅/fas 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
sh_ver="0.2"
Green="\033[32m"
Red="\033[31m"
Blue="\033[36m"
Font="\033[0m"
Info="${Green}[信息]${Font}"
Error="${Red}[警告]${Font}"
Tip="${Blue}[注意]${Font}"
AD=`pwd`
Fas_Install(){
if [ -f "/bin/fas" ];then
echo -e "${Error} FAS守护已安装! "
echo "更新请先卸载原脚本"
sleep 1
exit
fi
echo " ----正在安装FAS守护脚本" && echo
cp ${AD}/fas /bin/fas
chmod 0777 /bin/fas
echo ' while true
do
netstat -lnup | grep openvpn &>/dev/null
if [ "$?" -ne "0" ];then
Date=`date +%Y年%m月%d日%H时%M分%S秒`
echo "$Date FAS守护: OpenVPN异常退出 尝试启动~" >> /root/fas.log
systemctl restart openvpn@server-udp >/dev/null 2>&1
sleep 2
netstat -lnup | grep openvpn &>/dev/null
if [ "$?" -eq "0" ];then
Date=`date +%Y年%m月%d日%H时%M分%S秒`
echo "$Date FAS守护: OpenVPN进程 启动成功~">> /root/fas.log
else
Date=`date +%Y年%m月%d日%H时%M分%S秒`
echo "$Date FAS守护: OpenVPN启动失败 10秒后将重试">> /root/fas.log
fi
fi
sleep 10
done' > /bin/fas_openvpn
chmod 0777 /bin/fas_openvpn
echo " ----FAS守护脚本安装完成" && echo
echo " ----输入fas即可管理脚本" && echo
echo " ----手动运行fas启动脚本" && echo
}
Fas_Uninstall(){
echo -n -e "${Error}确定卸载FAS流控守护脚本? Y/n: "
read choose
if [ "$choose" == "Y" ] || [ "$choose" == "y" ]
then
rm -rf ${AD}/fas
rm -rf /bin/fas
rm -rf /bin/fas_openvpn
#rm -rf /bin/fas_mysql
kill -9 $(ps -ef|grep fas_openvpn|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ') >/dev/null 2>&1
#kill -9 $(ps -ef|grep fas_mysql|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ') >/dev/null 2>&1
echo " ----Fas守护脚本卸载完成"
exit
else
echo "取消"
fi
}
Fas_Run(){
ps -ef | grep fas_openvpn | grep -v "grep" &>/dev/null
if [ "$?" = "0" ];then
echo -e "$Error FAS守护已在运行 无法多次运行"
sleep 2
exit
fi
echo "----Run OpenVPN Monitor Please Wait" && echo
bash /bin/fas_openvpn &
ps -ef | grep fas_openvpn | grep -v "grep" &>/dev/null
if [ "$?" -ne "0" ];then
echo -e "${Tip} FAS OpenVPN守护 启动失败 请检查" && echo
else
echo -e "${Info} FAS OpenVPN守护 启动成功" && echo
fi
Date=`date +%Y年%m月%d日%H时%M分%S秒`
echo "${Date} Run OpenVPN Monitor" >> /root/fas.log
}
Fas_Stop(){
echo -n -e "${Error}确定停止FAS守护? Y/n: "
read choose
if [ "$choose" == "Y" ] || [ "$choose" == "y" ]
then
echo -e "${Info} FAS守护已停止" && echo
kill -9 $(ps -ef|grep fas_openvpn|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ') >/dev/null 2>&1
#kill -9 $(ps -ef|grep fas_mysql|gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ') >/dev/null 2>&1
else
echo "取消"
fi
}
Fas_LOG(){
cat /root/fas.log
}
Fas_Update(){
echo -e "${Error} FAS守护为最新版"
}
echo
echo -e " FAS守护维护脚本 ${Red}[v${sh_ver}]${Font}
${Green}1.${Font} 安装 FAS守护
${Green}2.${Font} 卸载 FAS守护
————————————
${Green}3.${Font} 启动 FAS守护
${Green}4.${Font} 停止 FAS守护
${Green}5.${Font} 查看 FAS守护日志
————————————
${Green}6.${Font} 更新 FAS守护
————————————" && echo
stty erase '^H' && read -p " 请输入数字 [1-6]:" num
case "$num" in
1)
Fas_Install
;;
2)
Fas_Uninstall
;;
3)
Fas_Run
;;
4)
Fas_Stop
;;
5)
Fas_LOG
;;
6)
Fas_Update
;;
*)
echo "请输入正确数字 [1-6]"
;;
esac
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。