]> git.pld-linux.org Git - packages/asterisk.git/blame - asterisk.init
- allow some actions when network is down
[packages/asterisk.git] / asterisk.init
CommitLineData
68da8345
PG
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.
fc0a4ecb 28if is_yes "${NETWORKING}"; then
07879ea3 29 if [ ! -f /var/lock/subsys/network -a != stop -a != status ]; then
fc0a4ecb 30 msg_network_down Asterisk
31 exit 1
32 fi
33else
34 exit 0
68da8345
PG
35fi
36
37# Sanity check
38[ -f /etc/asterisk/asterisk.conf ] || exit 0
39
f4545cf2 40RETVAL=0
68da8345
PG
41# See how we were called.
42case "$1" in
43 start)
44 # Check if the service is already running?
45 if [ ! -f /var/lock/subsys/asterisk ]; then
46 msg_starting Asterisk
68da8345
PG
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
68da8345
PG
62 fi
63 ;;
fc0a4ecb 64 restart|force-reload)
68da8345
PG
65 $0 stop
66 $0 start
fc0a4ecb 67 exit $?
68da8345 68 ;;
fc0a4ecb 69# reload)
68da8345 70 # Should be some better way...
fc0a4ecb 71# $0 restart
72# if [ -f /var/lock/subsys/ ]; then
68da8345
PG
73# msg_reloading Asterisk
74# busy
75# ok
76# else
77# msg_not_running Asterisk
78# exit 1
79# fi
fc0a4ecb 80# ;;
68da8345
PG
81 status)
82 status asterisk
83 exit $?
84 ;;
85 *)
fc0a4ecb 86 msg_usage "$0 {start|stop|restart|force-reload|status}"
87 exit 3
68da8345
PG
88esac
89
90exit $RETVAL
This page took 0.04913 seconds and 4 git commands to generate.