This is a but.sh template for creating /etc/rc.d/init.d scripts for Java jar files. (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.)
After making this template, of course I realized that this could very easily be modified to do any other daemon, so I did just that, though it was honestly pretty trivial.
This, of course, requires but.sh.
The template itself requires only bash and gnu-coreutils (for head and potentially echo).
NAME-- The intended name of the daemonJAVA_BIN-- The path to the Java binaryJAR-- The path to the jar to run
(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.errJAR_ARGS-- The list of arguments to pass to the Java process (for the jar)
wget https://gist.github.com/nealian/b3e40c8a7326ebea389e5fb97b3eeea3/raw/sysvinit-jar.buttemplate && wget https://gist.github.com/nealian/b3e40c8a7326ebea389e5fb97b3eeea3/raw/sysvinit-jar.buttemplate.functions
but.sh sysvinit-jar.buttemplate -c sysvinit-jar.buttemplate.functions -c daemon.environment -o /etc/rc.d/init.d/daemon