~singpolyma/asterisk

ref: upstream/16.2.1_dfsg asterisk/contrib/init.d/rc.gentoo.asterisk -rwxr-xr-x 1.0 KiB
fe6d69c0Stephen Paul Weber import-tar 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/sbin/runscript
# $Id$

### BEGIN INIT INFO
# Provides:		asterisk
# Required-Start:    $network $syslog $named $local_fs $remote_fs
# Required-Stop:     $network $syslog $named $local_fs $remote_fs
# Should-Start:      dahdi misdn lcr wanrouter mysql postgresql
# Should-Stop:       dahdi misdn lcr wanrouter mysql postgresql
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	Asterisk PBX
# Description:		the Asterisk Open Source PBX
### END INIT INFO

depend() {
	need net logger
}

start() {
	# Check if Asterisk is already running.  If it is, then bug out, because
	# starting safe_asterisk when Asterisk is running is very bad.
	VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version' 2>/dev/null`
	if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
		echo "Asterisk is already running.  $0 will exit now."
		exit 1
	fi

	ebegin "Starting Asterisk"
	/usr/sbin/asterisk
	eend $? "Failed to start Asterisk"
}

stop() {
	ebegin "Stopping Asterisk"
	kill $(cat /var/run/asterisk.pid)
	eend $? "Failed to stop Asterisk"
}