#!/bin/bash USER=www-data GROUP=www-data HOST=127.0.0.1 PORT=9005 CGI_NAME=/usr/bin/mctxserv CGI_BASENAME=`basename $CGI_NAME` PID=/var/run/$CGI_BASENAME.pid DAEMON=/usr/bin/spawn-fcgi DAEMON_BASENAME=`basename $DAEMON` DAEMON_OPTS="-a $HOST -p $PORT -u $USER -g $GROUP -P $PID $CGI_NAME" #Test if daemon exists [ -x "$DAEMON" ] || (echo $DAEMON doesn\'t exist! && exit 1) #Test if cgi module exists [ -x "$CGI_NAME" ] || (echo $CGI_BASENAME doesn\'t exist! && exit 1) start() { echo -n "Starting FastCGI Daemon: " start-stop-daemon --start --quiet --pidfile $PID \ --exec $DAEMON -- $DAEMON_OPTS > /dev/null RETVAL=$? echo "$CGI_BASENAME." } stop() { echo -n "Stopping FastCGI Daemon: " start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PID RETVAL=$? echo "$CGI_BASENAME." } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; *) echo "Usage: mctxserv {start|stop|restart}" exit 1 ;; esac exit $RETVAL