#!/bin/sh # # Starts xaseco2 script # # chkconfig: 345 98 02 # description: XAseco2 is the TM2C server controller # # Author: Frans P. de Vries MYDESC="XASECO2 server controller" MYUSER=tm2 MYPATH=/home/$MYUSER/xaseco2 MYNAME=`basename $0 | sed 's/^[SK][0-9][0-9]//'` MYPROC="xaseco2.php TM2" DAEMON=$MYPATH/XAseco2.sh MYPIDF=/var/run/$MYNAME.pid MYLOCK=/var/lock/subsys/$MYNAME # Source function library. . /etc/rc.d/init.d/functions # Make sure the daemon directory is in the front of the path list PATH=$MYPATH:$PATH # See how we were called. case "$1" in start) # Change to package directory so config paths can be relative cd $MYPATH || \ { echo "$0: Can't cd to $MYPATH" ; exit 1 ; } # Make sure the daemon exists [ -f $DAEMON ] || \ { echo "$0: Daemon not found: $DAEMON" ; exit 1 ; } # See if we are already running # Note: kill -0 _PID_ # returns true if process _PID_ is alive and accepting signals. [ -f $MYPIDF ] && kill -0 `cat $MYPIDF` 2>/dev/null && \ { echo "$0: $MYPIDF exists and process is running" ; exit 1 ; } echo -n "Starting $MYDESC: " echo -n "$MYNAME " su -l -c "$DAEMON &" $MYUSER > $MYPIDF chown $MYUSER.tm $MYPIDF echo touch $MYLOCK ;; stop) echo -n "Shutting down $MYDESC: " echo -n "$MYNAME " killproc $MYNAME rm -f $MYPIDF echo rm -f $MYLOCK ;; status) pid=`ps ax | grep "$MYPROC\>" | grep -v grep | awk '{print $1}'` if [ -n "$pid" ]; then echo "$MYPROC (pid $pid) is running..." exit 0 fi status $MYNAME ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|status|restart}" exit 1 esac exit 0