Package: initscripts
Version: 2.88dsf-18
Severity: minor
Tags: patch

Dear Maintainer,

Please find attached a series of 21 patches, attempt to cleanup,
robustify and improve performance and maintability of that script
(triggerd by bug#625726.

These patches do not improve error handling, although such an effort
would be prized.


-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 3.1.0-1-686-pae (SMP w/2 CPU cores)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash

Versions of packages initscripts depends on:
ii  coreutils       8.13-3
ii  debianutils     4.1
ii  libc6           2.13-23
ii  lsb-base        3.2-28
ii  mount           2.20.1-1
ii  sysv-rc         2.88dsf-18
ii  sysvinit-utils  2.88dsf-18

Versions of packages initscripts recommends:
ii  e2fsprogs  1.42-1
ii  psmisc     22.14-1

initscripts suggests no packages.

-- Configuration Files:
/etc/init.d/bootlogd changed [not included]

-- no debconf information


Cheers,

-- 
Cristian
From 5ee806120d466bd4795a822de83ba8e1255dd238 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:26:06 +0100
Subject: [PATCH 01/21] Cleaned up end-of-line whitespace.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index e6bc833..d4ee06f 100755
--- a/mountnfs
+++ b/mountnfs
@@ -19,7 +19,7 @@ set_env() {
 	# Read through fstab line by line. If it is NFS, set the flag
 	# for mounting NFS file systems. If any NFS partition is found and it
 	# not mounted with the nolock option, we start the portmapper.
-	# 
+	#
 	# If any sec={krb5,krb5i,krb5p} option is given, or any of the file
 	# systems are nfs4, we'll need to start rpc.gssd and/or rpc.idmapd too;
 	# we'll leave that to nfs-common.
-- 
1.7.7.3

From a67d8952dfbcc194bee6580c9a5a924373b5916e Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:29:18 +0100
Subject: [PATCH 02/21] Cleaned up space-followed-by-tab.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mountnfs b/mountnfs
index d4ee06f..4668abe 100755
--- a/mountnfs
+++ b/mountnfs
@@ -47,12 +47,12 @@ set_env() {
 		esac
 		case "$FSTYPE" in
 		  nfs)
-		  	# NFS filsystems normally require statd and portmap. However,
+			# NFS filsystems normally require statd and portmap. However,
 			# if nolock is set, portmap and statd are not required for this
 			# file system.
 			case "$OPTS" in
 			  nolock|*,nolock|nolock,*|*,nolock,*)
-			  	# no action
+				# no action
 				;;
 			  *)
 				start_nfs=yes
@@ -63,7 +63,7 @@ set_env() {
 			case "$OPTS" in
 			  sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
 
-			  	start_nfs=yes
+				start_nfs=yes
 				;;
 			esac
 			;;
-- 
1.7.7.3

From cdb4716ee41dca22bd64437c1981d832366581d9 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:31:37 +0100
Subject: [PATCH 03/21] Cleaned up indentation whitespace.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mountnfs b/mountnfs
index 4668abe..791cc31 100755
--- a/mountnfs
+++ b/mountnfs
@@ -118,7 +118,7 @@ do_start() {
 
 exit_unless_last_interface() {
     ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces  | \
-        sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
+	sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
     for i in $ifaces ; do
 	if ! grep -q $i /etc/network/run/ifstate ; then
 	    msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
@@ -159,7 +159,7 @@ if [ no != "$ASYNCMOUNTNFS" ]; then
     fi
 
     on_exit() {
-        # Clean up lock when script exits, even if it is interrupted
+	# Clean up lock when script exits, even if it is interrupted
 	rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
     }
     trap on_exit EXIT # Enable emergency handler
-- 
1.7.7.3

From e4cdfadea6340b7b94e88ef29b4191c4a287597e Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:38:05 +0100
Subject: [PATCH 04/21] Various whitespace cleanup.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/mountnfs b/mountnfs
index 791cc31..57a2cd7 100755
--- a/mountnfs
+++ b/mountnfs
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
 # Description:       Now that TCP/IP is configured, mount the NFS file
 #                    systems in /etc/fstab if needed. If possible,
 #                    start the portmapper before mounting (this is needed for
@@ -62,7 +62,6 @@ set_env() {
 			# However, Kerberos requires gssd, so start nfs-common anyway.
 			case "$OPTS" in
 			  sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
-
 				start_nfs=yes
 				;;
 			esac
@@ -119,8 +118,8 @@ do_start() {
 exit_unless_last_interface() {
     ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces  | \
 	sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
-    for i in $ifaces ; do
-	if ! grep -q $i /etc/network/run/ifstate ; then
+    for i in $ifaces; do
+	if ! grep -q $i /etc/network/run/ifstate; then
 	    msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
 	    log_warning_msg "$msg"
 	    exit 0
@@ -142,13 +141,13 @@ if [ no != "$ASYNCMOUNTNFS" ]; then
     [ "$IFACE" != "lo" ] || exit 0
 
     # Lock around this otherwise insanity may occur
-    mkdir /var/run/network          2>/dev/null || true
+    mkdir /var/run/network 2>/dev/null || true
 
     # Wait until all auto interfaces are up before attemting to mount
     # network file systems.
     exit_unless_last_interface
 
-    if mkdir /var/run/network/mountnfs 2>/dev/null ; then
+    if mkdir /var/run/network/mountnfs 2>/dev/null; then
 	:
     else
 	msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting"
@@ -164,6 +163,6 @@ if [ no != "$ASYNCMOUNTNFS" ]; then
     }
     trap on_exit EXIT # Enable emergency handler
     do_start
-elif [ yes = "$FROMINITD" ] ; then
+elif [ yes = "$FROMINITD" ]; then
     do_start
 fi
-- 
1.7.7.3

From 344e31ec2f25135427da78e7aa2deebedf7d9aef Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:43:07 +0100
Subject: [PATCH 05/21] Uniformized some command syntax.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/mountnfs b/mountnfs
index 57a2cd7..506c292 100755
--- a/mountnfs
+++ b/mountnfs
@@ -30,8 +30,7 @@ set_env() {
 	start_nfs=no
 	NETFS=""
 	NETDEV=""
-	while read DEV MTPT FSTYPE OPTS REST
-	do
+	while read DEV MTPT FSTYPE OPTS REST; do
 		case "$DEV" in
 		  ""|\#*)
 			continue
@@ -76,8 +75,7 @@ set_env() {
 			FSTYPE=
 			;;
 		esac
-		if [ "$FSTYPE" ]
-		then
+		if [ "$FSTYPE" ]; then
 			case "$NETFS" in
 			  $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
 				;;
@@ -97,16 +95,14 @@ do_start() {
 	# and/or rpc.idmapd, and loads the right kernel modules if
 	# applicable) if we use Kerberos and/or NFSv4 mounts.
 	#
-	if [ "$start_nfs" = yes ] && [ -x /etc/init.d/nfs-common ]
-	then
+	if [ "$start_nfs" = yes ] && [ -x /etc/init.d/nfs-common ]; then
 		[ -x /etc/init.d/portmap ] && /etc/init.d/portmap start
 		[ -x /etc/init.d/rpcbind ] && /etc/init.d/rpcbind start
 		/etc/init.d/nfs-common start
 	fi
 
 	pre_mountall
-	if [ "$NETFS" ]
-	then
+	if [ "$NETFS" ]; then
 		mount -a -t$NETFS
 	fi
 	if [ "$NETDEV" ]; then
-- 
1.7.7.3

From 37f3c3f9a8aee31806c72e7e1fc53924db0453ae Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:49:08 +0100
Subject: [PATCH 06/21] Reindented some parts.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   74 +++++++++++++++++++++++++++++++-------------------------------
 1 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/mountnfs b/mountnfs
index 506c292..bb8c2e9 100755
--- a/mountnfs
+++ b/mountnfs
@@ -112,15 +112,15 @@ do_start() {
 }
 
 exit_unless_last_interface() {
-    ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces  | \
-	sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
-    for i in $ifaces; do
-	if ! grep -q $i /etc/network/run/ifstate; then
-	    msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
-	    log_warning_msg "$msg"
-	    exit 0
-	fi
-    done
+	ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces | \
+		sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
+	for i in $ifaces; do
+		if ! grep -q $i /etc/network/run/ifstate; then
+			msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
+			log_warning_msg "$msg"
+			exit 0
+		fi
+	done
 }
 
 # Using 'no !=' instead of 'yes =' to make sure async nfs mounting is
@@ -129,36 +129,36 @@ set_env
 # Exit imediately and do not claim to wait for the last interface if
 # no network file systems are listed in /etc/fstab.
 if [ "$start_nfs" = "no" ] && [ ! "$NETFS" ] && [ ! "$NETDEV" ]; then
-  exit 0
+	exit 0
 fi
 
 if [ no != "$ASYNCMOUNTNFS" ]; then
-    # Not for loopback!
-    [ "$IFACE" != "lo" ] || exit 0
-
-    # Lock around this otherwise insanity may occur
-    mkdir /var/run/network 2>/dev/null || true
-
-    # Wait until all auto interfaces are up before attemting to mount
-    # network file systems.
-    exit_unless_last_interface
-
-    if mkdir /var/run/network/mountnfs 2>/dev/null; then
-	:
-    else
-	msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting"
-	log_failure_msg "$msg"
-	# Log if /usr/ is mounted
-	[ -x /usr/bin/logger ] && /usr/bin/logger -t "if-up.d/mountnfs[$IFACE]" "$msg"
-	exit 0
-    fi
-
-    on_exit() {
-	# Clean up lock when script exits, even if it is interrupted
-	rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
-    }
-    trap on_exit EXIT # Enable emergency handler
-    do_start
+	# Not for loopback!
+	[ "$IFACE" != "lo" ] || exit 0
+
+	# Lock around this otherwise insanity may occur
+	mkdir /var/run/network 2>/dev/null || true
+
+	# Wait until all auto interfaces are up before attemting to mount
+	# network file systems.
+	exit_unless_last_interface
+
+	if mkdir /var/run/network/mountnfs 2>/dev/null; then
+		:
+	else
+		msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting"
+		log_failure_msg "$msg"
+		# Log if /usr/ is mounted
+		[ -x /usr/bin/logger ] && /usr/bin/logger -t "if-up.d/mountnfs[$IFACE]" "$msg"
+		exit 0
+	fi
+
+	on_exit() {
+		# Clean up lock when script exits, even if it is interrupted
+		rmdir /var/run/network/mountnfs 2>/dev/null || exit 0
+	}
+	trap on_exit EXIT # Enable emergency handler
+	do_start
 elif [ yes = "$FROMINITD" ]; then
-    do_start
+	do_start
 fi
-- 
1.7.7.3

From ed7023160ecfe8d06bffeda1269b54798aa554e7 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:51:10 +0100
Subject: [PATCH 07/21] '|' is a control operator, therefore '\' is
 superfluous.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index bb8c2e9..a7e71da 100755
--- a/mountnfs
+++ b/mountnfs
@@ -112,7 +112,7 @@ do_start() {
 }
 
 exit_unless_last_interface() {
-	ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces | \
+	ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces |
 		sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
 	for i in $ifaces; do
 		if ! grep -q $i /etc/network/run/ifstate; then
-- 
1.7.7.3

From cc5e4cea32217dfdbdd6d81b7cd8bf9226745c2b Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 10:53:39 +0100
Subject: [PATCH 08/21] Use correct character class (s/space/blank/).

`man tr'
	[:space:]
		all horizontal or vertical whitespace
		               ^^^^^^^^^^^
We're interested just in horizontal whitespace.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index a7e71da..f95ea85 100755
--- a/mountnfs
+++ b/mountnfs
@@ -112,7 +112,7 @@ do_start() {
 }
 
 exit_unless_last_interface() {
-	ifaces="$(grep "^[[:space:]]*auto" /etc/network/interfaces |
+	ifaces="$(grep "^[[:blank:]]*auto" /etc/network/interfaces |
 		sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
 	for i in $ifaces; do
 		if ! grep -q $i /etc/network/run/ifstate; then
-- 
1.7.7.3

From c033def2f7d0149b03f840d84770c0e78d1146c6 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:01:02 +0100
Subject: [PATCH 09/21] Extended use [:blank:] character class.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index f95ea85..558881e 100755
--- a/mountnfs
+++ b/mountnfs
@@ -113,7 +113,7 @@ do_start() {
 
 exit_unless_last_interface() {
 	ifaces="$(grep "^[[:blank:]]*auto" /etc/network/interfaces |
-		sed -e 's/[ \t]*auto[ \t]*//;s/[ \t]*$//;s/[ \t]/\n/g')"
+		sed -e 's/[[:blank:]]*auto[[:blank:]]*//;s/[[:blank:]]*$//;s/[[:blank:]]/\n/g')"
 	for i in $ifaces; do
 		if ! grep -q $i /etc/network/run/ifstate; then
 			msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
-- 
1.7.7.3

From 07e742f6945bffd2e9918db27ef5dbdda457bfa7 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:39:10 +0100
Subject: [PATCH 10/21] Eliminate a 'grep' fork.  'sed' can do that too.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/mountnfs b/mountnfs
index 558881e..5fd11dc 100755
--- a/mountnfs
+++ b/mountnfs
@@ -112,8 +112,7 @@ do_start() {
 }
 
 exit_unless_last_interface() {
-	ifaces="$(grep "^[[:blank:]]*auto" /etc/network/interfaces |
-		sed -e 's/[[:blank:]]*auto[[:blank:]]*//;s/[[:blank:]]*$//;s/[[:blank:]]/\n/g')"
+	ifaces="$(sed -ne '/^[[:blank:]]*auto[[:blank:]]*/{s/^[[:blank:]]*auto[[:blank:]]*//;s/[[:blank:]]*$//;s/[[:blank:]]\+/\n/g;p}' /etc/network/interfaces)"
 	for i in $ifaces; do
 		if ! grep -q $i /etc/network/run/ifstate; then
 			msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
-- 
1.7.7.3

From 64a9bab2e22774b6b652df88d3a3ba8d75fd3030 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:41:36 +0100
Subject: [PATCH 11/21] Removed useless quotes.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index 5fd11dc..ba2a739 100755
--- a/mountnfs
+++ b/mountnfs
@@ -112,7 +112,7 @@ do_start() {
 }
 
 exit_unless_last_interface() {
-	ifaces="$(sed -ne '/^[[:blank:]]*auto[[:blank:]]*/{s/^[[:blank:]]*auto[[:blank:]]*//;s/[[:blank:]]*$//;s/[[:blank:]]\+/\n/g;p}' /etc/network/interfaces)"
+	ifaces=$(sed -ne '/^[[:blank:]]*auto[[:blank:]]*/{s/^[[:blank:]]*auto[[:blank:]]*//;s/[[:blank:]]*$//;s/[[:blank:]]\+/\n/g;p}' /etc/network/interfaces)
 	for i in $ifaces; do
 		if ! grep -q $i /etc/network/run/ifstate; then
 			msg="if-up.d/mountnfs[$IFACE]: waiting for interface $i before doing NFS mounts"
-- 
1.7.7.3

From d22706e097215d6990f6bfc5256997cac58717e8 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:45:12 +0100
Subject: [PATCH 12/21] Removed more useless quotes.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/mountnfs b/mountnfs
index ba2a739..4b62fdb 100755
--- a/mountnfs
+++ b/mountnfs
@@ -28,15 +28,15 @@ set_env() {
 	exec 9<&0 </etc/fstab
 
 	start_nfs=no
-	NETFS=""
-	NETDEV=""
+	NETFS=
+	NETDEV=
 	while read DEV MTPT FSTYPE OPTS REST; do
-		case "$DEV" in
+		case $DEV in
 		  ""|\#*)
 			continue
 			;;
 		esac
-		case "$OPTS" in
+		case $OPTS in
 		  noauto|*,noauto|noauto,*|*,noauto,*)
 			continue
 			;;
@@ -44,12 +44,12 @@ set_env() {
 			NETDEV=yes
 			;;
 		esac
-		case "$FSTYPE" in
+		case $FSTYPE in
 		  nfs)
 			# NFS filsystems normally require statd and portmap. However,
 			# if nolock is set, portmap and statd are not required for this
 			# file system.
-			case "$OPTS" in
+			case $OPTS in
 			  nolock|*,nolock|nolock,*|*,nolock,*)
 				# no action
 				;;
@@ -59,7 +59,7 @@ set_env() {
 			esac
 
 			# However, Kerberos requires gssd, so start nfs-common anyway.
-			case "$OPTS" in
+			case $OPTS in
 			  sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
 				start_nfs=yes
 				;;
@@ -76,7 +76,7 @@ set_env() {
 			;;
 		esac
 		if [ "$FSTYPE" ]; then
-			case "$NETFS" in
+			case $NETFS in
 			  $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
 				;;
 			  *)
@@ -127,13 +127,13 @@ exit_unless_last_interface() {
 set_env
 # Exit imediately and do not claim to wait for the last interface if
 # no network file systems are listed in /etc/fstab.
-if [ "$start_nfs" = "no" ] && [ ! "$NETFS" ] && [ ! "$NETDEV" ]; then
+if [ "$start_nfs" = no ] && [ ! "$NETFS" ] && [ ! "$NETDEV" ]; then
 	exit 0
 fi
 
 if [ no != "$ASYNCMOUNTNFS" ]; then
 	# Not for loopback!
-	[ "$IFACE" != "lo" ] || exit 0
+	[ "$IFACE" != lo ] || exit 0
 
 	# Lock around this otherwise insanity may occur
 	mkdir /var/run/network 2>/dev/null || true
-- 
1.7.7.3

From 752aa06e86ecdc924c718fb18afe44caca16a207 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:47:36 +0100
Subject: [PATCH 13/21] Use correct test operator.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index 4b62fdb..f51638d 100755
--- a/mountnfs
+++ b/mountnfs
@@ -127,7 +127,7 @@ exit_unless_last_interface() {
 set_env
 # Exit imediately and do not claim to wait for the last interface if
 # no network file systems are listed in /etc/fstab.
-if [ "$start_nfs" = no ] && [ ! "$NETFS" ] && [ ! "$NETDEV" ]; then
+if [ "$start_nfs" = no ] && [ -z "$NETFS" ] && [ -z "$NETDEV" ]; then
 	exit 0
 fi
 
-- 
1.7.7.3

From 58bce19e531bfe2cf5b3cddf0cdf576316a944f2 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:48:47 +0100
Subject: [PATCH 14/21] Optimized test; removed useless ':' command.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/mountnfs b/mountnfs
index f51638d..9cee9b4 100755
--- a/mountnfs
+++ b/mountnfs
@@ -142,9 +142,7 @@ if [ no != "$ASYNCMOUNTNFS" ]; then
 	# network file systems.
 	exit_unless_last_interface
 
-	if mkdir /var/run/network/mountnfs 2>/dev/null; then
-		:
-	else
+	if ! mkdir /var/run/network/mountnfs 2>/dev/null; then
 		msg="if-up.d/mountnfs[$IFACE]: lock /var/run/network/mountnfs exist, not mounting"
 		log_failure_msg "$msg"
 		# Log if /usr/ is mounted
-- 
1.7.7.3

From 173a1bfb119e00d4e0310524a716d1f196e744c5 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:49:54 +0100
Subject: [PATCH 15/21] Use builtin ':', 'true' alternative.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mountnfs b/mountnfs
index 9cee9b4..1c10c8a 100755
--- a/mountnfs
+++ b/mountnfs
@@ -136,7 +136,7 @@ if [ no != "$ASYNCMOUNTNFS" ]; then
 	[ "$IFACE" != lo ] || exit 0
 
 	# Lock around this otherwise insanity may occur
-	mkdir /var/run/network 2>/dev/null || true
+	mkdir /var/run/network 2>/dev/null || :
 
 	# Wait until all auto interfaces are up before attemting to mount
 	# network file systems.
-- 
1.7.7.3

From 8fc00381f035a97d9cc848e7d02f2809d4f8d8f4 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:53:53 +0100
Subject: [PATCH 16/21] Use consistent syntax in tests.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mountnfs b/mountnfs
index 1c10c8a..e9cf7b3 100755
--- a/mountnfs
+++ b/mountnfs
@@ -131,7 +131,7 @@ if [ "$start_nfs" = no ] && [ -z "$NETFS" ] && [ -z "$NETDEV" ]; then
 	exit 0
 fi
 
-if [ no != "$ASYNCMOUNTNFS" ]; then
+if [ "$ASYNCMOUNTNFS" != no ]; then
 	# Not for loopback!
 	[ "$IFACE" != lo ] || exit 0
 
@@ -156,6 +156,6 @@ if [ no != "$ASYNCMOUNTNFS" ]; then
 	}
 	trap on_exit EXIT # Enable emergency handler
 	do_start
-elif [ yes = "$FROMINITD" ]; then
+elif [ "$FROMINITD" = yes ]; then
 	do_start
 fi
-- 
1.7.7.3

From 27ded560d9eea012d1da3308d62c0dde2161e5b8 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:57:15 +0100
Subject: [PATCH 17/21] START_NFS is a global variable; initialize outside
 functions.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/mountnfs b/mountnfs
index e9cf7b3..9cb737b 100755
--- a/mountnfs
+++ b/mountnfs
@@ -13,6 +13,8 @@ PATH=/sbin:/bin
 . /lib/lsb/init-functions
 . /lib/init/mount-functions.sh
 
+START_NFS=no
+
 set_env() {
 	[ -f /etc/fstab ] || return
 	#
@@ -27,7 +29,6 @@ set_env() {
 
 	exec 9<&0 </etc/fstab
 
-	start_nfs=no
 	NETFS=
 	NETDEV=
 	while read DEV MTPT FSTYPE OPTS REST; do
@@ -54,20 +55,20 @@ set_env() {
 				# no action
 				;;
 			  *)
-				start_nfs=yes
+				START_NFS=yes
 				;;
 			esac
 
 			# However, Kerberos requires gssd, so start nfs-common anyway.
 			case $OPTS in
 			  sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
-				start_nfs=yes
+				START_NFS=yes
 				;;
 			esac
 			;;
 		  nfs4)
 			# NFSv4 requires idmapd, so start nfs-common no matter what the options are.
-			start_nfs=yes
+			START_NFS=yes
 			;;
 		  smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs|ceph)
 			;;
@@ -95,7 +96,7 @@ do_start() {
 	# and/or rpc.idmapd, and loads the right kernel modules if
 	# applicable) if we use Kerberos and/or NFSv4 mounts.
 	#
-	if [ "$start_nfs" = yes ] && [ -x /etc/init.d/nfs-common ]; then
+	if [ "$START_NFS" = yes ] && [ -x /etc/init.d/nfs-common ]; then
 		[ -x /etc/init.d/portmap ] && /etc/init.d/portmap start
 		[ -x /etc/init.d/rpcbind ] && /etc/init.d/rpcbind start
 		/etc/init.d/nfs-common start
@@ -127,7 +128,7 @@ exit_unless_last_interface() {
 set_env
 # Exit imediately and do not claim to wait for the last interface if
 # no network file systems are listed in /etc/fstab.
-if [ "$start_nfs" = no ] && [ -z "$NETFS" ] && [ -z "$NETDEV" ]; then
+if [ "$START_NFS" = no ] && [ -z "$NETFS" ] && [ -z "$NETDEV" ]; then
 	exit 0
 fi
 
-- 
1.7.7.3

From 5408e3e7f28f135488643d49b17f47f63bf0825f Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 11:59:29 +0100
Subject: [PATCH 18/21] NETFS and NETDEV are globals too.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mountnfs b/mountnfs
index 9cb737b..87fa8f1 100755
--- a/mountnfs
+++ b/mountnfs
@@ -14,6 +14,8 @@ PATH=/sbin:/bin
 . /lib/init/mount-functions.sh
 
 START_NFS=no
+NETFS=
+NETDEV=
 
 set_env() {
 	[ -f /etc/fstab ] || return
@@ -29,8 +31,6 @@ set_env() {
 
 	exec 9<&0 </etc/fstab
 
-	NETFS=
-	NETDEV=
 	while read DEV MTPT FSTYPE OPTS REST; do
 		case $DEV in
 		  ""|\#*)
-- 
1.7.7.3

From 682c9a21e483ac1af4d1b54daff83d1718d39212 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 12:07:33 +0100
Subject: [PATCH 19/21] Declared function local variables.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/mountnfs b/mountnfs
index 87fa8f1..72e3ce2 100755
--- a/mountnfs
+++ b/mountnfs
@@ -18,6 +18,8 @@ NETFS=
 NETDEV=
 
 set_env() {
+	local DEV MTPT FSTYPE OPTS REST
+
 	[ -f /etc/fstab ] || return
 	#
 	# Read through fstab line by line. If it is NFS, set the flag
@@ -113,6 +115,8 @@ do_start() {
 }
 
 exit_unless_last_interface() {
+	local ifaces i msg
+
 	ifaces=$(sed -ne '/^[[:blank:]]*auto[[:blank:]]*/{s/^[[:blank:]]*auto[[:blank:]]*//;s/[[:blank:]]*$//;s/[[:blank:]]\+/\n/g;p}' /etc/network/interfaces)
 	for i in $ifaces; do
 		if ! grep -q $i /etc/network/run/ifstate; then
-- 
1.7.7.3

From e9b2672211365e8e19b76b9c8a2dd0344d6a81d7 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 12:13:15 +0100
Subject: [PATCH 20/21] Lower case local variables, to distinguish from
 global.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/mountnfs b/mountnfs
index 72e3ce2..ba517c3 100755
--- a/mountnfs
+++ b/mountnfs
@@ -18,7 +18,7 @@ NETFS=
 NETDEV=
 
 set_env() {
-	local DEV MTPT FSTYPE OPTS REST
+	local dev mtpt fstype opts rest
 
 	[ -f /etc/fstab ] || return
 	#
@@ -33,13 +33,13 @@ set_env() {
 
 	exec 9<&0 </etc/fstab
 
-	while read DEV MTPT FSTYPE OPTS REST; do
-		case $DEV in
+	while read dev mtpt fstype opts rest; do
+		case $dev in
 		  ""|\#*)
 			continue
 			;;
 		esac
-		case $OPTS in
+		case $opts in
 		  noauto|*,noauto|noauto,*|*,noauto,*)
 			continue
 			;;
@@ -47,12 +47,12 @@ set_env() {
 			NETDEV=yes
 			;;
 		esac
-		case $FSTYPE in
+		case $fstype in
 		  nfs)
 			# NFS filsystems normally require statd and portmap. However,
 			# if nolock is set, portmap and statd are not required for this
 			# file system.
-			case $OPTS in
+			case $opts in
 			  nolock|*,nolock|nolock,*|*,nolock,*)
 				# no action
 				;;
@@ -62,7 +62,7 @@ set_env() {
 			esac
 
 			# However, Kerberos requires gssd, so start nfs-common anyway.
-			case $OPTS in
+			case $opts in
 			  sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
 				START_NFS=yes
 				;;
@@ -75,15 +75,15 @@ set_env() {
 		  smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs|ceph)
 			;;
 		  *)
-			FSTYPE=
+			fstype=
 			;;
 		esac
-		if [ "$FSTYPE" ]; then
+		if [ "$fstype" ]; then
 			case $NETFS in
-			  $FSTYPE|*,$FSTYPE|$FSTYPE,*|*,$FSTYPE,*)
+			  $fstype|*,$fstype|$fstype,*|*,$fstype,*)
 				;;
 			  *)
-				NETFS="$NETFS${NETFS:+,}$FSTYPE"
+				NETFS="$NETFS${NETFS:+,}$fstype"
 				;;
 			esac
 		fi
-- 
1.7.7.3

From 0d974fd783ad23fae2c36e61e213015d81f290e0 Mon Sep 17 00:00:00 2001
From: Cristian Ionescu-Idbohrn <c...@axis.com>
Date: Fri, 23 Dec 2011 12:29:40 +0100
Subject: [PATCH 21/21] Split some long comment lines.

Signed-off-by: Cristian Ionescu-Idbohrn <c...@axis.com>
---
 mountnfs |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/mountnfs b/mountnfs
index ba517c3..a0c999b 100755
--- a/mountnfs
+++ b/mountnfs
@@ -49,9 +49,9 @@ set_env() {
 		esac
 		case $fstype in
 		  nfs)
-			# NFS filsystems normally require statd and portmap. However,
-			# if nolock is set, portmap and statd are not required for this
-			# file system.
+			# NFS filsystems normally require statd and portmap.
+			# However, if nolock is set, portmap and statd are not
+			# required for this file system.
 			case $opts in
 			  nolock|*,nolock|nolock,*|*,nolock,*)
 				# no action
@@ -61,7 +61,8 @@ set_env() {
 				;;
 			esac
 
-			# However, Kerberos requires gssd, so start nfs-common anyway.
+			# However, Kerberos requires gssd, so start nfs-common
+			# anyway.
 			case $opts in
 			  sec=krb5|*,sec=krb5|sec=krb5,*|*,sec=krb5,*|sec=krb5i|*,sec=krb5i|sec=krb5i,*|*,sec=krb5i,*|sec=krb5p|*,sec=krb5p|sec=krb5p,*|*,sec=krb5p,*)
 				START_NFS=yes
@@ -69,7 +70,8 @@ set_env() {
 			esac
 			;;
 		  nfs4)
-			# NFSv4 requires idmapd, so start nfs-common no matter what the options are.
+			# NFSv4 requires idmapd, so start nfs-common no matter
+		  	# what the options are.
 			START_NFS=yes
 			;;
 		  smbfs|cifs|coda|ncp|ncpfs|ocfs2|gfs|ceph)
-- 
1.7.7.3

Reply via email to