From 75c1f4f92c1ef6804fbfbc75679c45f9b0d24fb0 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Fri, 2 Mar 2007 19:47:05 +0000 Subject: 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. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@2265 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.init | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/zaptel.init b/zaptel.init index 81c0150..52aa030 100644 --- a/zaptel.init +++ b/zaptel.init @@ -10,6 +10,9 @@ 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,7 +64,7 @@ unload_module() { # Check that telephony is up. [ "${TELEPHONY}" = "yes" ] || exit 0 -[ -f /sbin/ztcfg ] || exit 0 +[ -x "$ZTCFG" ] || exit 0 [ -f /etc/zaptel.conf ] || exit 0 @@ -69,6 +72,18 @@ 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 # See how we were called. @@ -108,13 +123,9 @@ case "$1" in 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 @@ case "$1" in $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}" -- cgit v1.2.3