diff options
-rw-r--r-- | zaptel.init | 37 |
1 files 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}" |