PKGBUILDs/community/opensips/opensips.init
2009-10-09 21:15:33 -05:00

50 lines
788 B
Bash

#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
BINNAME=opensips
OSRDIR=/usr/sbin
OPENSIPS=$OSRDIR/$BINNAME
TMPDIR=/var/tmp
CORE=$TMPDIR/core
ETC=/etc/opensips/opensips.cfg
PIDFILE=/var/run/opensips.pid
case "$1" in
start)
stat_busy "Starting OpenSIPS server"
cd $TMPDIR
$OPENSIPS -f $ETC -w $TMPDIR -P $PIDFILE 2>&1 > /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon opensips
stat_done
fi
;;
stop)
stat_busy "Stopping OpenSIPS server"
if [ -r $PIDFILE ]
then
cat $PIDFILE | xargs kill
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon opensips
stat_done
fi
else
stat_fail
fi
;;
restart)
$0 stop
sleep 3
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac