[asterisk-commits] tilghman: branch 1.6.0 r239309 - in /branches/1.6.0: ./ contrib/scripts/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jan 11 21:24:10 CST 2010


Author: tilghman
Date: Mon Jan 11 21:24:05 2010
New Revision: 239309

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=239309
Log:
Merged revisions 239308 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r239308 | tilghman | 2010-01-11 21:21:40 -0600 (Mon, 11 Jan 2010) | 15 lines
  
  Merged revisions 239307 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r239307 | tilghman | 2010-01-11 21:18:36 -0600 (Mon, 11 Jan 2010) | 8 lines
    
    Portability and other fixes for the safe_asterisk script
    (closes issue #16416)
     Reported by: bklang
     Patches: 
           safe_asterisk-compat-1.patch uploaded by bklang (license 919)
           20100106__issue16416__trunk.diff.txt uploaded by tilghman (license 14)
     Tested by: bklang
  ........
................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/contrib/scripts/safe_asterisk

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/contrib/scripts/safe_asterisk
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/contrib/scripts/safe_asterisk?view=diff&rev=239309&r1=239308&r2=239309
==============================================================================
--- branches/1.6.0/contrib/scripts/safe_asterisk (original)
+++ branches/1.6.0/contrib/scripts/safe_asterisk Mon Jan 11 21:24:05 2010
@@ -34,10 +34,10 @@
 
 function message() {
 	echo "$1" >&2
-	if [ "$SYSLOG" != "" ]; then
+	if test "x$SYSLOG" != "x" ; then
 	    logger -p "${SYSLOG}.warn" -t safe_asterisk[$$] "$1"
 	fi
-	if [ "$LOGFILE" != "" ]; then
+	if test "x$LOGFILE" != "x" ; then
 	    echo "safe_asterisk[$$]: $1" >> "$LOGFILE"
 	fi
 }
@@ -45,7 +45,7 @@
 # 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'`
-if [ "`echo $VERSION | cut -c 1-8`" = "Asterisk" ]; then
+if test "`echo $VERSION | cut -c 1-8`" = "Asterisk" ; then
 	message "Asterisk is already running.  $0 will exit now."
 	exit 1
 fi
@@ -54,36 +54,29 @@
 # root. if running asterisk as other users, pass that to asterisk on the command
 # line.
 # if we're not root, fall back to standard everything.
-if [ `id -u` != 0 ]
-then
+if test `id -u` != 0 ; then
 	echo "Oops. I'm not root. Falling back to standard prio and file max." >&2
 	echo "This is NOT suitable for large systems." >&2
 	PRIORITY=0
 	message "safe_asterisk was started by `id -n` (uid `id -u`)."
 else
-	if `uname -s | grep Linux 2>&1 > /dev/null `
-	then
+	if `uname -s | grep Linux >/dev/null 2>&1`; then
 		# maximum number of open files is set to the system maximum divided by two if
 		# MAXFILES is not set.
-		if [ "$MAXFILES" = "" ]
-		then
+		if test "x$MAXFILES" = "x" ; then
 			# just check if file-max is readable
-			if [ -r /proc/sys/fs/file-max ]
-			then
+			if test -r /proc/sys/fs/file-max ; then
 				MAXFILES=$(( `cat /proc/sys/fs/file-max` / 2 ))
 			fi
 		fi
 		SYSCTL_MAXFILES="fs.file-max"
-	elif `uname -s | grep Darwin 2>&1 > /dev/null `
-	then
+	elif `uname -s | grep Darwin /dev/null 2>&1`; then
 		SYSCTL_MAXFILES="kern.maxfiles"
 	fi
 
 
-	if [ "$SYSMAXFILES" != "" ]
-	then
-		if [ "$SYSCTL_MAXFILES" != "" ]
-		then
+	if test "x$SYSMAXFILES" != "x"; then
+		if test "x$SYSCTL_MAXFILES" != "x"; then
 			sysctl -w $SYSCTL_MAXFILES=$SYSMAXFILES
 		fi
 	fi
@@ -106,21 +99,21 @@
 # Don't fork when running "safely"
 #
 ASTARGS=""
-if [ "$TTY" != "" ]; then
-	if [ -c /dev/tty${TTY} ]; then
+if test "x$TTY" != "x" ; then
+	if test -c /dev/tty${TTY} ; then
 		TTY=tty${TTY}
-	elif [ -c /dev/vc/${TTY} ]; then
+	elif test -c /dev/vc/${TTY} ; then
 		TTY=vc/${TTY}
 	else
 		message "Cannot find specified TTY (${TTY})"
 		exit 1
 	fi
 	ASTARGS="${ASTARGS} -vvvg"
-	if [ "$CONSOLE" != "no" ]; then
+	if test "x$CONSOLE" != "xno" ; then
 		ASTARGS="${ASTARGS} -c"
 	fi
 fi
-if [ ! -w ${DUMPDROP} ]; then	
+if test ! -w "${DUMPDROP}" ; then	
 	message "Cannot write to ${DUMPDROP}"
 	exit 1
 fi
@@ -134,9 +127,9 @@
 # Run scripts to set any environment variables or do any other system-specific setup needed
 #
 
-if [ -d /etc/asterisk/startup.d ]; then
+if test -d /etc/asterisk/startup.d ; then
 	for script in /etc/asterisk/startup.d/*.sh; do
-		if [ -x ${script} ]; then
+		if test -r ${script} ; then
 			. ${script}
 		fi
 	done
@@ -146,7 +139,7 @@
 {
 	while :; do 
 
-		if [ "$TTY" != "" ]; then
+		if test "x$TTY" != "x" ; then
 			cd /tmp
 			stty sane < /dev/${TTY}
 			nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}
@@ -156,42 +149,43 @@
 		fi
 		EXITSTATUS=$?
 		message "Asterisk ended with exit status $EXITSTATUS"
-		if [ "$EXITSTATUS" = "0" ]; then
+		if test "x$EXITSTATUS" = "x0" ; then
 			# Properly shutdown....
 			message "Asterisk shutdown normally."
 			exit 0
-		elif [ $EXITSTATUS -gt 128 ]; then
-			EXITSIGNAL=EXITSTATUS-128
+		elif test "0$EXITSTATUS" -gt "128" ; then
+			EXITSIGNAL=$(($EXITSTATUS - 128))
 			echo "Asterisk exited on signal $EXITSIGNAL."
-			if [ "$NOTIFY" != "" ]; then
+			if test "x$NOTIFY" != "x" ; then
 				echo "Asterisk on $MACHINE exited on signal $EXITSIGNAL.  Might want to take a peek." | \
 				mail -s "Asterisk Died" $NOTIFY
 				message "Exited on signal $EXITSIGNAL"
 			fi
-			if [ "$EXEC" != "" ]; then
+			if test "x$EXEC" != "x" ; then
 				$EXEC
 			fi
 
 			PID=`cat ${ASTPIDFILE}`
-			if [ -f /tmp/core.${PID} ]; then
-				mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-`date -Iseconds` &
-			elif [ -f /tmp/core ]; then
-				mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` &
+			DATE=`date "+%Y-%m-%dT%H:%M:%S%z"`
+			if test -f /tmp/core.${PID} ; then
+				mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-$DATE &
+			elif test -f /tmp/core ; then
+				mv /tmp/core ${DUMPDROP}/core.`hostname`-$DATE &
 			fi
 		else
 			message "Asterisk died with code $EXITSTATUS."
 
 			PID=`cat ${ASTPIDFILE}`
-			if [ -f /tmp/core.${PID} ]; then
-				mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-`date -Iseconds` &
-			elif [ -f /tmp/core ]; then
-				mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` &
+			DATE=`date "+%Y-%m-%dT%H:%M:%S%z"`
+			if test -f /tmp/core.${PID} ; then
+				mv /tmp/core.${PID} ${DUMPDROP}/core.`hostname`-$DATE &
+			elif test -f /tmp/core ; then
+				mv /tmp/core ${DUMPDROP}/core.`hostname`-$DATE &
 			fi
 		fi
 		message "Automatically restarting Asterisk."
 		sleep $SLEEPSECS
-		if [ $KILLALLMPG123 ]
-		then
+		if test "0$KILLALLMPG123" -gt "0" ; then
 			killall -9 mpg123
 		fi
 	done




More information about the asterisk-commits mailing list