簡體   English   中英

update-rc.d禁用/刪除不會刪除etc / init.d / rc *引用

[英]update-rc.d disable/remove will not remove etc/init.d/rc* references

我使用Debian init.d框架創建了一個守護程序,該守護程序可以作為服務成功運行。 我也用過:

sudo update-rc.d /etc/init.d/pirservice.sh defaults

使守護程序在引導時運行,並在發出關閉命令時很好地關閉。

但是,我此后嘗試使用以下方法刪除啟動服務時的啟動:

sudo update-rc.d /etc/init.d/pirservice.sh remove

在檢查完成時使用:

ls -l /etc/rc?.d/*pirservice.sh

腳本仍鏈接在所有6個rc?.d文件夾中,並確保在啟動時仍加載足夠的文件

當我嘗試使用以下內容時:

sudo update-rc.d /etc/init.d/pirservice.sh disable

我收到以下錯誤:

update-rc.d: using dependency based boot sequencing
update-rc.d: error: cannot find a LSB script for /etc/init.d/pirservice.sh

我的腳本如下:

#!/bin/sh

# /etc/init.d/pirservice.sh

### BEGIN INIT INFO
# Provides:          myservice
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Put a short description of the service here
# Description:       Put a long description of the service here
### END INIT INFO

# Change the next 3 lines to suit where you install your script and what you want to     call it
DIR=/usr/local/bin/myservice
DAEMON=$DIR/pir.py
DAEMON_NAME=pir

# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root

# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid

. /lib/lsb/init-functions

do_start () {
    log_daemon_msg "Starting system $DAEMON_NAME daemon"
    start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user     $DAEMON_USER --startas $DAEMON
    log_end_msg $?
}
do_stop () {
    log_daemon_msg "Stopping system $DAEMON_NAME daemon"
    start-stop-daemon --stop --pidfile $PIDFILE --retry 10
    log_end_msg $?
}

case "$1" in

    start|stop)
        do_${1}
        ;;

    log_end_msg $?
}
 do_stop () {
    log_daemon_msg "Stopping system $DAEMON_NAME daemon"
    start-stop-daemon --stop --pidfile $PIDFILE --retry 10
    log_end_msg $?
}

 case "$1" in

    start|stop)
        do_${1}
        ;;

    restart|reload|force-reload)
        do_stop
        do_start
        ;;

    status)
        status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
        ;;
    *)
        echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}"
        exit 1
        ;;

esac
exit 0

誰能提供任何指導?

好。 我看不到初始化腳本有任何明顯的錯誤。 因此,我強制執行以下操作:

sudo update-rc.d -f /etc/init.d/pirservice.sh remove

如果有人能弄清楚為什么我有LSB錯誤,我將不勝感激。

手冊頁說

update-rc.d [-n] [-f] 名稱刪除

更新的rc.d更新系統V風格的init腳本鏈接/etc/rcrunlevel.d/NN*name*其目標是/etc/init.d/目錄的腳本。

所以你應該使用

update-rc.d pirservice.sh禁用

代替。 為了獲得良好的風格,您應該在INIT INFO塊中更新信息。 另外,您可以刪除.sh擴展名以獲得更好的名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM