catch read/write errors and exit if they occur (issue #6721)
[asterisk/asterisk.git] / contrib / init.d / rc.slackware.asterisk
1 #!/bin/sh
2 #
3 # Start/stop/restart Asterisk PBX
4 #
5 # Version: 1.0 - Paul Belanger <pabelanger@gmail.com>
6 #
7 # 03.29.2005 - Initial Version
8 #
9
10 asterisk_start() {
11    if [ -x /usr/sbin/asterisk ]; then
12       echo "Starting Asterisk   /usr/sbin/asterisk"
13       /usr/sbin/asterisk
14    fi
15 }
16
17 asterisk_stop() {
18     # If there is no PID file, ignore this request...
19     if [ -r /var/run/asterisk.pid ]; then
20       killall asterisk
21     fi
22 }
23
24 asterisk_restart() {
25    asterisk_stop
26    asterisk_start
27 }
28
29 case "$1" in
30    'start')
31       asterisk_start
32       ;;
33    'stop')
34       asterisk_stop
35       ;;
36    'restart')
37       asterisk_restart
38       ;;
39    *)
40       echo "usage $0 start|stop|restart" ;;
41 esac
42