[zaptel-commits] tzafrir: branch 1.2 r2656 - /branches/1.2/zaptel.init

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Jun 21 01:51:53 CDT 2007


Author: tzafrir
Date: Thu Jun 21 01:51:52 2007
New Revision: 2656

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2656
Log:
readability fixes: Remove complex nesting. Move hpec init to a function.

Modified:
    branches/1.2/zaptel.init

Modified: branches/1.2/zaptel.init
URL: http://svn.digium.com/view/zaptel/branches/1.2/zaptel.init?view=diff&rev=2656&r1=2655&r2=2656
==============================================================================
--- branches/1.2/zaptel.init (original)
+++ branches/1.2/zaptel.init Thu Jun 21 01:51:52 2007
@@ -62,12 +62,11 @@
 
 # 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 @@
 	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 @@
 
 	[ $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




More information about the zaptel-commits mailing list