#! /bin/bash PIDFILE="/var/run/smsdaemon.pid" function start_d { /usr/local/sbin/smsdaemon --daemon } function stop_d { if [ -f $PIDFILE ] ; then PID=`cat $PIDFILE` LINES=`ps aux | grep smsdaemon | grep $PID | wc -l` if [ "$LINES" == "1" ] ; then kill $PID else echo "pidfile found -- but smsdaemon not running" fi else echo "PIDFILE not found !!!!!!!!" fi } function status_d { if [ -f $PIDFILE ] ; then PID=`cat $PIDFILE` LINES=`ps aux | grep smsdaemon | grep $PID | wc -l` if [ "$LINES" == "1" ] ; then echo "smsdaemon running (pid=$PID)" else echo "pidfile found -- but smsdaemon not running" fi else echo "no pidfile - smsdaemon not started" fi } function reload_d { PID=`cat $PIDFILE` kill -HUP $PID } case $1 in "start") start_d ;; "stop") stop_d ;; "status") status_d ;; "reload") reload_d ;; "restart") stop_d sleep 5 start_d ;; *) echo "Usage $0 [start|stop|status|reload|restart]" ;; esac