Merged revisions 115285 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Mon, 5 May 2008 03:25:35 +0000 (03:25 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Mon, 5 May 2008 03:25:35 +0000 (03:25 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r115285 | tilghman | 2008-05-04 22:22:25 -0500 (Sun, 04 May 2008) | 7 lines

When starting Asterisk, bug out if Asterisk is already running.
(closes issue #12525)
 Reported by: explidous
 Patches:
       20080428__bug12525.diff.txt uploaded by Corydon76 (license 14)
 Tested by: mvanbaak

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@115286 65c4cc65-6c06-0410-ace0-fbb531ad65f3

contrib/init.d/rc.debian.asterisk
contrib/init.d/rc.gentoo.asterisk
contrib/init.d/rc.mandrake.asterisk
contrib/init.d/rc.redhat.asterisk
contrib/init.d/rc.slackware.asterisk
contrib/init.d/rc.suse.asterisk
contrib/scripts/safe_asterisk

index 5e50eb7..b5b150c 100755 (executable)
@@ -51,6 +51,14 @@ fi
 
 case "$1" in
   start)
+       # Check if Asterisk is already running.  If it is, then bug out, because
+       # starting up Asterisk when Asterisk is already running is very bad.
+       VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'`
+       if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+               echo "Asterisk is already running.  $0 will exit now."
+               exit 1
+       fi
+
        log_begin_msg "Starting $DESC: $NAME"
         if [ $AST_USER ] ; then
                 ASTARGS="-U $AST_USER"
index 3d963d6..efc87af 100755 (executable)
@@ -6,6 +6,14 @@ depend() {
 }
 
 start() {
+       # 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 [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+               echo "Asterisk is already running.  $0 will exit now."
+               exit 1
+       fi
+
        ebegin "Starting Asterisk"
        /usr/sbin/asterisk
        eend $? "Failed to start Asterisk"
index 1ffd25d..8d4f0b7 100755 (executable)
@@ -119,6 +119,14 @@ run_asterisk()
 
 case "$1" in
        start)
+               # Check if Asterisk is already running.  If it is, then bug out, because
+               # starting Asterisk when Asterisk is already running is very bad.
+               VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'`
+               if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+                       echo "Asterisk is already running.  $0 will exit now."
+                       exit 1
+               fi
+
                gprintf "Starting asterisk: "
                run_asterisk >/dev/null 2>&1 &
                sleep 2 # Give it time to die
index 27d633e..de821fe 100755 (executable)
@@ -68,6 +68,14 @@ fi
 RETVAL=0
 
 start() {
+       # Check if Asterisk is already running.  If it is, then bug out, because
+       # starting safe_asterisk when Asterisk is running is very bad.
+       VERSION=`${AST_SBIN}/asterisk -rx 'core show version'`
+       if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+               echo "Asterisk is already running."
+               exit 1
+       fi
+
        # Start daemons.
        echo -n $"Starting asterisk: "
         if [ -f $SAFE_ASTERISK ] ; then
index 0802bfc..0b2d3a7 100755 (executable)
 
 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'`
+      if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+         echo "Asterisk is already running.  $0 will exit now."
+         exit 1
+      fi
+
       echo "Starting Asterisk   /usr/sbin/asterisk"
       /usr/sbin/asterisk
    fi
index 25e96cf..c8d94df 100755 (executable)
@@ -63,6 +63,15 @@ RETVAL=0
 
 start() {
        # Start daemons.
+
+       # Check if Asterisk is already running.  If it is, then bug out, because
+       # starting Asterisk when Asterisk is already running is very bad.
+       VERSION=`/usr/sbin/asterisk -rx 'core show version'`
+       if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+               echo "Asterisk is already running.  $0 will exit now."
+               exit 1
+       fi
+
        echo -n $"Starting asterisk: "
         if [ -f $SAFE_ASTERISK ] ; then
                DAEMON=$SAFE_ASTERISK
index 05e44d8..e73933a 100644 (file)
@@ -38,6 +38,14 @@ function message() {
        fi
 }
 
+# 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 [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+       message "Asterisk is already running.  $0 will exit now."
+       exit 1
+fi
+
 # since we're going to change priority and open files limits, we need to be
 # root. if running asterisk as other users, pass that to asterisk on the command
 # line.