--- packaging/fedora/openser.init.orig 2009-11-16 14:52:34.034758160 +0300
+++ packaging/fedora/openser.init 2009-11-16 14:57:03.860757492 +0300
@@ -12,28 +12,50 @@
# Source function library.
. /etc/rc.d/init.d/functions
-oser=/usr/sbin/openser
prog=openser
-RETVAL=0
+oser=/usr/sbin/$prog
+pidfile="/var/run/$prog.pid"
+lockfile="/var/lock/subsys/$prog"
+configfile="/etc/$prog/$prog.cfg"
+
+OPTIONS=""
[ -f /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+RETVAL=0
+
start() {
echo -n $"Starting $prog: "
+
+ # check whether OpenSER was already started
+ if status $prog > /dev/null 2>&1 ; then
+ echo -n "already running" && warning && echo
+ return 0
+ fi
+
# there is something at end of this output which is needed to
# report proper [ OK ] status in Fedora scripts
- daemon $oser $OPTIONS 2>/dev/null | tail -1
+ daemon $oser -P $pidfile -f $configfile $OPTIONS 2>/dev/null | tail -1
RETVAL=$?
echo
- [ $RETVAL = 0 ] && touch /var/lock/subsys/$prog
+ [ $RETVAL = 0 ] && touch $lockfile
+ return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
- killproc $oser
+
+ # check whether OpenSER is running
+ if ! status $prog > /dev/null 2>&1 ; then
+ echo -n "not running" && warning && echo
+ return 0
+ fi
+
+ killproc $prog 2> /dev/null
RETVAL=$?
echo
- [ $RETVAL = 0 ] && rm -f /var/lock/subsys/$prog /var/run/$prog.pid
+ [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
+ return $RETVAL
}
# See how we were called.
@@ -45,22 +67,22 @@
stop
;;
status)
- status $oser
+ status $prog
RETVAL=$?
;;
- restart)
+ restart|force-reload)
stop
start
;;
- condrestart)
- if [ -f /var/run/openser.pid ] ; then
+ condrestart|try-restart)
+ if [ -f $pidfile ] ; then
stop
start
fi
;;
*)
- echo $"Usage: $prog {start|stop|restart|condrestart|status|help}"
- exit 1
+ echo $"Usage: $prog {start|stop|restart|condrestart|status}"
+ RETVAL=2
esac
exit $RETVAL