Problem starting a service running Debian
Modern Debian uses a dependency-based init system. The dependencies are defined in the LSB header you have at the top of the init script. You need to define a dependency on $network
:
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
Related videos on Youtube
Sun Wukong
Updated on September 18, 2022Comments
-
Sun Wukong over 1 year
I want to run a UPNP renderer as a service on a Raspberry Pi using Raspian, a Debian based distro. Actually, everything runs fine but one thing : I can't manage to start the service at boot time at the right time. To me, it looks that it starts too early before the wifi connection has been established. As a result, the renderer can't be seen on the network. If I manually stop the service and restart it, it works fine.
As root, I run the following command to create the service :
update-rc.d gmediarender defaults
but links are created like S02gmediarender and the wifi manager is S03wicd so after unregistering gmediarender, I tried :
update-rc.d gmediarender defaults 99
but the result is just the same.
Originally, my script was :
#!/bin/sh ### BEGIN INIT INFO # Provides: gmediarender # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start GMediaRender at boot time # Description: Start GMediaRender at boot time. ### END INIT INFO USER=root HOME=/root export USER HOME case "$1" in start) echo "Starting GMediaRender" start-stop-daemon -x /usr/local/bin/gmediarender -c pi:audio -S -- -f "Raspberry" -d ;; stop) echo "Stopping GMediaRender" start-stop-daemon -x /usr/local/bin/gmediarender -K ;; *) echo "Usage: /etc/init.d/gmediarender {start|stop}" exit 1 ;; esac exit 0
i tried to remove the header part but it didn't help. Thanks for your help :-)
After adding the $network dependency, I issued the update-rc.d command with (and then without) the -n option :
pi@raspberrypi ~ $ sudo update-rc.d -n gmediarender defaults 99 update-rc.d: using dependency based boot sequencing insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc0.d/K01gmediarender insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc1.d/K01gmediarender insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc2.d/S02gmediarender insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc3.d/S02gmediarender insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc4.d/S02gmediarender insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc5.d/S02gmediarender insserv: enable service ../init.d/gmediarender -> /etc/init.d/../rc6.d/K01gmediarender insserv: dryrun, not creating .depend.boot, .depend.start, and .depend.stop pi@raspberrypi ~ $
Here's my rc2.d disrectory : I wonder if network-manager and wicd are not redundant and may interfere and cause trouble ?
pi@raspberrypi /etc/rc2.d $ ll total 4 lrwxrwxrwx 1 root root 17 oct. 28 23:43 K01lightdm -> ../init.d/lightdm lrwxrwxrwx 1 root root 20 mars 16 19:20 K06nfs-common -> ../init.d/nfs-common lrwxrwxrwx 1 root root 17 mars 16 19:20 K06rpcbind -> ../init.d/rpcbind -rw-r--r-- 1 root root 677 févr. 8 01:26 README lrwxrwxrwx 1 root root 18 oct. 28 22:56 S01bootlogs -> ../init.d/bootlogs lrwxrwxrwx 1 root root 17 oct. 28 23:27 S01ifplugd -> ../init.d/ifplugd lrwxrwxrwx 1 root root 14 oct. 28 22:56 S01motd -> ../init.d/motd lrwxrwxrwx 1 root root 17 oct. 28 23:27 S01rsyslog -> ../init.d/rsyslog lrwxrwxrwx 1 root root 14 mars 16 17:50 S01sudo -> ../init.d/sudo lrwxrwxrwx 1 root root 22 oct. 28 23:27 S01triggerhappy -> ../init.d/triggerhappy lrwxrwxrwx 1 root root 14 oct. 28 23:27 S02cron -> ../init.d/cron lrwxrwxrwx 1 root root 14 oct. 28 23:27 S02dbus -> ../init.d/dbus lrwxrwxrwx 1 root root 24 oct. 28 23:28 S02dphys-swapfile -> ../init.d/dphys-swapfile lrwxrwxrwx 1 root root 22 mars 30 21:38 S02gmediarender -> ../init.d/gmediarender lrwxrwxrwx 1 root root 13 oct. 28 23:27 S02ntp -> ../init.d/ntp lrwxrwxrwx 1 root root 15 mars 16 18:00 S02rsync -> ../init.d/rsync lrwxrwxrwx 1 root root 13 oct. 28 23:59 S02ssh -> ../init.d/ssh lrwxrwxrwx 1 root root 22 mars 16 21:25 S03avahi-daemon -> ../init.d/avahi-daemon lrwxrwxrwx 1 root root 19 mars 16 18:47 S03bluetooth -> ../init.d/bluetooth lrwxrwxrwx 1 root root 25 mars 16 18:48 S03network-manager -> ../init.d/network-manager lrwxrwxrwx 1 root root 14 mars 23 15:09 S03wicd -> ../init.d/wicd lrwxrwxrwx 1 root root 20 mars 16 19:20 S04pulseaudio -> ../init.d/pulseaudio lrwxrwxrwx 1 root root 18 mars 16 19:20 S05rc.local -> ../init.d/rc.local lrwxrwxrwx 1 root root 19 mars 16 19:20 S05rmnologin -> ../init.d/rmnologin pi@raspberrypi /etc/rc2.d $
A new try : I tried to rename
/etc/rc2.d/S02gmediarender
as/etc/rc2.d/S06gmediarender
Same problem : after reboot, the service isn't visible on the network.Finally: I went in another direction : getting the problem simpler as I suspected that wicd and network-manager were probably interfering with each other. So I got rid of the two of them and configured
/etc/network/interfaces
so the RPI simply connect to my wifi access point. The KISS effect : Keep it simple, stupid ;-) Without the wifi managers overhead and after a reboot, the GMediaRenderer is now available on my network.-
ott-- about 11 yearsIf you omit the
99
, does it create the script withS20...
then? What version of Debian is that? -
Sun Wukong about 11 yearsWhen I omitted the 99, the scripts were created with S02 and the network manager(s) were like S03. I got rid of them and it is now fine. Raspian is a Debian based distro for the €25 Raspberry computer
-
hildred almost 9 yearspossible duplicate of Creating a shutdown only script with update-rc.d
-
-
Sun Wukong about 11 yearsthanks for your help. I added the $network dependency, issued the
update-rc.d gmediarender defaults
command and rebooted. But unfortunatly after reboot, the service is up (like before) but the renderer isn't seen on the network (as it is if I restart it manually). Here's a trace I made :