Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 1999 10:19:10 +0200
From:      Sheldon Hearn <sheldonh@uunet.co.za>
To:        current@freebsd.org
Subject:   REQ: Test /etc/rc clean-up
Message-ID:  <21889.935137150@axl.noc.iafrica.com>

next in thread | raw e-mail | index | archive | help

Hi folks,

I have a diff for src/etc/rc that I'd like to have had used on a few
machines before I commit it. I'm pretty sure I haven't made any mistakes
with my changes, but you can never be too careful, right?

The diff homogenizes the manner in which variables are tested and is
more careful about using variables in a manner that avoids potential
problems that are unlikely to occur. I see it as a mostly cosmetic, but
healthy change.

Ciao,
Sheldon.

Index: rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.193
diff -u -d -r1.193 rc
--- rc	1999/08/06 06:22:43	1.193
+++ rc	1999/08/17 15:36:04
@@ -45,15 +45,15 @@
 	ccdconfig -C
 fi
 
-if [ X$start_vinum = XYES ]; then
+if [ X"${start_vinum}" = X"YES" ]; then
 	vinum start
-elif [ -n "$vinum_drives" ]; then
-	vinum read $vinum_drives
+elif [ -n "${vinum_drives}" ]; then
+	vinum read ${vinum_drives}
 fi
 
 swapon -a
 
-if [ $1x = autobootx ]; then
+if [ X"$1" = X"autoboot" ]; then
 	echo Automatic reboot in progress...
 	fsck -p
 	case $? in
@@ -95,7 +95,7 @@
 # diskless boot it does not have to be.
 #
 
-if [ "X$root_rw_mount" != "XNO" ]; then
+if [ X"${root_rw_mount}" != X"NO" ]; then
 	mount -u -o rw /
 fi
 
@@ -106,7 +106,7 @@
 
 umount -a >/dev/null 2>&1
 
-if [ "X$early_nfs_mounts" != "XYES" ]; then
+if [ X"${early_nfs_mounts}" != X"YES" ]; then
 	mount -a -t nonfs
 else
 	mount -a
@@ -119,9 +119,9 @@
 # Run custom disk mounting function here
 #
 
-if [ "X$diskless_mount" != "X" ]; then
-	if [ -f $diskless_mount ]; then
-		sh $diskless_mount
+if [ X"${diskless_mount}" != X"" ]; then
+	if [ -f ${diskless_mount} ]; then
+		sh ${diskless_mount}
 	fi
 fi
 
@@ -148,9 +148,9 @@
 fi
 
 # Add additional swapfile, if configured.
-if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then
-	echo "Adding $swapfile as additional swap."
-	vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b
+if [ X"${swapfile}" != X"NO" -a -w "${swapfile}" -a -b /dev/vn0b ]; then
+	echo "Adding ${swapfile} as additional swap."
+	vnconfig /dev/vn0b ${swapfile} && swapon /dev/vn0b
 fi
 
 # set sysctl variables early as we can
@@ -195,7 +195,7 @@
 #
 # See also the example of another cleanup policy in /etc/periodic/daily.
 #
-if [ "X${clear_tmp_enable}" = X"YES" ]; then
+if [ X"${clear_tmp_enable}" = X"YES" ]; then
 	echo clearing /tmp
 
 	# prune quickly with one rm, then use find to clean up /tmp/[lq]*
@@ -217,7 +217,7 @@
 # start system logging and name service (named needs to start before syslogd
 # if you don't have a /etc/resolv.conf)
 #
-if [ "X${syslogd_enable}" = X"YES" ]; then
+if [ X"${syslogd_enable}" = X"YES" ]; then
 	# Transitional symlink (for the next couple of years :) until all
 	# binaries had a chance to move towards /var/run/log.
 	if [ ! -h /dev/log ] ; then
@@ -233,21 +233,21 @@
 # enable dumpdev so that savecore can see it
 # /var/crash should be a directory or a symbolic link
 # to the crash directory if core dumps are to be saved.
-if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} -a -d /var/crash ]; then
+if [ X"${dumpdev}" != X"NO" -a -e ${dumpdev} -a -d /var/crash ]; then
 	dumpon ${dumpdev}
 	echo -n checking for core dump...
 	savecore /var/crash
 fi
 
-if [ -n "$network_pass1_done" ]; then
+if [ -n "${network_pass1_done}" ]; then
 	network_pass2
 fi
 
 # Enable/Check the quotas (must be after ypbind if using NIS)
-if [ "X${enable_quotas}" = X"YES" ]; then
+if [ X"${enable_quotas}" = X"YES" ]; then
 
     # Only check quotas if they have been previously enabled, and requested
-    if [ "X${check_quotas}" = X"YES" ]; then
+    if [ X"${check_quotas}" = X"YES" ]; then
             echo -n 'checking quotas:'
             quotacheck -a
             echo ' done.'
@@ -258,7 +258,7 @@
         echo ' done.'
 fi
 
-if [ -n "$network_pass2_done" ]; then
+if [ -n "${network_pass2_done}" ]; then
 	network_pass3
 fi
 
@@ -274,7 +274,7 @@
 	"password file may be incorrect -- /etc/ptmp exists"
 fi
 
-if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then
+if [ X"${accounting_enable}" = X"YES" -a -d /var/account ]; then
 	echo 'turning on accounting'
 	if [ ! -e /var/account/acct ]; then
 		touch /var/account/acct
@@ -287,7 +287,7 @@
 if [ -x /sbin/ldconfig ]; then
 	if [ X"`/usr/bin/objformat`" = X"elf" ]; then
 		_LDC=/usr/lib
-		for i in $ldconfig_paths; do
+		for i in ${ldconfig_paths}; do
 			if test -d $i; then
 				_LDC="${_LDC} $i"
 			fi
@@ -301,7 +301,7 @@
 		# Default the a.out ldconfig path.
 		: ${ldconfig_paths_aout=${ldconfig_paths}}
 		_LDC=/usr/lib/aout
-		for i in $ldconfig_paths_aout; do
+		for i in ${ldconfig_paths_aout}; do
 			if test -d $i; then
 				_LDC="${_LDC} $i"
 			fi
@@ -314,23 +314,23 @@
 # Now start up miscellaneous daemons that don't belong anywhere else
 #
 echo -n starting standard daemons:
-if [ "X${inetd_enable}" != X"NO" ]; then
+if [ X"${inetd_enable}" != X"NO" ]; then
 	echo -n ' inetd';	inetd ${inetd_flags}
 fi
 
-if [ "X${cron_enable}" != X"NO" ]; then
+if [ X"${cron_enable}" != X"NO" ]; then
 	echo -n ' cron';	cron
 fi
 
-if [ "X${lpd_enable}" = X"YES" ]; then
+if [ X"${lpd_enable}" = X"YES" ]; then
 	echo -n ' printer';		${lpd_program} ${lpd_flags}
 fi
 
-if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then
+if [ X"${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then
 	echo -n ' sendmail';	/usr/sbin/sendmail ${sendmail_flags}
 fi
 
-if [ "X${usbd_enable}" = X"YES" ]; then
+if [ X"${usbd_enable}" = X"YES" ]; then
 	echo -n ' usbd';	/usr/sbin/usbd ${usbd_flags}
 fi
 
@@ -344,9 +344,9 @@
 
 # Recover vi editor files.
 vibackup=`echo /var/tmp/vi.recover/vi.*`
-if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then
+if [ X"${vibackup}" != X'/var/tmp/vi.recover/vi.*' ]; then
 	echo 'Recovering vi editor sessions'
-	for i in $vibackup; do
+	for i in ${vibackup}; do
 		# Only test files that are readable.
 		if test ! -r $i; then
 			continue
@@ -362,8 +362,8 @@
 	# It is possible to get incomplete recovery files, if the editor
 	# crashes at the right time.
 	virecovery=`echo /var/tmp/vi.recover/recover.*`
-	if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
-		for i in $virecovery; do
+	if [ "${virecovery}" != '/var/tmp/vi.recover/recover.*' ]; then
+		for i in ${virecovery}; do
 			# Only test files that are readable.
 			if test ! -r $i; then
 				continue
@@ -373,7 +373,7 @@
 			# corrupted, or that have no corresponding backup file.
 			# Else send mail to the user.
 			recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
-			if test -n "$recfile" -a -s "$recfile"; then
+			if test -n "${recfile}" -a -s "${recfile}"; then
 				sendmail -t < $i
 			else
 				rm -f $i
@@ -388,7 +388,7 @@
 fi
 
 # for each valid dir in $local_startup, search for init scripts matching *.sh
-if [ "X${local_startup}" != X"NO" ]; then
+if [ X"${local_startup}" != X"NO" ]; then
 	echo -n 'Local package initialization:'
 	for dir in ${local_startup}; do
 		[ -d ${dir} ] && for script in ${dir}/*.sh; do
@@ -437,7 +437,7 @@
 
 # Raise kernel security level.  This should be done only after `fsck' has
 # repaired local file systems if you want the securelevel to be greater than 1.
-if [ "X${kern_securelevel_enable}" = X"YES" -a "${kern_securelevel}" -ge 0 ]; 
+if [ X"${kern_securelevel_enable}" = X"YES" -a "${kern_securelevel}" -ge 0 ]; 
 then
 	echo 'Raising kernel security level'
 	sysctl -w kern.securelevel=${kern_securelevel}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?21889.935137150>