On Sun, Nov 25, 2007 at 09:01:50PM -0800, C.J. Adams-Collier wrote: > is there something like a service-common package that provides a helper > script like the following for services to source? I think the current solution is "provide a template with dh_make", which is somewhat more general since the init.sh might need to be overhauled to be useful for some given app.
> I'm thinking that it would belong somewhere like > /usr/share/service-common/init.sh. I have not tested the following yet, and > I'm a sucky bash programmer. > > # Fully qualified paths to required programs > START_STOP_DAEMON=/sbin/start-stop-daemon > CAT=/bin/cat > ECHO=/bin/echo > . /etc/default/$SERVICE_NAME In general, you'd want to test for the existance and only source it if it's there. > # Kill me on all errors > set -e Put this early as possible. > # If the daemon binary does not exist, report the error and exit > if [ ! -f $SERVICE_DAEMON ]; then > fatal( "Service daemon, '$SERVICE_DAEMON' does not exist." ) > fi Actually, this is usually: [ -x $DAEMON ] || exit 0 since the conffiles (such as the initscript) are present after removing (but not purging) the package, and this keeps them from spewing noisy errors about the daemon not starting or such. > # Make sure the RUNDIR exists with correct permissions > if [ ! -d "$RUNDIR" ]; then Any reason not to include the rundir in the pacakge? Then you don't have to manually remove it in the initscripts. > # Check whether we were configured to not start the services. > check_for_no_start() { > if [ "$SERVICE_DISABLED" = "yes" ]; then This is probably a good idea to be generally and consistently supported. OTOH removing the execute bit or renaming the daemon file already works most (90%) of the time. Justin -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]