case $1 in "start") echo "执行了启动命令" tail -n+18 $0 > $(pwd)/KeepAdGuardShell.sh setsid sh $(pwd)/KeepAdGuardShell.sh > /dev/null & ;; "stop") echo "执行了关闭命令" ps -ef | grep "KeepAdGuardShell" | grep -v "grep" | awk '{print $2}' | xargs kill -9 ;; *) echo "输入 sh KeepAdGuard.sh start 命令启动"; echo "输入 sh KeepAdGuard.sh stop 命令关闭"; echo " -- -- By: Moieo" ;; esac exit # --------------------------------------- Shell --------------------------------------- while true do process=$(ps -e | grep 'com.adguard.android') if [[ $process != '' ]] then continue else am broadcast -n com.adguard.android/.receivers.BootUpReceiver fi done