代码拉取完成,页面将自动刷新
#!/bin/bash
### BEGIN INIT INFO
# Provides: ADbyby
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Ad filtering tool
# Description: Start or stop the ADbyby
### END INIT INFO
NAME="ADbyby"
NAME_BIN="adbyby"
FILE="/usr/local/adbyby/bin"
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
RETVAL=0
check_running(){
PID=`ps -ef |grep "${NAME_BIN}" |grep -v "grep" | grep -v ".sh"| grep -v "init.d" |grep -v "service" |awk '{print $2}'`
if [[ ! -z ${PID} ]]; then
return 0
else
return 1
fi
}
do_start(){
check_running
if [[ $? -eq 0 ]]; then
echo -e "${Info} $NAME (PID ${PID}) 正在运行..." && exit 0
else
cd ${FILE}
nohup ./adbyby > /dev/null 2>&1 &
sleep 2s
check_running
if [[ $? -eq 0 ]]; then
echo -e "${Info} $NAME 启动成功 !"
else
echo -e "${Error} $NAME 启动失败 !"
fi
fi
}
do_stop(){
check_running
if [[ $? -eq 0 ]]; then
kill -9 ${PID}
RETVAL=$?
if [[ $RETVAL -eq 0 ]]; then
echo -e "${Info} $NAME 停止成功 !"
else
echo -e "${Error} $NAME 停止失败 !"
fi
else
echo -e "${Info} $NAME 未运行"
RETVAL=1
fi
}
do_status(){
check_running
if [[ $? -eq 0 ]]; then
echo -e "${Info} $NAME (PID $(echo ${PID})) 正在运行..."
else
echo -e "${Info} $NAME 未运行 !"
RETVAL=1
fi
}
do_restart(){
do_stop
echo -e "${Info} start downloading rules files"
if ! wget --no-check-certificate https://gitee.com/churking/adbyby/raw/master/xwhyc-rules/lazy.txt -O ${FILE}/data/lazy.txt; then
echo -e "${Error} lazy.txt下载失败 !" && exit 1
fi
echo -e "${Info} lazy.txt下载完成 !"
if ! wget --no-check-certificate https://gitee.com/churking/adbyby/raw/master/xwhyc-rules/video.txt -O ${FILE}/data/video.txt; then
echo -e "${Error} video.txt下载失败 !" && exit 1
fi
echo -e "${Info} video.txt下载完成 !"
do_start
}
case "$1" in
start|stop|restart|status)
do_$1
;;
*)
echo "使用方法: $0 { start | stop | restart | status }"
RETVAL=1
;;
esac
exit $RETVAL
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。