Hi folks,
What follows is a diff that presents Doug's changes (which must have
required quite a bit of effort, thanks!) in a slightly different format
which I think the grumpies here might prefer.
Specifically, case statements look more like what a lot of folks are
used to seeing, and conditionals that don't need to be case sensitive
have not been converted to case statements.
I think the effort which Doug has put into this is great and would make
for a better rc. It's a pity that a few cosmetic issues generated so
much pooh-pooh'ing. :-(
Ciao,
Sheldon.
Index: rc
===================================================================
RCS file: /home/ncvs/src/etc/rc,v
retrieving revision 1.194
diff -u -d -r1.194 rc
--- rc 1999/08/25 16:01:33 1.194
+++ rc 1999/08/27 12:26:46
@@ -8,24 +8,25 @@
# and the console is the controlling terminal.
# Note that almost all the user-configurable behavior is no longer in
-# this file, but rather in /etc/defaults/rc.conf. Please check this file
+# this file, but rather in /etc/defaults/rc.conf. Please check that file
# first before contemplating any changes here.
stty status '^T'
# Set shell to ignore SIGINT (2), but not children;
# shell catches SIGQUIT (3) and returns to single user after fsck.
+#
trap : 2
trap : 3 # shouldn't be needed
-HOME=/; export HOME
+HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
-export PATH
+export HOME PATH
# BOOTP diskless boot. We have to run the rc file early in order to
# retarget various config files.
#
-if [ -f /etc/rc.diskless1 ]; then
+if [ -r /etc/rc.diskless1 ]; then
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
if [ ${dlv:=0} != 0 ]; then
. /etc/rc.diskless1
@@ -34,22 +35,28 @@
# If there is a global system configuration file, suck it in.
#
-if [ -f /etc/defaults/rc.conf ]; then
+if [ -r /etc/defaults/rc.conf ]; then
. /etc/defaults/rc.conf
-elif [ -f /etc/rc.conf ]; then
+elif [ -r /etc/rc.conf ]; then
. /etc/rc.conf
fi
# Configure ccd devices.
-if [ -f /etc/ccd.conf ]; then
+#
+if [ -r /etc/ccd.conf ]; then
ccdconfig -C
fi
-if [ "${start_vinum}" = "YES" ]; then
+case ${start_vinum} in
+[Yy][Ee][Ss])
vinum start
-elif [ -n "${vinum_drives}" ]; then
- vinum read ${vinum_drives}
-fi
+ ;;
+*)
+ if [ -n "${vinum_drives}" ]; then
+ vinum read ${vinum_drives}
+ fi
+ ;;
+esac
swapon -a
@@ -94,35 +101,39 @@
# root normally must be read/write, but if this is a BOOTP NFS
# diskless boot it does not have to be.
#
-
-if [ "${root_rw_mount}" != "NO" ]; then
+case ${root_rw_mount} in
+[Nn][Oo])
+ ;;
+*)
mount -u -o rw /
-fi
+ ;;
+esac
if [ $? != 0 ]; then
echo "Filesystem mount failed, startup aborted"
+ echo "Mounting root filesystem rw failed, startup aborted"
exit 1
fi
umount -a >/dev/null 2>&1
-if [ "${early_nfs_mounts}" != "YES" ]; then
- mount -a -t nonfs
-else
+case ${early_nfs_mounts} in
+[Yy][Ee][Ss])
mount -a
-fi
+ ;;
+*)
+ mount -a -t nonfs
+ ;;
+esac
if [ $? != 0 ]; then
- echo "Filesystem mount failed, startup aborted"
+ echo "Mounting /etc/fstab filesystems failed, startup aborted"
exit 1
fi
# Run custom disk mounting function here
#
-
-if [ -n "${diskless_mount}" ]; then
- if [ -f "${diskless_mount}" ]; then
- sh ${diskless_mount}
- fi
+if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then
+ sh ${diskless_mount}
fi
adjkerntz -i
@@ -148,46 +159,64 @@
fi
# Add additional swapfile, if configured.
-if [ "${swapfile}" != "NO" -a -w "${swapfile}" -a -b /dev/vn0b ]; then
- echo "Adding ${swapfile} as additional swap."
- vnconfig /dev/vn0b ${swapfile} && swapon /dev/vn0b
-fi
+#
+case ${swapfile} in
+[Nn][Oo])
+ ;;
+*)
+ if [ -w "${swapfile}" -a -b /dev/vn0b ]; then
+ echo "Adding ${swapfile} as additional swap."
+ vnconfig /dev/vn0b ${swapfile} && swapon /dev/vn0b
+ fi
+ ;;
+esac
-# set sysctl variables early as we can
-if [ -f /etc/rc.sysctl ]; then
+# Set sysctl variables as early as we can
+#
+if [ -r /etc/rc.sysctl ]; then
. /etc/rc.sysctl
fi
-# configure serial devices
-if [ -f /etc/rc.serial ]; then
+# Configure serial devices
+#
+if [ -r /etc/rc.serial ]; then
. /etc/rc.serial
fi
-# start up PC-card configuration
-if [ -f /etc/rc.pccard ]; then
+# Start up PC-card configuration
+#
+if [ -r /etc/rc.pccard ]; then
. /etc/rc.pccard
fi
-# start up the initial network configuration.
-if [ -f /etc/rc.network ]; then
+# Start up the initial network configuration.
+#
+if [ -r /etc/rc.network ]; then
. /etc/rc.network # We only need to do this once.
network_pass1
fi
-echo -n "Mounting NFS file systems"
-mount -a -t nfs
-echo .
+case ${early_nfs_mounts} in
+[Yy][Ee][Ss])
+ ;;
+*)
+ echo -n "Mounting NFS file systems"
+ mount -a -t nfs
+ echo .
+ ;;
+esac
# Whack the pty perms back into shape.
+#
chflags 0 /dev/tty[pqrsPQRS]*
chmod 666 /dev/tty[pqrsPQRS]*
chown root:wheel /dev/tty[pqrsPQRS]*
-# clean up left-over files
+# Clean up left-over files
+#
clean_var # If it hasn't already been done
rm /var/run/clean_var
-#
# Clearing /tmp at boot-time seems to have a long tradition. It doesn't
# help in any way for long-living systems, and it might accidentally
# clobber files you would rather like to have preserved after a crash
@@ -195,100 +224,122 @@
#
# See also the example of another cleanup policy in /etc/periodic/daily.
#
-if [ "${clear_tmp_enable}" = "YES" ]; then
+case ${clear_tmp_enable} in
+[Yy][Ee][Ss])
echo clearing /tmp
- # prune quickly with one rm, then use find to clean up /tmp/[lq]*
+ # One quick rm, then use find to clean up /tmp/[lq]*
# (not needed with mfs /tmp, but doesn't hurt there...)
(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
find -d . ! -name . ! -name lost+found ! -name quota.user \
! -name quota.group -exec rm -rf -- {} \;)
-
-fi
+ ;;
+esac
-# Remove X lock files, since they will prevent you from restarting X11
+# Remove X lock files, since they will prevent you from restarting X11
# after a system crash.
+#
rm -f /tmp/.X*-lock /tmp/.X11-unix/*
# snapshot any kernel -c changes back to disk here <someday>
# this has changed with ELF and /kernel.config.
echo -n 'additional daemons:'
-# start system logging and name service (named needs to start before syslogd
-# if you don't have a /etc/resolv.conf)
+
+# Start system logging service (named needs to have started from rc.network
+# already if you don't have a /etc/resolv.conf)
#
-if [ "${syslogd_enable}" = "YES" ]; then
- # Transitional symlink (for the next couple of years :) until all
- # binaries had a chance to move towards /var/run/log.
+case ${syslogd_enable} in
+[Yy][Ee][Ss] )
+ # Transitional symlink (for the next couple of years :) until
+ # all binaries have had a chance to move towards /var/run/log.
if [ ! -h /dev/log ] ; then
# might complain for r/o root f/s
ln -sf /var/run/log /dev/log
fi
rm -f /var/run/log
- echo -n ' syslogd'; syslogd ${syslogd_flags}
-fi
+ echo -n ' syslogd'; syslogd ${syslogd_flags}
+ ;;
+esac
+
echo '.'
-# enable dumpdev so that savecore can see it
+# 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 [ "${dumpdev}" != "NO" -a -e ${dumpdev} -a -d /var/crash ]; then
- dumpon ${dumpdev}
- echo -n checking for core dump...
- savecore /var/crash
-fi
+#
+case ${dumpdev} in
+[Nn][Oo])
+ ;;
+*)
+ if [ -e ${dumpdev} -a -d /var/crash ]; then
+ dumpon ${dumpdev}
+ echo -n checking for core dump...
+ savecore /var/crash
+ fi
+ ;;
+esac
if [ -n "${network_pass1_done}" ]; then
network_pass2
fi
# Enable/Check the quotas (must be after ypbind if using NIS)
-if [ "${enable_quotas}" = "YES" ]; then
-
- # Only check quotas if they have been previously enabled, and requested
- if [ "${check_quotas}" = "YES" ]; then
- echo -n 'checking quotas:'
- quotacheck -a
- echo ' done.'
- fi
+#
+case ${enable_quotas} in
+[Yy][Ee][Ss])
+ case ${check_quotas} in
+ [Yy][Ee][Ss] )
+ echo -n 'checking quotas:'
+ quotacheck -a
+ echo ' done.'
+ ;;
+ esac
echo -n 'enabling quotas:'
quotaon -a
echo ' done.'
-fi
+ ;;
+esac
if [ -n "${network_pass2_done}" ]; then
network_pass3
fi
-# build ps databases
-kvm_mkdb
+# Build ps databases
+#
+kvm_mkdb
dev_mkdb
-# check the password temp/lock file
-if [ -f /etc/ptmp ]
-then
+# Check the password temp/lock file
+#
+if [ -e /etc/ptmp ]; then
logger -s -p auth.err \
"password file may be incorrect -- /etc/ptmp exists"
fi
-if [ "${accounting_enable}" = "YES" -a -d /var/account ]; then
- echo 'turning on accounting'
- if [ ! -e /var/account/acct ]; then
- touch /var/account/acct
+case ${accounting_enable} in
+[Yy][Ee][Ss])
+ if [ -d /var/account ]; then
+ echo 'turning on accounting'
+ if [ ! -e /var/account/acct ]; then
+ touch /var/account/acct
+ fi
+ accton /var/account/acct
fi
- accton /var/account/acct
-fi
+ ;;
+esac
# Make shared lib searching a little faster. Leave /usr/lib first if you
# add your own entries or you may come to grief.
+#
if [ -x /sbin/ldconfig ]; then
if [ "`/usr/bin/objformat`" = "elf" ]; then
_LDC=/usr/lib
for i in ${ldconfig_paths}; do
- if test -d ${i}; then
+ if [ -d ${i} ]; then
_LDC="${_LDC} ${i}"
fi
done
@@ -302,7 +353,7 @@
: ${ldconfig_paths_aout=${ldconfig_paths}}
_LDC=/usr/lib/aout
for i in ${ldconfig_paths_aout}; do
- if test -d ${i}; then
+ if [ -d ${i} ]; then
_LDC="${_LDC} ${i}"
fi
done
@@ -314,47 +365,65 @@
# Now start up miscellaneous daemons that don't belong anywhere else
#
echo -n starting standard daemons:
-if [ "${inetd_enable}" != "NO" ]; then
+case ${inetd_enable} in
+[Nn][Oo])
+ ;;
+*)
echo -n ' inetd'; inetd ${inetd_flags}
-fi
+ ;;
+esac
-if [ "${cron_enable}" != "NO" ]; then
+case ${cron_enable} in
+[Nn][Oo])
+ ;;
+*)
echo -n ' cron'; cron
-fi
+ ;;
+esac
-if [ "${lpd_enable}" = "YES" ]; then
- echo -n ' printer'; ${lpd_program} ${lpd_flags}
-fi
+case ${lpd_enable} in
+[Yy][Ee][Ss])
+ echo -n ' printer'; ${lpd_program} ${lpd_flags}
+ ;;
+esac
-if [ "${sendmail_enable}" = "YES" -a -r /etc/sendmail.cf ]; then
- echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
-fi
+case ${sendmail_enable} in
+[Yy][Ee][Ss])
+ if [ -r /etc/sendmail.cf ]; then
+ echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
+ fi
+ ;;
+esac
-if [ "${usbd_enable}" = "YES" ]; then
+case ${usbd_enable} in
+[Yy][Ee][Ss])
echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags}
-fi
+ ;;
+esac
echo '.'
-# configure implementation specific stuff
+# Configure implementation specific stuff
+#
arch=`uname -m`
-if [ -f /etc/rc.${arch} ]; then
+if [ -r /etc/rc.${arch} ]; then
. /etc/rc.${arch}
fi
# Recover vi editor files.
+#
vibackup=`echo /var/tmp/vi.recover/vi.*`
if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
echo 'Recovering vi editor sessions'
for i in ${vibackup}; do
# Only test files that are readable.
- if test ! -r ${i}; then
+ if [ ! -r ${i} ]; then
continue
fi
# Unmodified nvi editor backup files either have the
# execute bit set or are zero length. Delete them.
- if test -x ${i} -o ! -s ${i}; then
+ if [ -x ${i} -o ! -s ${i} ]; then
rm -f ${i}
fi
done
@@ -365,7 +434,7 @@
if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
for i in ${virecovery}; do
# Only test files that are readable.
- if test ! -r ${i}; then
+ if [ ! -r ${i} ]; then
continue
fi
@@ -373,7 +442,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 [ -n "${recfile}" -a -s "${recfile}" ]; then
sendmail -t < ${i}
else
rm -f ${i}
@@ -382,26 +451,40 @@
fi
fi
-# make a bounds file for msgs(1) if there isn't one already
+# Make a bounds file for msgs(1) if there isn't one already
+# "Delete important files with symlink" security hole?
+#
if [ ! -f /var/msgs/bounds ]; then
echo 0 > /var/msgs/bounds
fi
-# for each valid dir in $local_startup, search for init scripts matching *.sh
-if [ "${local_startup}" != "NO" ]; then
+# For each valid dir in $local_startup, search for init scripts matching *.sh
+#
+case ${local_startup} in
+[Nn][Oo])
+ ;;
+*)
echo -n 'Local package initialization:'
for dir in ${local_startup}; do
- [ -d ${dir} ] && for script in ${dir}/*.sh; do
- [ -x ${script} ] && \
- (set -T ; trap 'exit 1' 2 ; ${script} start)
- done
+ if [ -d ${dir} ]; then
+ for script in ${dir}/*.sh; do
+ if [ -x ${script} ]; then
+ (set -T ; trap 'exit 1' 2 ; \
+ ${script} start)
+ fi
+ done
+ fi
done
echo .
-fi
+ ;;
+esac
-if [ "${update_motd}" != "NO" ]; then
+case ${update_motd} in
+[Nn][Oo])
+ ;;
+*)
T=`mktemp /tmp/_motd.XXXXXX`
- if [ $? -eq 0 ]; then
+ if [ $? = 0 ]; then
uname -v | sed -e 's,^\([^#]*\) #\(.*
[1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}}
else {print}}' < /etc/motd >> ${T}
cmp -s ${T} /etc/motd || {
@@ -410,10 +493,14 @@
}
rm -f ${T}
fi
-fi
+ ;;
+esac
-# Run rc.devfs if present to customize devfs
-[ -f /etc/rc.devfs ] && sh /etc/rc.devfs
+# Run rc.devfs if readable to customize devfs
+#
+if [ -r /etc/rc.devfs ]; then
+ sh /etc/rc.devfs
+fi
# Do traditional (but rather obsolete) rc.local file if it exists. If you
# use this file and want to make it programmatic, source /etc/defaults/rc.conf
@@ -422,14 +509,14 @@
# Use /etc/rc.local
#
# ---- rc.local ----
-# if [ -f /etc/defaults/rc.conf ]; then
+# if [ -r /etc/defaults/rc.conf ]; then
# . /etc/defaults/rc.conf
# fi
-#
+#
# ... additional startup conditionals ...
-# ---- rc.local ----
-#
-if [ -f /etc/rc.local ]; then
+# ---- rc.local ----
+#
+if [ -r /etc/rc.local ]; then
echo -n 'starting local daemons:'
sh /etc/rc.local
echo '.'
@@ -437,11 +524,15 @@
# 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 [ "${kern_securelevel_enable}" = "YES" -a "${kern_securelevel}" -ge 0 ];
-then
- echo 'Raising kernel security level'
- sysctl -w kern.securelevel=${kern_securelevel}
-fi
+#
+case ${kern_securelevel_enable} in
+[Yy][Ee][Ss])
+ if [ "${kern_securelevel}" -ge 0 ]; then
+ echo 'Raising kernel security level'
+ sysctl -w kern.securelevel=${kern_securelevel}
+ fi
+ ;;
+esac
date
exit 0
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message