aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-11 16:31:03 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-11 16:31:03 +0000
commitb2d3754358cb34ec2254e219798d831a764ed760 (patch)
tree0635d2bd8aa19615e6a4840efed2481432f8b494 /contrib
parent9f9792e83fad98f6ff182f35901f7c4098c733b9 (diff)
Issue 9121 - fixups for safe_asterisk script
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@63903 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'contrib')
-rw-r--r--contrib/scripts/safe_asterisk23
1 files changed, 19 insertions, 4 deletions
diff --git a/contrib/scripts/safe_asterisk b/contrib/scripts/safe_asterisk
index 5a8808a56..7ea4a998e 100644
--- a/contrib/scripts/safe_asterisk
+++ b/contrib/scripts/safe_asterisk
@@ -6,6 +6,8 @@ CONSOLE=yes # Whether or not you want a console
MACHINE=`hostname` # To specify which machine has crashed when getting the mail
DUMPDROP=/tmp
ASTSBINDIR=__ASTERISK_SBIN_DIR__
+ASTPIDFILE=__ASTERISK_VARRUN_DIR__/asterisk.pid
+
#
# Don't fork when running "safely"
#
@@ -35,6 +37,11 @@ fi
ulimit -c unlimited
#
+# Don't die if stdout/stderr can't be written to
+#
+trap '' SIGPIPE
+
+#
# Run scripts to set any environment variables or do any other system-specific setup needed
#
@@ -53,10 +60,10 @@ run_asterisk()
if [ "$TTY" != "" ]; then
cd /tmp
stty sane < /dev/${TTY}
- ${ASTSBINDIR}/asterisk ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}
+ ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}
else
cd /tmp
- ${ASTSBINDIR}/asterisk ${CLIARGS} ${ASTARGS}
+ ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS}
fi
EXITSTATUS=$?
echo "Asterisk ended with exit status $EXITSTATUS"
@@ -71,7 +78,11 @@ run_asterisk()
echo "Asterisk on $MACHINE exited on signal $EXITSIGNAL. Might want to take a peek." | \
mail -s "Asterisk Died" $NOTIFY
fi
- if [ -f /tmp/core ]; then
+
+ 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` &
fi
else
@@ -80,7 +91,11 @@ run_asterisk()
exit 0
else
echo "Asterisk died with code $EXITSTATUS."
- if [ -f /tmp/core ]; then
+
+ 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` &
fi
fi