如何在執行 raspbian 的樹莓派中使用 init.d 啟動服務?

如何在執行 raspbian 的樹莓派中使用 init.d 啟動服務?

我的樹莓派上安裝了 Raspbian。我找到了一些指南,應該允許我在啟動時自動啟動腳本。但它不起作用。

我運行了 update-rc.d (不確定拼寫是否正確),我檢查了一下,它在 /etc/rcx.d 中創建了各種條目。這些條目以字母 K 或 S 開頭。

我可以使用“sudo service myscripthere start”(或停止/重新啟動)手動執行腳本。 「mybinary」位於 /usr/local/bin 中。

關於可能出什麼問題的任何想法嗎?謝謝


這是腳本的內容。

### BEGIN INIT INFO
# Provides:          myscript
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

case "$1" in
start)   echo -n "Start services"
   /usr/local/bin/mybinary -start
   ;;
stop)   echo -n "Stop services"
   /usr/local/bin/mybinary -stop
   ;;
restart)
   $0 stop
   $0 start
        ;;
*)   echo "Usage: $0 start|stop|restart"
        exit 1
        ;;
esac
exit 0

相關內容