updated on Wed Jan 25 16:08:47 UTC 2012
[aur-mirror.git] / freeswitch / freeswitch.rc.conf
blob1ad6363a708cb128d77e5ec0c511a87c04aceb96
1 #!/bin/bash
3 daemon_name=freeswitch
5 . /etc/rc.conf
6 . /etc/rc.d/functions
7 . /etc/conf.d/$daemon_name
8 get_pid() {
9 pidof -o %PPID $daemon_name
12 case "$1" in
13 fgstart)
14 stat_busy "Starting $daemon_name daemon in the foreground"
15 stat_done
16 ulimit -s 240
17 exec su -c "/usr/bin/freeswitch $FREESWITCH_OPTS -nf" freeswitch
19 start)
20 stat_busy "Starting $daemon_name daemon"
22 PID=$(get_pid)
23 if [ -z "$PID" ]; then
24 [ -f /var/run/$daemon_name.pid ] && rm -f /var/run/$daemon_name.pid
25 # RUN
26 ulimit -s 240
27 su -c "/usr/bin/freeswitch $FREESWITCH_OPTS" freeswitch
29 if [ $? -gt 0 ]; then
30 stat_fail
31 exit 1
32 else
33 echo $(get_pid) > /var/run/$daemon_name.pid
34 add_daemon $daemon_name
35 stat_done
37 else
38 stat_fail
39 exit 1
43 stop)
44 stat_busy "Stopping $daemon_name daemon"
45 PID=$(get_pid)
46 # KILL
47 [ ! -z "$PID" ] && kill $PID &> /dev/null
49 if [ $? -gt 0 ]; then
50 stat_fail
51 exit 1
52 else
53 rm -f /var/run/$daemon_name.pid &> /dev/null
54 rm_daemon $daemon_name
55 stat_done
59 restart)
60 $0 stop
61 sleep 3
62 $0 start
65 status)
66 stat_busy "Checking $daemon_name status";
67 ck_status $daemon_name
68 fs_cli -x 'status'
72 echo "usage: $0 {start|stop|restart|status|fgstart}"
73 esac
75 exit 0