[zaptel-commits] tzafrir: branch 1.4 r2659 - /branches/1.4/zaptel.init

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Thu Jun 21 02:37:42 CDT 2007


Author: tzafrir
Date: Thu Jun 21 02:37:41 2007
New Revision: 2659

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2659
Log:
Reduce nesting in hpec startup by moving it to a function.

Modified:
    branches/1.4/zaptel.init

Modified: branches/1.4/zaptel.init
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel.init?view=diff&rev=2659&r1=2658&r2=2659
==============================================================================
--- branches/1.4/zaptel.init (original)
+++ branches/1.4/zaptel.init Thu Jun 21 02:37:41 2007
@@ -126,6 +126,49 @@
 	fi
 }
 
+hpec_start() {
+	# check for HPEC licenses
+	for f in /var/lib/digium/licenses/HPEC*.lic; do
+		if [ -f ${f} ]; then
+			haveHPEC=1
+		fi
+	done
+
+	# HPEC license found
+	if [ -z "${haveHPEC}" ]; 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
 
@@ -200,38 +243,7 @@
 		fi
 	done
 
-	# HPEC license found
-	if [ -n "${haveHPEC}" ]; 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