Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Aug 1999 11:20:42 -0700 (PDT)
From:      "Rodney W. Grimes" <freebsd@gndrsh.dnsmgr.net>
To:        sheldonh@uunet.co.za (Sheldon Hearn)
Cc:        current@FreeBSD.ORG
Subject:   Re: REQ: Test /etc/rc clean-up
Message-ID:  <199908201820.LAA24083@gndrsh.dnsmgr.net>
In-Reply-To: <21889.935137150@axl.noc.iafrica.com> from Sheldon Hearn at "Aug 20, 1999 10:19:10 am"

next in thread | previous 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?

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.

Looks good, it's been quite some time since someone applied the
style rules to the src/etc tree...
----------------------------
revision 1.48
date: 1995/03/21 15:20:47;  author: jkh;  state: Exp;  lines: +59 -49
Begin a long-overdue cleanup of this whole mess.

1. Move all system configuration variables into /etc/sysconfig
2. Adapt other files to use it.
3. Add a host of new variables for micro-managing your system in various
   ways.  For 2.1, /etc/sysconfig will be machine-edited so that the user
   doesn't even have to care at all about the various funny names we picked.
4. Enable dset.  We won't get it debugged if we never use it, and no one
   has said anything negative about it yet, so here goes!
5. Try to use one consistent style throughout.
----------------------------

(#5 being the last time I can find that this was done to the file...)

I always wanted a knob on sh so that variables _had_ to be of the
form ${name} just so I could run my scripts through it so it would
find all of these types of things for me.

> 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
> 


-- 
Rod Grimes - KD7CAX - (RWG25)                    rgrimes@gndrsh.dnsmgr.net


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?199908201820.LAA24083>