chorlton2080
Posts: 129
Joined: Sun Dec 23, 2012 9:44 pm

Update-rc won't remove links to user daemon

Thu Dec 26, 2013 10:53 pm

I have created a daemon using the Debian init.d skeleton which successfully runs as a service. I've also used:

Code: Select all

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:

Code: Select all

sudo update-rc.d /etc/init.d/pirservice.sh remove
On checking for completion using:

Code: Select all

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.

When I try to use the following:

Code: Select all

sudo update-rc.d /etc/init.d/pirservice.sh disable
I get the following error:

Code: Select all

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:

Code: Select all

#!/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 --st
   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 assistance?

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Update-rc won't remove links to user daemon

Thu Dec 26, 2013 10:57 pm

Sometimes I just add "exit 0" to a script. Yes, I know it is not ideal, but it works.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

chorlton2080
Posts: 129
Joined: Sun Dec 23, 2012 9:44 pm

Re: Update-rc won't remove links to user daemon

Fri Dec 27, 2013 12:14 am

Hi Richard

Given you've been using UNIX since '85 (I was at my C64 at that time having persuaded my parents of its 'educational value', which really meant playing Commodore Soccer) you clearly know what you're doing - but I fail to grasp how "exit 0" gets me to a solution with this. You'll note I have an "exit 0" in my init script also.

Return to “Raspberry Pi OS”