2 TTY=9 # TTY (if you want one) for Asterisk to run on
3 CONSOLE=yes # Whether or not you want a console
4 #NOTIFY=ben@alkaloid.net # Who to notify about crashes
7 # Don't fork when running "safely"
10 if [ "$TTY" != "" ]; then
11 if [ -c /dev/tty${TTY} ]; then
13 elif [ -c /dev/vc/${TTY} ]; then
16 echo "Cannot find your TTY (${TTY})" >&2
19 ASTARGS="${ASTARGS} -vvvg"
20 if [ "$CONSOLE" != "no" ]; then
21 ASTARGS="${ASTARGS} -c"
24 if [ ! -w ${DUMPDROP} ]; then
25 echo "Cannot write to ${DUMPDROP}" >&2
30 # Let Asterisk dump core
42 if [ "$TTY" != "" ]; then
44 stty sane < /dev/${TTY}
45 asterisk ${ASTARGS} >& /dev/${TTY} < /dev/${TTY}
51 echo "Asterisk ended with exit status $EXITSTATUS"
52 if [ "$EXITSTATUS" = "0" ]; then
53 # Properly shutdown....
54 echo "Asterisk shutdown normally."
56 elif [ $EXITSTATUS -gt 128 ]; then
57 let EXITSIGNAL=EXITSTATUS-128
58 echo "Asterisk exited on signal $EXITSIGNAL."
59 if [ "$NOTIFY" != "" ]; then
60 echo "Asterisk exited on signal $EXITSIGNAL. Might want to take a peek." | \
61 mail -s "Asterisk Died" $NOTIFY
63 if [ -f /tmp/core ]; then
64 mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` &
67 echo "Asterisk died with code $EXITSTATUS. Aborting."
68 if [ -f /tmp/core ]; then
69 mv /tmp/core ${DUMPDROP}/core.`hostname`-`date -Iseconds` &
73 echo "Automatically restarting Asterisk."