[asterisk-commits] mvanbaak: trunk r177852 - in /trunk: ./ contrib/init.d/ contrib/scripts/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Feb 21 07:13:35 CST 2009
Author: mvanbaak
Date: Sat Feb 21 07:13:35 2009
New Revision: 177852
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=177852
Log:
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/
Modified:
trunk/Makefile
trunk/contrib/init.d/rc.archlinux.asterisk
trunk/contrib/init.d/rc.debian.asterisk
trunk/contrib/scripts/safe_asterisk
Modified: trunk/Makefile
URL: http://svn.digium.com/svn-view/asterisk/trunk/Makefile?view=diff&rev=177852&r1=177851&r2=177852
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Sat Feb 21 07:13:35 2009
@@ -146,7 +146,7 @@
ASTSBINDIR=$(sbindir)
ASTSPOOLDIR=$(localstatedir)/spool/asterisk
ASTLOGDIR=$(localstatedir)/log/asterisk
- ASTVARRUNDIR=$(localstatedir)/run
+ ASTVARRUNDIR=$(localstatedir)/run/asterisk
ASTMANDIR=$(mandir)
ifneq ($(findstring BSD,$(OSARCH)),)
ASTVARLIBDIR=$(prefix)/share/asterisk
@@ -805,22 +805,28 @@
config:
@if [ "${OSARCH}" = "linux-gnu" ]; then \
if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
- $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
+ cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR);s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
+ chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
elif [ -f /etc/debian_version ]; then \
- $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
+ cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR);s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
+ chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
elif [ -f /etc/gentoo-release ]; then \
- $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
+ cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR);s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
+ chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
- $(INSTALL) -m 755 contrib/init.d/rc.mandriva.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
+ cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR);s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
+ chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
- $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
+ cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR);s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
+ chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
elif [ -f /etc/arch-release -o -f /etc/arch-release ]; then \
- $(INSTALL) -m 755 contrib/init.d/rc.archlinux.asterisk $(DESTDIR)/etc/rc.d/asterisk; \
+ cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR);s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/asterisk ;\
+ chmod 755 $(DESTDIR)/etc/rc.d/asterisk;\
elif [ -f /etc/slackware-version ]; then \
echo "Slackware is not currently supported, although an init script does exist for it." \
else \
Modified: trunk/contrib/init.d/rc.archlinux.asterisk
URL: http://svn.digium.com/svn-view/asterisk/trunk/contrib/init.d/rc.archlinux.asterisk?view=diff&rev=177852&r1=177851&r2=177852
==============================================================================
--- trunk/contrib/init.d/rc.archlinux.asterisk (original)
+++ trunk/contrib/init.d/rc.archlinux.asterisk Sat Feb 21 07:13:35 2009
@@ -8,26 +8,31 @@
#
. /etc/rc.conf
. /etc/rc.d/functions
+DAEMON=__ASTERISK_SBIN_DIR__/asterisk
+ASTVARRUNDIR=__ASTERISK_VARRUN_DIR__
case "$1" in
start)
stat_busy "Starting Asterisk..."
- if [ -x /usr/sbin/asterisk ]; then
+ if [ ! -d $ASTVARRUNDIR ]; then
+ mkdir -p $ASTVARRUNDIR
+ fi
+ if [ -x $DAEMON ]; 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'`
+ VERSION=`${DAEMON} -rx 'core show version'`
if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
echo "Asterisk is already running. $0 will exit now."
exit 1
fi
- /usr/sbin/asterisk
+ ${DAEMON}
stat_done
fi
;;
stop)
- if [ -r /var/run/asterisk.pid ]; then
+ if [ -r ${ASTVARRUNDIR}/asterisk.pid ]; then
stat_busy "Stoping Asterisk..."
- asterisk -rx "core stop now" > /dev/null 2&>1
+ ${DAEMON} -rx "core stop now" > /dev/null 2&>1
if [ $? -gt 0 ]; then
stat_fail
else
Modified: trunk/contrib/init.d/rc.debian.asterisk
URL: http://svn.digium.com/svn-view/asterisk/trunk/contrib/init.d/rc.debian.asterisk?view=diff&rev=177852&r1=177851&r2=177852
==============================================================================
--- trunk/contrib/init.d/rc.debian.asterisk (original)
+++ trunk/contrib/init.d/rc.debian.asterisk Sat Feb 21 07:13:35 2009
@@ -21,7 +21,9 @@
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 @@
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 @@
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 $?
Modified: trunk/contrib/scripts/safe_asterisk
URL: http://svn.digium.com/svn-view/asterisk/trunk/contrib/scripts/safe_asterisk?view=diff&rev=177852&r1=177851&r2=177852
==============================================================================
--- trunk/contrib/scripts/safe_asterisk (original)
+++ trunk/contrib/scripts/safe_asterisk Sat Feb 21 07:13:35 2009
@@ -12,7 +12,8 @@
DUMPDROP=/tmp
SLEEPSECS=4
ASTSBINDIR=__ASTERISK_SBIN_DIR__
-ASTPIDFILE=__ASTERISK_VARRUN_DIR__/asterisk.pid
+ASTVARRUNDIR=__ASTERISK_VARRUN_DIR__
+ASTPIDFILE=${ASTVARRUNDIR}/asterisk.pid
# comment this line out to have this script _not_ kill all mpg123 processes when
# asterisk exits
@@ -91,6 +92,11 @@
# set the process's filemax to whatever set above
ulimit -n $MAXFILES
+ if [ ! -d ${ASTVARRUNDIR} ]; then
+ mkdir -p ${ASTVARRUNDIR}
+ chmod 770 ${ASTVARRUNDIR}
+ fi
+
fi
if test "x$UMASK" != "x"; then
More information about the asterisk-commits
mailing list