diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2005-01-21 22:49:26 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2005-01-21 22:49:26 +0000 |
commit | 285e2417b6283c0b31eb9151e1350c55bad244cb (patch) | |
tree | b60e9350723c996da69a49da64805a293ab588a4 /zaptel.init | |
parent | d4abecffcb475e6d472368850ccf3c7c40224a20 (diff) |
Improve portability for debian (bug #3390)
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@571 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel.init')
-rwxr-xr-x | zaptel.init | 100 |
1 files changed, 71 insertions, 29 deletions
diff --git a/zaptel.init b/zaptel.init index 300c74e..4593112 100755 --- a/zaptel.init +++ b/zaptel.init @@ -8,33 +8,52 @@ # # config: /etc/sysconfig/zaptel -# Source function library. -. /etc/rc.d/init.d/functions +initdir=/etc/init.d -[ -f /etc/sysconfig/zaptel ] || exit 0 +# +# Determine which kind of configuration we're using +# +system=redhat # assume redhat +if [ -f /etc/debian_version ]; then + system=debian +fi -# Source zaptel configuration. -. /etc/sysconfig/zaptel +# Source function library. +if [ $system = redhat ]; then + . $initdir/functions || exit 0 +fi -# Check that telephony is up. -if [ "${TELEPHONY}" = "no" ]; then - exit 0 +# Source zaptel configuration. +if [ $system = debian ]; then + [ -f /etc/default/zaptel ] && . /etc/default/zaptel +elif [ $system = redhat ]; then + [ -f /etc/sysconfig/zaptel ] && . /etc/sysconfig/zaptel fi -[ -f /sbin/ztcfg ] || exit 0 +if [ -z "${MODULES}" ]; then + # Populate defaults if not present + MODULES="tor2 wct4xxp wct1xxp wcte11xp wcfxo wctdm" +fi -[ -f /etc/zaptel.conf ] || exit 0 +RMODULES="" +# Reverse list for un-loading; don't change +for x in $MODULES; do + RMODULES="$x $RMODULES" +done -RETVAL=0 +# Check that telephony is up. +[ "${TELEPHONY}" = "yes" ] || exit 0 -MODULES="torisa tor2 wct4xxp wcte11xp wct1xxp wcfxo wctdm wcusb" +[ -f /sbin/ztcfg ] || exit 0 -RMODULES="wcusb wctdm wcfxo wct1xxp wcte11xp wct4xxp tor2 torisa" +[ -f /etc/zaptel.conf ] || exit 0 if [ "${DEBUG}" = "yes" ]; then ARGS="debug=1" fi +RETVAL=0 + # See how we were called. case "$1" in start) @@ -42,14 +61,20 @@ case "$1" in rmmod wcusb >& /dev/null rmmod wcfxsusb >& /dev/null rmmod audio >& /dev/null - action "Loading zaptel framework: " modprobe zaptel - echo -n "Loading zaptel hardware modules: " + if [ $system = debian ]; then + echo -n "Loading zaptel framework: " + modprobe zaptel >& /dev/null && echo -n "done" + echo "." + elif [ $system = redhat ]; then + action "Loading zaptel framework: " modprobe zaptel + fi + echo -n "Loading zaptel hardware modules:" for x in $MODULES; do - if insmod ${x} ${ARGS} >& /dev/null; then - echo -n "$x " + if modprobe ${x} ${ARGS} >& /dev/null; then + echo -n " $x" fi done - echo + echo "." TMOUT=10 # max secs to wait while [ ! -d /dev/zap ] ; do sleep 1 @@ -59,34 +84,51 @@ case "$1" in exit 1 fi done - sleep 1; - action "Running ztcfg: " /sbin/ztcfg + 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 RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/zaptel - ;; stop) - # Stop daemons. - echo -n "Unloading zaptel hardware drivers: " + # Unload drivers + echo -n "Unloading zaptel hardware drivers:" for x in $RMODULES; do if rmmod ${x} >& /dev/null; then - echo -n "$x " + echo -n " $x" fi done - echo - - action "Removing zaptel module: " rmmod zaptel + echo "." + + if [ $system = debian ]; then + echo -n "Removing zaptel module: " + rmmod zaptel >& /dev/null && echo -n "done" + echo "." + elif [ $system = redhat ]; then + action "Removing zaptel module: " rmmod zaptel + fi RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/zaptel ;; restart) $0 stop $0 start - RETVAL=$? ;; reload) - action "Reloading ztcfg: " /sbin/ztcfg + 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=$? ;; *) echo "Usage: zaptel {start|stop|restart|reload}" |