#!/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: /opt/freeswitch/conf/freeswitch.conf # pidfile: /opt/freeswitch/log/freeswitch.pid # export PATH=$PATH:/opt/freeswitch/bin # Source function library. . /etc/init.d/functions # Source options file if [ -f /etc/sysconfig/freeswitch ]; then . /etc/sysconfig/freeswitch fi PROG_NAME=freeswitch PID_FILE=/opt/freeswitch/log/freeswitch.pid FS_USER=freeswitch FS_FILE=/opt/freeswitch/bin/freeswitch LOCK_FILE=/var/lock/subsys/freeswitch RETVAL=0 # start() { echo -n "Starting $PROG_NAME: " if [ -e $LOCK_FILE ]; then if [ -e $PID_FILE ] && [ -e /proc/`$PID_FILE` ]; then echo echo -n $"$PROG_NAME is already running."; failure $"$PROG_NAME is already running."; echo return 1 fi fi daemon --user $FS_USER --pidfile $PID_FILE "$FS_FILE $FREESWITCH_PARAMS >/dev/null 2>&1" echo RETVAL=$? [ $RETVAL -eq 0 ] && touch $LOCK_FILE; return $RETVAL } stop() { echo -n "Shutting down $PROG_NAME: " if [ ! -e $LOCK_FILE ]; then echo echo -n $"cannot stop $PROG_NAME: $PROG_NAME is not running." failure $"cannot stop $PROG_NAME: $PROG_NAME is not running." echo return 1; fi $FS_FILE -stop > /dev/null 2>&1 killproc $PROG_NAME RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE; return $RETVAL } rhstatus() { status $PROG_NAME; } case "$1" in start) start ;; stop) stop ;; status) status $PROG_NAME RETVAL=$? ;; restart) stop start ;; reload) # ;; condrestart) [ -f $PID_FILE ] && restart || : ;; *) echo "Usage: $PROG_NAME {start|stop|status|reload|restart" exit 1 ;; esac exit $RETVAL