#!/bin/sh # # Startup script for a daemontool services. # # Written by: Jeremy Brand # http://www.nirvani.net/software/ # # Copyright 2003, Jeremy Brand # All rights reserved # # Version 0.8.0 # # Used to integrate D. J. Bernstein's daemontools nicely # into SysV init scripts (RedHat, Debian, etc) # # Copy this file into /etc/init.d/your_program # # Replace this with the name of your service directory # /service/your_program_dir # prog="your_program_dir" # Default return value RETVAL=0 # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $"Starting ${prog}: " /command/svc -u "/service/${prog}" RETVAL=$? if [ $RETVAL = 0 ]; then sleep 2 echo " [ OK ]"; else echo " [ ERROR ]"; fi echo return $RETVAL } stop() { echo -n $"Stopping ${prog}: " /command/svc -d "/service/${prog}" RETVAL=$? if [ $RETVAL = 0 ]; then sleep 2 echo " [ OK ]"; else echo " [ ERROR ]"; fi echo return $RETVAL } status() { /command/svstat "/service/${prog}" } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status "${prog}" RETVAL=$? ;; restart) stop start ;; *) echo $"Usage: $0 {start|stop|restart|status}" exit 1 esac exit $RETVAL