Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For the life of me, I cannot get this to work. I'm running Debian on Raspberry Pi.

running this command from CLI:

/home/pi/domotiga/DomotiGaServer.gambas -d

runs my home automation server.

How do I go about running this on boot?

I have a file in my /etc/init.d dir that does get loaded, but it doesn't launch the server

file contents:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          domotigaserver
# Required-Start:    $syslog $mysql
# Required-Stop:     $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: domotiga server
# Description:
#
### END INIT INFO

#!/bin/bash
# /etc/init.d/domotigaserver
#

# Carry out specific functions when asked to by the system
case "$1" in
start)
su pi -c '/home/pi/domotiga/DomotiGaServer.gambas -d'
echo "Starting DomotiGa Server " 
;;
stop)
pkill DomotiGaServer.gambas
echo "DomotiGa Server has been stopped (didn't double check though)" 
;;
*)
echo "Usage: /etc/init.d/domotigaserver {start|stop}" 
exit 1
;;
esac

exit 0
share|improve this question
8  
Writing the init.d script is not enough, you need to create start/stop links in /etc/rc[0-9].d for the proper run level. Tools like rcconf or update-rc.d can do this for you. See e.g. debianadmin.com/manage-linux-init-or-startup-scripts.html –  jofel Dec 30 '12 at 17:46
    
@jofel A verbose version of that comment would make an excellent answer. –  Herman Torjussen Dec 30 '12 at 19:20
1  
rcconf reports that the domotigaserver is scheduled to load - is that enough? When watching the startup text, 'domotigaserver started' is also listed, yet the server isn't running. Thanks. –  Mike Thrussell Dec 30 '12 at 19:42
1  
@MikeThrussell If you see the message, your script seems to be called. Does the program start if you call your script by hand? –  jofel Dec 30 '12 at 20:13
    
@jofel yes, it starts when called by hand - I log in (ssh) as user 'pi' to do this –  Mike Thrussell Dec 30 '12 at 20:29

2 Answers 2

Creating init.d scripts is not enough, you need to create start/stop links in /etc/rc[0-9].d for the proper run level. As default, Debian uses run level 2 (configurable in /etc/inittab).

To create appropriate links, you can use update-rc.d. Run

update-rc.d domotigaserver default

as root user.

Alternatively, you can use rcconf (install it e.g. by apt-get install rcconf). It offers a nice TUI.

See for example here for more information.

share|improve this answer
    
Thanks for your detailed answer. Unfortunately this doesn't seem to be my problem. Running '/etc/init.d/domotigaserver start' by hand also starts the server ok, and rcconf reports it is set to run on startup and the script executes, but the server isn't loaded. –  Mike Thrussell Dec 31 '12 at 0:59

Turns out the script was executing too early; before some prerequisites. Symlinks were named S03domotigaserver - I renamed them to S80domotigaserver and it now works.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.