Personal notes to be always available for debian installations.
Here’s a very simple script which is divided into two parts, code which always runs, and code which runs when called with “start” or “stop”.
If you need something like a service to start at boot time, you need this.
Debian stores script needed to usually start, stop and restart in /etc/init.d/
Scripts contained have to be able to manage at least the start and stop parameters.
Following script is an example i use as template for any purpose.
#! /bin/sh # /etc/init.d/template # # at least two cases (start and stop) case "$1" in start) echo "Starting service... " /usr/local/bin/yourservce -parameters ;; stop) echo "Stopping service" kill -0 $PID 2> /dev/null ;; *) echo "Usage: /etc/init.d/template {start|stop}" exit 1 ;; esac exit 0
Anyway you can add several “cases” and options, take a look at you scripts in /etc/init.d directory.
Once you have your start/stop script, you add it let’s say at boot time, with the command
update-rc.d script_name defaults
(remember to chmod +x the file)
You can remove it with following command:
update-rc.d -f script_name remove
obviously thanks to http://www.debian-administration.org/articles/28