From 878abc56f013a9bd94a46bf1a009407e6c8ecceb Mon Sep 17 00:00:00 2001 From: tzafrir Date: Sun, 29 Apr 2007 20:19:13 +0000 Subject: xpp rev. 3814: * Protocol no. 2.6: syncing improvements. * Support for 8-port Astribank BRI. * Firmware unloading now works: rmmod xpp_usb; /etc/hotplug/usb/xpp_fxloader reset * Defaults of kernel parameters are now part of parameter description. * World-readable kernel parameters. * No need for extra patch beyond bristuff for Astribank BRI. * Default poll intervals changed: 500 in BRI and FXO. * Allow changing FXS polls interval at run time. * BRI initalization fixed on SUSE (path to logger). * When using the SUSE zaptel rpm package, set modules_var=ZAPTEL_MODULES in /etc/sysconfig/zaptel . * zt_registration not verbose by default. * xpp_sync warns if FXO is sync slave. * Fixed genzaptelconf -z (zapscan output emulation). * PCM fixes. * Solves "multiple ticks" bug. No need for pcm_tasklets workaround. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2475 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.init | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'zaptel.init') diff --git a/zaptel.init b/zaptel.init index 408832f..42cf4c4 100644 --- a/zaptel.init +++ b/zaptel.init @@ -39,11 +39,26 @@ if [ -z "${MODULES}" ]; then MODULES="tor2 wct4xxp wct1xxp wcte11xp wcfxo wctdm wctdm24xxp" fi -RMODULES="" -# Reverse list for un-loading; don't change -for x in $MODULES; do - RMODULES="$x $RMODULES" -done +# recursively unload a module and its dependencies, if possible. +# where's modprobe -r when you need it? +# inputs: module to unload. +# returns: the result from +unload_module() { + module="$1" + line=`lsmod 2>/dev/null | grep "^$1 "` + if [ "$line" = '' ]; then return; fi # module was not loaded + + set -- $line + # $1: the original module, $2: size, $3: refcount, $4: deps list + mods=`echo $4 | tr , ' '` + for mod in $mods; do + # run in a subshell, so it won't step over our vars: + (unload_module $mod) + # TODO: the following is probably the error handling we want: + # if [ $? != 0 ]; then return 1; fi + done + rmmod $module +} # Wait for Astribank to initialize registers: wait_for_xpp() { @@ -214,24 +229,16 @@ case "$1" in # Unload drivers $ZTCFG -s echo -n "Unloading zaptel hardware drivers:" - for x in $RMODULES; do - if rmmod ${x} >& /dev/null; then - echo -n " $x" - fi - done - 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 + unload_module zaptel RETVAL=$? [ $RETVAL -eq 0 ] && rm -f $LOCKFILE ;; + unload) + # We don't have zaptel helper, so let's not replicate too much code: + # allow others to use the unload command. + unload_module zaptel + ;; restart) $0 stop $0 start -- cgit v1.2.3