mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-16 19:50:19 +01:00
network/asterisk: create piddir during init
This imports the contrib/init.d/rc.slackware.asterisk from the upstream asterisk repo (with a change that we had been doing afterward) Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
parent
b42e55f08c
commit
7c8ad5caee
2 changed files with 68 additions and 5 deletions
|
@ -244,17 +244,16 @@ for i in \
|
|||
done
|
||||
|
||||
mkdir -p $PKG/etc/rc.d
|
||||
install -m 0755 contrib/init.d/rc.slackware.asterisk $PKG/etc/rc.d/rc.asterisk.new
|
||||
|
||||
# Fix pid file location in rc script
|
||||
sed -i 's/asterisk.pid/asterisk\/asterisk.pid/' $PKG/etc/rc.d/rc.asterisk.new
|
||||
sed $CWD/rc.asterisk.new \
|
||||
-e "s,@ASTERISKUSR@,$ASTERISKUSR,g" \
|
||||
-e "s,@ASTERISKGRP@,$ASTERISKGRP,g" \
|
||||
> $PKG/etc/rc.d/rc.asterisk.new
|
||||
|
||||
# Set file ownership
|
||||
chown -R $ASTERISKUSR:$ASTERISKGRP $PKG/usr/lib${LIBDIRSUFFIX}
|
||||
chown -R $ASTERISKUSR:$ASTERISKGRP $PKG/var/lib/asterisk
|
||||
chown -R $ASTERISKUSR:$ASTERISKGRP $PKG/var/spool/asterisk
|
||||
chown -R $ASTERISKUSR:$ASTERISKGRP $PKG/var/log/asterisk
|
||||
chown -R $ASTERISKUSR:$ASTERISKGRP $PKG/var/run/asterisk
|
||||
chown $ASTERISKUSR:$ASTERISKGRP $PKG/usr/sbin/asterisk
|
||||
|
||||
# The voicemail config file needs to writeable by the asterisk user
|
||||
|
|
64
network/asterisk/rc.asterisk.new
Normal file
64
network/asterisk/rc.asterisk.new
Normal file
|
@ -0,0 +1,64 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start/stop/restart Asterisk PBX
|
||||
#
|
||||
# Version: 1.0 - Paul Belanger <pabelanger@gmail.com>
|
||||
#
|
||||
# 03.29.2005 - Initial Version
|
||||
#
|
||||
# $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
|
||||
|
||||
asterisk_start() {
|
||||
if [ -x /usr/sbin/asterisk ]; then
|
||||
# Check if Asterisk is already running. If it is, then bug out, because
|
||||
# starting safe_asterisk when Asterisk is running is very bad.
|
||||
VERSION=`/usr/sbin/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
|
||||
|
||||
echo "Starting Asterisk /usr/sbin/asterisk"
|
||||
mkdir -p /var/run/asterisk
|
||||
chown @ASTERISKUSR@:@ASTERISKGRP@ /var/run/asterisk
|
||||
/usr/sbin/asterisk
|
||||
fi
|
||||
}
|
||||
|
||||
asterisk_stop() {
|
||||
# If there is no PID file, ignore this request...
|
||||
if [ -r /var/run/asterisk/asterisk.pid ]; then
|
||||
killall asterisk
|
||||
fi
|
||||
}
|
||||
|
||||
asterisk_restart() {
|
||||
asterisk_stop
|
||||
asterisk_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
asterisk_start
|
||||
;;
|
||||
'stop')
|
||||
asterisk_stop
|
||||
;;
|
||||
'restart')
|
||||
asterisk_restart
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart" ;;
|
||||
esac
|
Loading…
Reference in a new issue