[zaptel-commits] tzafrir: trunk r2265 - /trunk/zaptel.init

zaptel-commits at lists.digium.com zaptel-commits at lists.digium.com
Fri Mar 2 12:47:05 MST 2007


Author: tzafrir
Date: Fri Mar  2 13:47:05 2007
New Revision: 2265

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2265
Log:
Fix the usage of ztcfg in the init script:
 * The debian variant has failed to report errors.
 * Remove duplication.
 * Allow overriding the location of ztcfg and zaptel.conf in the config file.

Modified:
    trunk/zaptel.init

Modified: trunk/zaptel.init
URL: http://svn.digium.com/view/zaptel/trunk/zaptel.init?view=diff&rev=2265&r1=2264&r2=2265
==============================================================================
--- trunk/zaptel.init (original)
+++ trunk/zaptel.init Fri Mar  2 13:47:05 2007
@@ -9,6 +9,9 @@
 # config: /etc/sysconfig/zaptel
 
 initdir=/etc/init.d
+
+ZTCFG=/sbin/ztcfg
+ZTCFG_CMD="$ZTCFG" # e.g: for a custom zaptel.conf location
 
 #
 # Determine which kind of configuration we're using
@@ -61,13 +64,25 @@
 # Check that telephony is up.
 [ "${TELEPHONY}" = "yes" ] || exit 0
 
-[ -f /sbin/ztcfg ] || exit 0
+[ -x "$ZTCFG" ] || exit 0
 
 [ -f /etc/zaptel.conf ] || exit 0
 
 if [ "${DEBUG}" = "yes" ]; then
 	ARGS="debug=1"
 fi
+
+run_ztcfg() {
+	if [ $system = debian ]; then
+	 	echo -n "Running ztcfg: " 
+	 	$ZTCFG_CMD >/dev/null 2>&1 && echo -n "done"
+		RETVAL=$?
+		echo "."
+	elif [ $system = redhat ]; then
+		action "Running ztcfg: " $ZTCFG_CMD
+		RETVAL=$?
+	fi
+}
 
 RETVAL=0
 
@@ -108,13 +123,9 @@
 		echo "No functioning zap hardware found in /proc/zaptel, loading ztdummy"
 		modprobe ztdummy >& /dev/null
 	fi
-	if [ $system = debian ]; then
-	    echo -n "Running ztcfg: " 
-	    /sbin/ztcfg >& /dev/null && echo -n "done"
-	    echo "."
-	elif [ $system = redhat ]; then
-	    action "Running ztcfg: " /sbin/ztcfg
-	fi
+
+	run_ztcfg
+
 	RETVAL=$?
 
 	[ $RETVAL -eq 0 ] && touch $LOCKFILE
@@ -138,14 +149,8 @@
 	$0 start
 	;;
   reload)
-	if [ $system = debian ]; then
-	    echo -n "Reloading ztcfg: "
-	    /sbin/ztcfg >& /dev/null && echo -n "done"
-	    echo "."
-	elif [ $system = redhat ]; then
-	    action "Reloading ztcfg: " /sbin/ztcfg
-	fi
-	RETVAL=$?
+	run_ztcfg
+	
 	;;
   *)
 	echo "Usage: zaptel {start|stop|restart|reload}"



More information about the zaptel-commits mailing list