[英]update-rc.d disable/remove will not remove etc/init.d/rc* references
I have created a daemon using the Debian init.d skeleton which successfully runs as a service. 我使用Debian init.d框架创建了一个守护程序,该守护程序可以作为服务成功运行。 I've also used:
我也用过:
sudo update-rc.d /etc/init.d/pirservice.sh defaults
to get the daemon running at boot and closing nicely when issuing a shutdown command. 使守护程序在引导时运行,并在发出关闭命令时很好地关闭。
However, I have since tried to remove the start at boot service using the following: 但是,我此后尝试使用以下方法删除启动服务时的启动:
sudo update-rc.d /etc/init.d/pirservice.sh remove
On checking for completion using: 在检查完成时使用:
ls -l /etc/rc?.d/*pirservice.sh
The scripts is still linked in all 6 rc?.d folders and sure enough still loads at boot 脚本仍链接在所有6个rc?.d文件夹中,并确保在启动时仍加载足够的文件
when I try to use the following: 当我尝试使用以下内容时:
sudo update-rc.d /etc/init.d/pirservice.sh disable
I get the following error: 我收到以下错误:
update-rc.d: using dependency based boot sequencing
update-rc.d: error: cannot find a LSB script for /etc/init.d/pirservice.sh
My scripts is as follows: 我的脚本如下:
#!/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
Can anyone offer any guidance? 谁能提供任何指导?
OK. 好。 I couldn't see any obvious error with the init script.
我看不到初始化脚本有任何明显的错误。 so I forced the removal as follows:
因此,我强制执行以下操作:
sudo update-rc.d -f /etc/init.d/pirservice.sh remove
If anyone can figure out why I have the LSB error I would be appreciative. 如果有人能弄清楚为什么我有LSB错误,我将不胜感激。
The man page says 手册页说
update-rc.d [-n] [-f] name remove
update-rc.d [-n] [-f] 名称删除
update-rc.d updates the System V style init script links /etc/rcrunlevel.d/NN*name* whose target is the script /etc/init.d/ name .
更新的rc.d更新系统V风格的init脚本链接/etc/rcrunlevel.d/NN*name*其目标是/etc/init.d/目录名的脚本。
So you should use 所以你应该使用
update-rc.d pirservice.sh disable
update-rc.d pirservice.sh禁用
instead. 代替。 For good style you should update information within the
INIT INFO
block. 为了获得良好的风格,您应该在
INIT INFO
块中更新信息。 Additionaly you could remove the .sh
extension for a nicer name. 另外,您可以删除
.sh
扩展名以获得更好的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.