SVN: rc-scripts/trunk/sysconfig/network-scripts/functions.network

glen glen at pld-linux.org
Mon Mar 24 20:16:04 CET 2008


Author: glen
Date: Mon Mar 24 20:16:03 2008
New Revision: 9667

Modified:
   rc-scripts/trunk/sysconfig/network-scripts/functions.network
Log:
- return val doc for check_{mii_tool,ethtool,iwconfig}
- code readability

Modified: rc-scripts/trunk/sysconfig/network-scripts/functions.network
==============================================================================
--- rc-scripts/trunk/sysconfig/network-scripts/functions.network	(original)
+++ rc-scripts/trunk/sysconfig/network-scripts/functions.network	Mon Mar 24 20:16:03 2008
@@ -41,7 +41,7 @@
 {
 	# Notify programs that have requested notification
 	( cd /var/run/netreport || exit
-	for i in * ; do
+	for i in *; do
 		[ -f $i ] && kill -SIGIO $i >/dev/null 2>&1 || \
 			rm -f $i >/dev/null 2>&1
 	done
@@ -51,8 +51,7 @@
 need_hostname()
 {
 	local hostname=$(hostname)
-	if [ "$hostname" = "(none)" -o "$hostname" = "localhost" -o \
-	     "$hostname" = "localhost.localdomain" ]; then
+	if [ "$hostname" = "(none)" -o "$hostname" = "localhost" -o "$hostname" = "localhost.localdomain" ]; then
 		NEEDHOSTNAME=yes
 	else
 		unset NEEDHOSTNAME
@@ -72,7 +71,8 @@
 	fi
 
 	if [ "$domain" ]; then
-		>/etc/resolv.conf.new
+		# XXX umask and possible /etc/resolv.conf symlink breakage
+		> /etc/resolv.conf.new
 		if ! grep -q "search $domain" /etc/resolv.conf ; then
 			echo "search $domain" >> /etc/resolv.conf.new
 		fi
@@ -562,28 +562,48 @@
 	fi
 }
 
+# returns
+# 0 - no link
+# 1 - link ok
+# 2 - unsupported, unknown return
 check_mii_tool ()
 {
 	[ -x /sbin/mii-tool ] || return 2
 	output=$(LC_ALL=C mii-tool $1 2>&1)
 	echo $output | grep -q "link ok" && return 1
-	echo $output | grep -q "no link" && return 0 || return 2
+	echo $output | grep -q "no link" && return 0
+	return 2
 }
 
+# returns
+# 0 - link off
+# 1 - link on
+# 2 - unsupported, unknown return
 check_ethtool ()
 {
 	[ -x /sbin/ethtool ] || return 2
 	output=$(LC_ALL=C ethtool $1 2>&1)
 	echo $output | grep -q "Link detected: yes" && return 1
-	echo $output | grep -q "Link detected: no" && return 0 || return 2
+	echo $output | grep -q "Link detected: no" && return 0
+	return 2
 }
 
+# returns
+# 0 - radio off
+# 1 - radio on
+# 2 - unsupported
 check_iwconfig ()
 {
 	[ -x /sbin/iwconfig ] || return 2
-	LC_ALL=C iwconfig "$1" 2>&1 | grep -q "radio off" && return 0 || return 2
+	output=$(LC_ALL=C iwconfig "$1" 2>&1)
+	echo "$output" | grep -q "radio off" && return 0
+	# XXX why no 'radio on' check?
+	return 2
 }
 
+# returns
+# 0 - link down
+# 1 - link up
 check_link_down ()
 {
 	if [ -x /sbin/mii-tool -o -x /sbin/ethtool -o -x /sbin/iwconfig ]; then


More information about the pld-cvs-commit mailing list