From d07330b318be668b667e4339d8dd0387327460e1 Mon Sep 17 00:00:00 2001 From: tzafrir Date: Thu, 21 Jun 2007 06:51:52 +0000 Subject: readability fixes: Remove complex nesting. Move hpec init to a function. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@2656 5390a7c7-147a-4af0-8ec9-7488f05a26cb --- zaptel.init | 83 +++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 38 deletions(-) (limited to 'zaptel.init') diff --git a/zaptel.init b/zaptel.init index 0f80bfd..1185620 100644 --- a/zaptel.init +++ b/zaptel.init @@ -62,12 +62,11 @@ unload_module() { # Wait for Astribank to initialize registers: wait_for_xpp() { - if [ -d /proc/xpp ] - then - # reading from waitfor_xpds only returns when the device - # has finished initilizing its regiters and is available. - cat /proc/xpp/XBUS-*/waitfor_xpds 2>/dev/null >/dev/null || true - fi + if [ ! -d /proc/xpp ]; then return; fi + + # reading from waitfor_xpds only returns when the device + # has finished initilizing its regiters and is available. + cat /proc/xpp/XBUS-*/waitfor_xpds 2>/dev/null >/dev/null || true } # Register to zaptel Astribank spans that were not autoomatically registered @@ -126,6 +125,45 @@ fix_asterisbank_sync() { fi } +hpec_start() { + # HPEC license found + if ! echo /var/lib/digium/licenses/HPEC-*.lic | grep -v '\*' | grep -q .; then + return + fi + + # zaphpec_enable not installed in /usr/sbin + if [ ! -f /usr/sbin/zaphpec_enable ]; then + echo -n "Running zaphpec_enable: Failed" + echo -n "." + echo " The zaphpec_enable binary is not installed in /usr/sbin." + return + fi + + # zaphpec_enable not set executable + if [ ! -x /usr/sbin/zaphpec_enable ]; then + echo -n "Running zaphpec_enable: Failed" + echo -n "." + echo " /usr/sbin/zaphpec_enable is not set as executable." + return + fi + + # zaphpec_enable properly installed + if [ $system = debian ]; then + echo -n "Running zaphpec_enable: " + /usr/sbin/zaphpec_enable >& /dev/null + elif [ $system = redhat ]; then + action "Running zaphpec_enable: " /usr/sbin/zaphpec_enable + fi + if [ $? = 0 ]; then + echo -n "done" + echo "." + else + echo -n "Failed" + echo -n "." + echo " This can be caused if you had already run zaphpec_enable, or if your HPEC license is no longer valid." + fi +} + # Check that telephony is up. [ "${TELEPHONY}" = "yes" ] || exit 0 @@ -193,38 +231,7 @@ case "$1" in [ $RETVAL -eq 0 ] && touch $LOCKFILE - # HPEC license found - if echo /var/lib/digium/licenses/HPEC-*.lic | grep -v '\*' | grep -q .; then - # zaphpec_enable not installed in /usr/sbin - if [ ! -f /usr/sbin/zaphpec_enable ]; then - echo -n "Running zaphpec_enable: Failed" - echo -n "." - echo " The zaphpec_enable binary is not installed in /usr/sbin." - else - # zaphpec_enable not set executable - if [ ! -x /usr/sbin/zaphpec_enable ]; then - echo -n "Running zaphpec_enable: Failed" - echo -n "." - echo " /usr/sbin/zaphpec_enable is not set as executable." - else - # zaphpec_enable properly installed - if [ $system = debian ]; then - echo -n "Running zaphpec_enable: " - /usr/sbin/zaphpec_enable >& /dev/null - elif [ $system = redhat ]; then - action "Running zaphpec_enable: " /usr/sbin/zaphpec_enable - fi - if [ $? = 0 ]; then - echo -n "done" - echo "." - else - echo -n "Failed" - echo -n "." - echo " This can be caused if you had already run zaphpec_enable, or if your HPEC license is no longer valid." - fi - fi - fi - fi + hpec_start ;; stop) # Unload drivers -- cgit v1.2.3