#! /bin/sh # $Id$ # $URL$ ### BEGIN INIT INFO # Provides: enrichmentserver # Required-Start: $syslog $named $network $time # Required-Stop: $syslog $named $network $time # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start enrichmentserver daemon # Description: Beter Zoeken & Vinden server ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=enrichmentserver DESC='enrichment server' DAEMON=/usr/bin/enrichmentserver.py CONFIG=/etc/enrichmentserver PYTHON=/usr/bin/python2.5 USER=enrich test -x $DAEMON || exit 0 test -e $CONFIG || exit 0 mkdir -p /var/run/enrichmentserver export LANG=en_US.UTF-8 # Include enrichmentserver defaults if available if [ -f /etc/default/enrichmentserver ] then . /etc/default/enrichmentserver fi command=$1 shift instances=$* instances() { case $instances in '') for c in $CONFIG/*.cfg do base=${c##*/} test -f "$c" && echo ${base%.cfg} done ;; *) echo "$instances" esac } start() { start-stop-daemon --start --quiet --pidfile /var/run/enrichmentserver/$1.pid --user ${USER%:*} --chuid $USER --background --make-pidfile --exec $PYTHON -- $DAEMON $DAEMON_OPTS $CONFIG/$1.cfg } stop() { start-stop-daemon --stop --quiet --pidfile /var/run/enrichmentserver/$1.pid --user ${USER%:*} --exec $PYTHON } isrunning() { start-stop-daemon --stop --test --quiet --pidfile /var/run/enrichmentserver/$1.pid --user ${USER%:*} --exec $PYTHON >/dev/null } case $command in start) echo -n "Starting $DESC:" done=' (none)' for i in $(instances) do done=. start $i echo -n " $i" done echo $done ;; stop) echo -n "Stopping $DESC:" done=' (none)' for i in $(instances) do done=. stop $i echo -n " $i" done echo $done ;; force-reload) # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart" except that it does nothing if the # daemon isn't already running. # check wether $DAEMON is running. If so, restart echo -n "Force-reloading $DESC:" done=' (none)' for i in $(instances) do if isrunning $i then done=. stop $i echo -n " $i" sleep 1 start $i fi done echo $done ;; restart) echo -n "Restarting $DESC:" done=' (none)' for i in $(instances) do done=. echo -n " $i" if isrunning $i then stop $i sleep 1 fi start $i done echo $done ;; status) for i in $(instances) do if ! isrunning $i then exit 1 fi done exit 0 ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0