set ASTVARRUNDIR=$(localstatedir)/run/asterisk as default path

When running asterisk as non-root and without this patch the pidfile wants
to go into /var/run/asterisk.pid. This directory is not writable for
the non-root user and changing permissions is not an option.
Putting it in /var/run/asterisk/asterisk.pid makes it possible
to set permissions on the /var/run/asterisk dir so everything
works as it should be.

Patched committed is based on pabelanger's patch.

(closes issue #13153)
Reported by: pabelanger
Patches:
      2009012900_bug13153-nonrootscripts.diff.txt uploaded by mvanbaak (license 7)

Review: http://reviewboard.digium.com/r/139/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@177852 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Michiel van Baak
2009-02-21 13:13:35 +00:00
parent d9eb973a3d
commit 5b497da128
4 changed files with 47 additions and 22 deletions

View File

@@ -21,7 +21,9 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=asterisk
DESC="Asterisk PBX"
# Full path to asterisk binary
DAEMON=/usr/sbin/asterisk
DAEMON=__ASTERISK_SBIN_DIR__/asterisk
ASTVARRUNDIR=__ASTERISK_VARRUN_DIR__
ASTETCDIR=__ASTERISK_ETC_DIR__
TRUE=/bin/true
# Uncomment this ONLY if you know what you are doing.
@@ -42,8 +44,8 @@ if ! [ -x $DAEMON ] ; then
exit 0
fi
if ! [ -d /etc/asterisk ] ; then
echo "ERROR: /etc/asterisk directory not found"
if ! [ -d $ASTETCDIR ] ; then
echo "ERROR: $ASTETCDIR directory not found"
exit 0
fi
@@ -61,12 +63,18 @@ case "$1" in
fi
log_begin_msg "Starting $DESC: $NAME"
if [ $AST_USER ] ; then
ASTARGS="-U $AST_USER"
fi
if [ $AST_GROUP ] ; then
ASTARGS="$ASTARGS -G $AST_GROUP"
fi
if [ ! -d $ASTVARRUNDIR ]; then
mkdir -p $ASTVARRUNDIR
fi
if [ $AST_USER ] ; then
ASTARGS="-U $AST_USER"
chown $AST_USER $ASTVARRUNDIR
fi
if [ $AST_GROUP ] ; then
ASTARGS="$ASTARGS -G $AST_GROUP"
chown $AST_GROUP $ASTVARRUNDIR
fi
# "start-stop-daemon --oknodo" returns 0 even if Asterisk was already running (as LSB expects):
start-stop-daemon --start --oknodo --exec $DAEMON -- $ASTARGS
log_end_msg $?