You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

92 lines
2.0 KiB

#!/bin/bash
#
# /etc/rc.d/init.d/freeswitch
#
# The FreeSWITCH Open Source Voice Platform
#
# chkconfig: 345 89 14
# description: Starts and stops the freeswitch server daemon
# processname: freeswitch
# config: /etc/kazoo/freeswitch/freeswitch.xml
# pidfile: /var/run/freeswitch/kazoo-freeswitch.pid
#
RETVAL=0
PID_FILE=${PID_FILE:-/var/run/freeswitch/kazoo-freeswitch.pid}
LOCK_FILE=/var/lock/subsys/kazoo-freeswitch
. /etc/init.d/functions
start() {
echo -n "Starting FreeSWITCH: "
if [ -e ${LOCK_FILE} ]; then
if [ -e ${PID_FILE} ] && [ -e /proc/`cat ${PID_FILE}` ]; then
failure $"FreeSWITCH is already running.";
echo
return 1
fi
fi
/usr/sbin/kazoo-freeswitch prepare >/dev/null 2>&1
daemon --pidfile ${PID_FILE} "/usr/sbin/kazoo-freeswitch background >/dev/null 2>&1"
RETVAL=$?
if [ ${RETVAL} -eq 0 ]; then
touch ${LOCK_FILE}
success $"OK"
echo
else
failure $"FreeSWITCH is already running or failed to start!"
echo
fi
}
stop() {
echo -n "Shutting down FreeSWITCH: "
if [ ! -e ${LOCK_FILE} ]; then
failure $"Unable to stop FreeSWITCH: FreeSWITCH is not running."
echo
return 1;
fi
/usr/sbin/kazoo-freeswitch stop >/dev/null 2>&1
RETVAL=$?
if [ ${RETVAL} -eq 0 ]; then
rm -f ${LOCK_FILE} ${pidfile}
success $"OK"
echo
else
failure $"FreeSWITCH is still running!"
echo
fi
}
status() {
/usr/sbin/kazoo-freeswitch status
RETVAL=$?
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart|reload)
restart
;;
condrestart)
[ ! -e ${LOCK_FILE} ] && restart
;;
*)
echo $"Usage: $0 (start|stop|restart|status)"
RETVAL=1
esac
exit ${RETVAL}