8637556aa58cb5d12771786cc161126d9760d6d8
[openwrt/svn-archive/archive.git] / net / freeswitch / files / freeswitch.init
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3 START=90
4
5 DEFAULT=/etc/default/freeswitch
6 OPTIONS=""
7
8 boot() {
9 # Do nothing on boot
10 exit 0
11 }
12
13 start() {
14 [ -f $DEFAULT ] && . $DEFAULT
15 mkdir -p $FS_DIR_DB
16 mkdir -p $FS_DIR_LOG
17 ulimit -s 240
18 $FS_DIR/usr/bin/freeswitch $OPTIONS -nc
19 }
20
21 stop() {
22 [ -f $DEFAULT ] && . $DEFAULT
23 $FS_DIR/usr/bin/freeswitch $OPTIONS -stop
24 }
25
26 restart() {
27 # stopping freeswitch is non-blocking, so we wait until freeswitch's
28 # event socket is down, and then wait an additional ten seconds so that
29 # freeswitch should be completely shutdown before we start it again
30 local retval
31 stop
32 fs_cli -x status >/dev/null 2>&1
33 retval=$?
34 while [ $retval -eq 0 ]; do sleep 1; fs_cli -x status >/dev/null 2>&1; retval=$?; done
35 sleep 10
36 start
37 }
38