From 4dc715811141dc530c109387515d73cda893db4f Mon Sep 17 00:00:00 2001 From: Jiri Slachta Date: Sun, 2 Feb 2014 02:07:11 +0100 Subject: [PATCH] asterisk-1.8.x: fix init script Signed-off-by: Jiri Slachta --- net/asterisk-1.8.x/files/asterisk.init | 38 ++++++++++++++++++-------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/net/asterisk-1.8.x/files/asterisk.init b/net/asterisk-1.8.x/files/asterisk.init index 53bf4af..8761561 100644 --- a/net/asterisk-1.8.x/files/asterisk.init +++ b/net/asterisk-1.8.x/files/asterisk.init @@ -1,21 +1,35 @@ #!/bin/sh /etc/rc.common -# Copyright (C) 2008 OpenWrt.org -START=50 +# Copyright (C) 2013 OpenWrt.org +. /lib/functions/service.sh + +START=99 +APP=asterisk +OPTIONS= DEST= -DEFAULT=$DEST/etc/default/asterisk -OPTIONS="" +DEFAULT=$DEST/etc/default/$APP +BIN_FILE=$DEST/usr/sbin/$APP +PID_FILE=$DEST/var/run/$APP/$APP.pid start() { - [ -f $DEFAULT ] && . $DEFAULT - [ -d $DEST/var/run/asterisk ] || mkdir -p $DEST/var/run/asterisk - [ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk - [ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk - [ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk - [ -h $DEST/usr/lib/asterisk/astdb ] || ln -sf /var/spool/asterisk/astdb $DEST/usr/lib/asterisk/astdb - $DEST/usr/sbin/asterisk $OPTIONS + [ -f $DEFAULT ] && . $DEFAULT + [ -d $DEST/var/run/asterisk ] || mkdir -p $DEST/var/run/asterisk + [ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk + [ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk + [ -d $DEST/var/lib ] || mkdir -p $DEST/var/lib + [ -h $DEST/var/lib/asterisk ] || ln -s /usr/lib/asterisk /var/lib/asterisk + [ -d $DEST/var/lib/asterisk/keys ] || mkdir -p $DEST/var/lib/asterisk/keys + + SERVICE_PID_FILE="/var/run/asterisk/asterisk.pid" \ + service_start $BIN_FILE $OPTIONS } stop() { - [ -f $DEST/var/run/asterisk/asterisk.pid ] && kill $(cat $DEST/var/run/asterisk/asterisk.pid) >/dev/null 2>&1 + SERVICE_PID_FILE="/var/run/asterisk/asterisk.pid" \ + service_stop $BIN_FILE +} + +reload() { + SERVICE_PID_FILE="/var/run/asterisk/asterisk.pid" \ + service_reload $BIN_FILE } -- 2.30.2