2007-12-01 12:24:45 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# /etc/rc.d/init.d/freeswitch
|
|
|
|
#
|
|
|
|
# The FreeSwitch Open Source Voice Platform
|
|
|
|
#
|
2008-03-19 13:21:30 -04:00
|
|
|
# chkconfig: 345 89 14
|
2008-03-19 12:56:24 -04:00
|
|
|
# description: Starts and stops the freeswitch server daemon
|
2007-12-01 12:24:45 -05:00
|
|
|
# processname: freeswitch
|
|
|
|
# config: /opt/freeswitch/conf/freeswitch.conf
|
2007-12-05 19:11:07 -05:00
|
|
|
# pidfile: /opt/freeswitch/log/freeswitch.pid
|
2007-12-01 12:24:45 -05:00
|
|
|
#
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/init.d/functions
|
|
|
|
|
2008-03-19 12:56:24 -04:00
|
|
|
PROG_NAME=freeswitch
|
|
|
|
PID_FILE=/opt/freeswitch/log/freeswitch.pid
|
2007-12-01 12:24:45 -05:00
|
|
|
FS_USER=freeswitch
|
2008-03-19 11:18:19 -04:00
|
|
|
FS_FILE=/opt/freeswitch/bin/freeswitch
|
2008-03-19 12:56:24 -04:00
|
|
|
LOCK_FILE=/var/lock/subsys/freeswitch
|
2008-03-19 13:37:18 -04:00
|
|
|
FREESWITCH_ARGS="-nc"
|
2007-12-01 12:24:45 -05:00
|
|
|
RETVAL=0
|
|
|
|
|
2008-03-19 13:48:05 -04:00
|
|
|
# Source options file
|
|
|
|
if [ -f /etc/sysconfig/freeswitch ]; then
|
|
|
|
. /etc/sysconfig/freeswitch
|
|
|
|
fi
|
|
|
|
|
2007-12-01 12:24:45 -05:00
|
|
|
# <define any local shell functions used by the code that follows>
|
|
|
|
|
|
|
|
start() {
|
2008-03-19 12:56:24 -04:00
|
|
|
echo -n "Starting $PROG_NAME: "
|
|
|
|
if [ -e $LOCK_FILE ]; then
|
2008-03-19 13:37:18 -04:00
|
|
|
if [ -e $PID_FILE ] && [ -e /proc/`cat $PID_FILE` ]; then
|
2008-03-19 13:21:30 -04:00
|
|
|
echo
|
|
|
|
echo -n $"$PROG_NAME is already running.";
|
|
|
|
failure $"$PROG_NAME is already running.";
|
2007-12-01 12:24:45 -05:00
|
|
|
echo
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-03-19 13:37:18 -04:00
|
|
|
daemon --user $FS_USER --pidfile $PID_FILE "$FS_FILE $FREESWITCH_ARGS $FREESWITCH_PARAMS >/dev/null 2>&1"
|
2008-03-19 11:18:19 -04:00
|
|
|
echo
|
|
|
|
RETVAL=$?
|
2008-03-19 12:56:24 -04:00
|
|
|
[ $RETVAL -eq 0 ] && touch $LOCK_FILE;
|
2008-03-19 13:37:18 -04:00
|
|
|
echo
|
2007-12-01 12:24:45 -05:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
2008-03-19 12:56:24 -04:00
|
|
|
echo -n "Shutting down $PROG_NAME: "
|
|
|
|
if [ ! -e $LOCK_FILE ]; then
|
2008-03-19 13:21:30 -04:00
|
|
|
echo
|
2008-03-19 12:56:24 -04:00
|
|
|
echo -n $"cannot stop $PROG_NAME: $PROG_NAME is not running."
|
|
|
|
failure $"cannot stop $PROG_NAME: $PROG_NAME is not running."
|
2007-12-01 12:24:45 -05:00
|
|
|
echo
|
|
|
|
return 1;
|
|
|
|
fi
|
2008-03-19 13:21:30 -04:00
|
|
|
$FS_FILE -stop > /dev/null 2>&1
|
|
|
|
killproc $PROG_NAME
|
2007-12-01 12:24:45 -05:00
|
|
|
RETVAL=$?
|
|
|
|
echo
|
2008-03-19 12:56:24 -04:00
|
|
|
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE;
|
2007-12-01 12:24:45 -05:00
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
rhstatus() {
|
2008-03-19 12:56:24 -04:00
|
|
|
status $PROG_NAME;
|
2007-12-01 12:24:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
|
|
|
status)
|
2008-03-19 12:56:24 -04:00
|
|
|
status $PROG_NAME
|
2007-12-01 12:24:45 -05:00
|
|
|
RETVAL=$?
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
# <cause the service configuration to be reread, either with
|
|
|
|
# kill -HUP or by restarting the daemons, in a manner similar
|
|
|
|
# to restart above>
|
|
|
|
;;
|
|
|
|
condrestart)
|
2008-03-19 12:56:24 -04:00
|
|
|
[ -f $PID_FILE ] && restart || :
|
2007-12-01 12:24:45 -05:00
|
|
|
;;
|
|
|
|
*)
|
2008-03-20 09:42:42 -04:00
|
|
|
echo "Usage: $PROG_NAME {start|stop|status|reload|restart}"
|
2007-12-01 12:24:45 -05:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
exit $RETVAL
|