SDB:How to Create Your Own Init Script

From openSUSE


Situation

You want to create your own init script which will be started and stopped in certain runlevels.
You also want to control this script by means of:

rc<scriptname> {start|stop|status|reload|force-reload|try-restart|restart}

Procedure

Copy the sample init script to your new script:

cp /etc/init.d/skeleton /etc/init.d/<scriptname>

Edit the file /etc/init.d/<scriptname> with a text editor of your choice and read and follow its instructions.

Now activate your script so that it can be run when the system boots:

insserv /etc/init.d/<scriptname>

Finally, create a link to /sbin:

ln -s /etc/init.d/<scriptname> /sbin/rc<scriptname>

Additional Information

For further information, please refer to the following manpages:

init(8), init.d(7), insserv(8)