SysVinit サービスはスクリプト自体とは異なる動作をします。

SysVinit サービスはスクリプト自体とは異なる動作をします。

私はAndroidでLinux Deployを使用しており、SysVinit用のサービスを作成しようとしています。私が使用しているディストリビューションはDebian Busterです。私は次のスクリプトを書いた。問題は、スクリプト自体で実行すると完全に実行されますが、サービスでは実行されないことです。実行すると動作しますservice clash startが、service clash stop動作しませんservice clash restart。 SysVinitは起動時に正しく実行されます。だから唯一の問題はイベントですrestart。実行され、次に触れるstopことなく終了しますstart。この問題を解決するにはどうすればよいですか?

  1 #!/bin/zsh
  2 # Default-Start: 2 3 4 5
  3 # Default-Stop: 0 1 6
  4 # description: Clash service
  5
  6 Clash=/usr/local/bin/clash
  7 CfgDir=/etc/clash/
  8
  9 stop(){
 10         if [ -n "$(pgrep clash)" ]
 11         then
 12                 for pid in $(pgrep clash)
 13                 do
 14                         kill $pid
 15                 done
 16         fi
 17 }
 18
 19 start(){
 20         nohup $Clash -d $CfgDir &!
 21 }
 22
 23 test -x $Clash || exit 0
 24
 25 case $1 in
 26   start)
 27         start
 28         ;;
 29
 30   stop)
 31         stop
 32         ;;
 33
 34   restart)
 35         stop
 36         start
 37         ;;
 38
 39   *)
 40         echo "Usage: $0 {start|stop|restart}"
 41         exit 1
 42 esac
 43
 44 exit 0

ベストアンサー1

おすすめ記事