This is a but.sh template for creating /etc/rc.d/init.d scripts. (Slightly based on the EPEL init-script template, and intended for an el6 machine, though I'm sure it would work with many, many more systems.)
This is actually a modification of a different gist, for jar init scripts on el6, but I soon realized that it could be used for any forking daemon just fine.
This, of course, requires but.sh
The template itself requires only bash and gnu-coreutils.
NAME-- The intended name of the daemonBIN-- The path to the binary
(Unless otherwise specified for the variable, assume the default is null.)
SUMMARY-- A very short summary of the daemon -- Defaults to the value of$NAMECHKCONFIG_START_LEVELS-- A string of runlevels (ex: '2345')CHKCONFIG_START_PRIORITY-- The starting priority, from 0-100 (0: started first) -- Defaults to 100CHKCONFIG_STOP_PRIORITY-- The stopping priority, from 0-100 (0: stopped first) -- Defaults to 0DESCRIPTION-- A longer description of the daemon, with lines separated by\n(see the manpage forechofor more backslash-sequences)LSB_PROVIDES-- The name(s) of the facilities that this daemon provides -- Defaults to the value of$NAMELSB_REQUIRED_START-- The name(s) of the facilities that this daemon needs to have running to be able to startLSB_REQUIRED_STOP-- The name(s) of the facilities that this daemon needs to have STILL running to be able to stopLSB_SHOULD_START-- The name(s) of the facilities that this daemon should start after; weak requires, but without failing if they don't existLSB_SHOULD_STOP-- The name(s) of the facilities that this daemon should stop before; weak requires, but without failing if they don't existLSB_DEFAULT_START-- A space-separated list of runlevels that this daemon should start on -- Defaults to space-separated$CHKCONFIG_START_LEVELSif that variable is set, otherwise nullLSB_DEFAULT_STOP-- A space-separated list of runlevels that this daemon should not be running on -- Defaults to all in the range 0-6 that$LSB_DEFAULT_STARTdoes not include if$LSB_DEFAULT_STARTor$CHKCONFIG_START_LEVELSare set, otherwise nullOUTLOG-- The log output file -- Defaults to /var/log/$NAME/$NAME.outERRLOG-- The error logging file -- Defaults to /var/log/$NAME/$NAME.errARGS-- The list of arguments to pass to the process
wget https://gist.github.com/nealian/1cce1439e532bf48d4dc71cb3ebde322/raw/sysvinit.buttemplate && wget https://gist.github.com/nealian/1cce1439e532bf48d4dc71cb3ebde322/raw/sysvinit.buttemplate.functions
but.sh sysvinit.buttemplate -c sysvinit.buttemplate.functions -c daemon.environment -o /etc/rc.d/init.d/daemon