aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-05 03:22:25 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-05 03:22:25 +0000
commit8c81e75f01dba357cc365e5fa4ff609d0d9e4b85 (patch)
tree1a58861d17c0c67338df468dd0866d7c0cf51fc0
parent8e65ea9bd92da2a7ae784128210bb3d6b3535038 (diff)
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: http://svn.digium.com/svn/asterisk/branches/1.4@115285 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xcontrib/init.d/rc.debian.asterisk8
-rwxr-xr-xcontrib/init.d/rc.gentoo.asterisk8
-rwxr-xr-xcontrib/init.d/rc.mandrake.asterisk8
-rwxr-xr-xcontrib/init.d/rc.redhat.asterisk8
-rwxr-xr-xcontrib/init.d/rc.slackware.asterisk8
-rwxr-xr-xcontrib/init.d/rc.suse.asterisk9
-rw-r--r--contrib/scripts/safe_asterisk10
7 files changed, 58 insertions, 1 deletions
diff --git a/contrib/init.d/rc.debian.asterisk b/contrib/init.d/rc.debian.asterisk
index 5e50eb793..b5b150c98 100755
--- a/contrib/init.d/rc.debian.asterisk
+++ b/contrib/init.d/rc.debian.asterisk
@@ -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"
diff --git a/contrib/init.d/rc.gentoo.asterisk b/contrib/init.d/rc.gentoo.asterisk
index 3d963d6c0..efc87afc7 100755
--- a/contrib/init.d/rc.gentoo.asterisk
+++ b/contrib/init.d/rc.gentoo.asterisk
@@ -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"
diff --git a/contrib/init.d/rc.mandrake.asterisk b/contrib/init.d/rc.mandrake.asterisk
index 1ffd25d37..8d4f0b70d 100755
--- a/contrib/init.d/rc.mandrake.asterisk
+++ b/contrib/init.d/rc.mandrake.asterisk
@@ -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
diff --git a/contrib/init.d/rc.redhat.asterisk b/contrib/init.d/rc.redhat.asterisk
index 27d633e70..de821fe8a 100755
--- a/contrib/init.d/rc.redhat.asterisk
+++ b/contrib/init.d/rc.redhat.asterisk
@@ -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
diff --git a/contrib/init.d/rc.slackware.asterisk b/contrib/init.d/rc.slackware.asterisk
index 0802bfcaa..0b2d3a7c5 100755
--- a/contrib/init.d/rc.slackware.asterisk
+++ b/contrib/init.d/rc.slackware.asterisk
@@ -10,6 +10,14 @@
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
diff --git a/contrib/init.d/rc.suse.asterisk b/contrib/init.d/rc.suse.asterisk
index 25e96cf8c..c8d94df1c 100755
--- a/contrib/init.d/rc.suse.asterisk
+++ b/contrib/init.d/rc.suse.asterisk
@@ -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
diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk
index 14d9b35ec..1cb5e8006 100644
--- a/contrib/scripts/safe_asterisk
+++ b/contrib/scripts/safe_asterisk
@@ -26,13 +26,21 @@ PRIORITY=0
# set to the system's maximum files open devided by two, if not set here.
# MAXFILES=32768
+# 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
+
# 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.
# if we're not root, fall back to standard everything.
if [ `id -u` != 0 ]
then
- echo "Ops. I'm not root. Falling back to standard prio and file max." >&2
+ 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
else