Subject: use /etc/default/settings for configuring safe_asterisk (vendor specific)
Author: Faidon Liambotis <paravoid@debian.org>
Bug-Debian: http://bugs.debian.org/381786
Last-Update: 2009-12-19

Use ASTSAFE_TTY and ASTSAFE_CONSOLE from /etc/default/asterisk to configure
safe_asterisk.

--- a/contrib/scripts/safe_asterisk
+++ b/contrib/scripts/safe_asterisk
@@ -1,9 +1,13 @@
 #!/bin/sh
 # vim:textwidth=80:tabstop=4:shiftwidth=4:smartindent:autoindent
 
+if [ -f /etc/default/asterisk ]; then
+	. /etc/default/asterisk;
+fi
+
 CLIARGS="$*"				# Grab any args passed to safe_asterisk
-TTY=9						# TTY (if you want one) for Asterisk to run on
-CONSOLE=yes					# Whether or not you want a console
+TTY=${ASTSAFE_TTY:-9}                   	# TTY (if you want one) for Asterisk to run on
+CONSOLE=${ASTSAFE_CONSOLE:-yes}         	# Whether or not you want a console
 #NOTIFY=ben@alkaloid.net	# Who to notify about crashes
 #EXEC=/path/to/somescript	# Run this command if Asterisk crashes
 #LOGFILE=/path/to/logfile	# Where to place the normal logfile (disabled if blank)
@@ -112,7 +116,7 @@ ulimit -c unlimited
 # Don't fork when running "safely"
 #
 ASTARGS=""
-if [ "$TTY" != "" ]; then
+if [ "$TTY" != "no" ]; then
 	if [ -c /dev/tty${TTY} ]; then
 		TTY=tty${TTY}
 	elif [ -c /dev/vc/${TTY} ]; then
@@ -152,7 +156,7 @@ run_asterisk()
 {
 	while :; do 
 
-		if [ "$TTY" != "" ]; then
+		if [ "$TTY" != "no" ]; then
 			cd /tmp
 			stty sane < /dev/${TTY}
 			nice -n $PRIORITY ${ASTSBINDIR}/asterisk -f ${CLIARGS} ${ASTARGS} > /dev/${TTY} 2>&1 < /dev/${TTY}
