]> git.pld-linux.org Git - packages/asterisk.git/blob - asterisk.init
- RETVAL initial setting
[packages/asterisk.git] / asterisk.init
1 #!/bin/sh
2 #
3 # asterix       This shell script takes care of starting and stopping
4 #               Asterisk PBX
5 #
6 # chkconfig:    345 90 25
7 #
8 # description:  Asterisk is an Open Source PBX and telephony development platform that
9 #               can both replace a conventional PBX and act as a platform for
10 #               developing custom telephony applications for delivering dynamic
11 #               content over a telephone similarly to how one can deliver dynamic
12 #               content through a web browser using CGI and a web server.
13 #               
14 # pidfile:      /var/run/asterisk.pid
15 # config:       /etc/asterisk/asterisk.conf
16
17
18 # Source function library
19 . /etc/rc.d/init.d/functions
20
21 # Get network config
22 . /etc/sysconfig/network
23
24 # Get service config
25 [ -f /etc/sysconfig/asterisk ] && . /etc/sysconfig/asterisk
26
27 # Check that networking is up.
28 if is_yes "${NETWORKING}"; then
29         if [ ! -f /var/lock/subsys/network ]; then
30                 msg_network_down Asterisk
31                 exit 1
32         fi
33 else
34         exit 0
35 fi
36
37 # Sanity check
38 [ -f /etc/asterisk/asterisk.conf ] || exit 0
39
40 RETVAL=0
41 # See how we were called.
42 case "$1" in
43   start)
44         # Check if the service is already running?
45         if [ ! -f /var/lock/subsys/asterisk ]; then
46                 msg_starting Asterisk
47                 daemon $SERVICE_RUN_NICE_LEVEL asterisk $ASTERISK_OPTS
48                 RETVAL=$?
49                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk
50         else
51                 msg_already_running Asterisk
52         fi
53         ;;
54   stop)
55         # Stop daemons.
56         if [ -f /var/lock/subsys/asterisk ]; then
57                 msg_stopping Asterisk
58                 killproc asterisk
59                 rm -f /var/lock/subsys/asterisk >/dev/null 2>&1
60         else
61                 msg_not_running Asterisk
62         fi
63         ;;
64   restart|force-reload)
65         $0 stop
66         $0 start
67         exit $?
68         ;;
69 #  reload)
70         # Should be some better way...
71 #       $0 restart
72 #       if [ -f /var/lock/subsys/ ]; then
73 #               msg_reloading Asterisk
74 #               busy
75 #               ok
76 #       else
77 #               msg_not_running Asterisk
78 #               exit 1
79 #       fi
80 #       ;;
81   status)
82         status asterisk
83         exit $?
84         ;;
85   *)
86         msg_usage "$0 {start|stop|restart|force-reload|status}"
87         exit 3
88 esac
89
90 exit $RETVAL
This page took 0.028205 seconds and 4 git commands to generate.