]> git.ipfire.org Git - thirdparty/freeswitch.git/blob - build/fs_ivrd.init.redhat
Merge branch 'master' of ssh://git.freeswitch.org:222/freeswitch
[thirdparty/freeswitch.git] / build / fs_ivrd.init.redhat
1 #!/bin/bash
2 #
3 # /etc/rc.d/init.d/fs_ivrd
4 #
5 # The FreeSwitch Open Source Voice Platform
6 #
7 # chkconfig: 345 89 14
8 # description: Starts and stops the fs_ivrd server daemon
9 # processname: fs_ivrd
10 # pidfile: /usr/local/fs_ivrd/run/fs_ivrd.pid
11 #
12
13 # Source function library.
14 . /etc/init.d/functions
15
16 PROG_NAME=fs_ivrd
17 PID_FILE=${PID_FILE-/usr/local/freeswitch/run/fs_ivrd.pid}
18 #FS_USER=${FS_USER-freeswitch}
19 FS_USER=${FS_USER-root}
20 FS_FILE=${FS_FILE-/usr/local/freeswitch/bin/fs_ivrd}
21 FS_HOME=${FS_HOME-/usr/local/freeswitch}
22 LOCK_FILE=/var/lock/subsys/fs_ivrd
23 IVRD_ARGS="-h localhost -p 9090"
24 RETVAL=0
25
26 # Source options file
27 if [ -f /etc/sysconfig/fs_ivrd ]; then
28 . /etc/sysconfig/fs_ivrd
29 fi
30
31 # <define any local shell functions used by the code that follows>
32
33 start() {
34 echo -n "Starting $PROG_NAME: "
35 if [ -e $LOCK_FILE ]; then
36 if [ -e $PID_FILE ] && [ -e /proc/`cat $PID_FILE` ]; then
37 echo
38 echo -n $"$PROG_NAME is already running.";
39 failure $"$PROG_NAME is already running.";
40 echo
41 return 1
42 fi
43 fi
44 cd $FS_HOME
45 daemon --user $FS_USER --pidfile $PID_FILE "$FS_FILE $IVRD_ARGS $IVRD_PARAMS >/dev/null 2>&1 &"
46 echo
47 RETVAL=$?
48 [ $RETVAL -eq 0 ] && touch $LOCK_FILE;
49 echo
50 return $RETVAL
51 }
52
53 stop() {
54 echo -n "Shutting down $PROG_NAME: "
55 if [ ! -e $LOCK_FILE ]; then
56 echo
57 echo -n $"cannot stop $PROG_NAME: $PROG_NAME is not running."
58 failure $"cannot stop $PROG_NAME: $PROG_NAME is not running."
59 echo
60 return 1;
61 fi
62 cd $FS_HOME
63 $FS_FILE -stop > /dev/null 2>&1
64 killproc $PROG_NAME
65 RETVAL=$?
66 echo
67 [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE;
68 return $RETVAL
69 }
70
71 rhstatus() {
72 status $PROG_NAME;
73 }
74
75 case "$1" in
76 start)
77 start
78 ;;
79 stop)
80 stop
81 ;;
82 status)
83 status $PROG_NAME
84 RETVAL=$?
85 ;;
86 restart)
87 stop
88 start
89 ;;
90 reload)
91 # <cause the service configuration to be reread, either with
92 # kill -HUP or by restarting the daemons, in a manner similar
93 # to restart above>
94 ;;
95 condrestart)
96 ;;
97 *)
98 echo "Usage: $PROG_NAME {start|stop|status|restart}"
99 exit 1
100 ;;
101 esac
102 exit $RETVAL