possible change for 4.9 rc file?

Julian Elischer julian at elischer.org
Wed Sep 3 13:42:10 PDT 2003


Here is a small (logically) change I have in /etc/rc
to allow the user to use /etc/rc in a jail by setting 
bootmode="jail"
in /etc/rc.conf

basically several parts of the code have been moved into

case ${bootmode} in
jail)
        ;;
 *)
	foo
esac

any commens?
is is a good idea?
is it something that migh make it to 4.9?

julian
(is 4.9 frozen yet?) hmm goes to look at web page..


--cut'mn'pasted diff..
ipm0# diff -u /etc/rc etc/rc
--- /etc/rc     Mon Jul 28 18:33:07 2003
+++ etc/rc      Wed Sep  3 13:31:51 2003
@@ -1,4 +1,5 @@
 #!/bin/sh
+set -x
 #
 # Copyright (c) 2000  The FreeBSD Project
 # All rights reserved.
@@ -195,39 +196,45 @@
 # root normally must be read/write, but if this is a BOOTP NFS
 # diskless boot it does not have to be.
 #
-case ${root_rw_mount} in
-[Nn][Oo] | '')
+case ${bootmode} in
+jail)
        ;;
 *)
-       if ! mount -u -o rw /; then
-               echo 'Mounting root filesystem rw failed, startup
aborted'
-               exit 1
-       fi
-       ;;
-esac
+       case ${root_rw_mount} in
+       [Nn][Oo] | '')
+               ;;
+       *)
+               if ! mount -u -o rw /; then
+                       echo 'Mounting root filesystem rw failed,
startup aborted'
+                       exit 1
+               fi
+               ;;
+       esac
 
-umount -a >/dev/null 2>&1
+       umount -a >/dev/null 2>&1
 
-# If using diskless, run custom disk mounting function here
-#
-if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then
-       sh ${diskless_mount}
-else
-# otherwise mount everything except nfs filesystems.
-       mount -a -t nonfs
-fi
+       # If using diskless, run custom disk mounting function here
+       #
+       if [ -n "${diskless_mount}" -a -r "${diskless_mount}" ]; then
+               sh ${diskless_mount}
+       else
+       # otherwise mount everything except nfs filesystems.
+               mount -a -t nonfs
+       fi
 
-case $? in
-0)
-       ;;
-*)
-       echo 'Mounting /etc/fstab filesystems failed, startup aborted'
-       exit 1
+       case $? in
+       0)
+               ;;
+       *)
+               echo 'Mounting /etc/fstab filesystems failed, startup
aborted'
+               exit 1
+               ;;
+       esac
+
+       adjkerntz -i
        ;;
 esac
 
-adjkerntz -i
-
 purgedir() {
        local dir file
 
@@ -273,67 +280,80 @@
 rm -f /var/run/clean_var /var/spool/lock/clean_var
 clean_var
 
-# Add additional swapfile, if configured.
-#
-case ${swapfile} in
-[Nn][Oo] | '')
+case ${bootmode} in
+jail)
+       # Host machine has done pass1.
+       # Pass 2 is dubious  for a jail 
+       # but ok as long as we don't enable things we shouldn't.
+       if [ -r /etc/rc.network ]; then
+               . /etc/rc.network       # We only need to do this once.
+       fi
+       network_pass1_done=YES
        ;;
 *)
-       if [ -w "${swapfile}" -a -c /dev/vn0b ]; then
-               echo "Adding ${swapfile} as additional swap"
-               vnconfig -e /dev/vn0b ${swapfile} swap
+       # Add additional swapfile, if configured.
+       #
+       case ${swapfile} in
+       [Nn][Oo] | '')
+               ;;
+       *)
+               if [ -w "${swapfile}" -a -c /dev/vn0b ]; then
+                       echo "Adding ${swapfile} as additional swap"
+                       vnconfig -e /dev/vn0b ${swapfile} swap
+               fi
+               ;;
+       esac
+
+       # Early pass to set the variables we can
+       #
+       if [ -r /etc/rc.sysctl ]; then
+               sh /etc/rc.sysctl first
        fi
-       ;;
-esac
 
-# Early pass to set the variables we can
-#
-if [ -r /etc/rc.sysctl ]; then
-       sh /etc/rc.sysctl first
-fi
+       # Configure serial devices
+       #
+       if [ -r /etc/rc.serial ]; then
+               . /etc/rc.serial
+       fi
 
-# Configure serial devices
-#
-if [ -r /etc/rc.serial ]; then
-       . /etc/rc.serial
-fi
+       # Start up PC-card configuration
+       #
+       if [ -r /etc/rc.pccard ]; then
+               . /etc/rc.pccard
+       fi
 
-# Start up PC-card configuration
-#
-if [ -r /etc/rc.pccard ]; then
-       . /etc/rc.pccard
-fi
+       # 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
 
-# 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
+       case ${ipv6_enable} in
+       [Yy][Ee][Ss])
+               if [ -r /etc/rc.network6 ]; then
+                       . /etc/rc.network6      # We only need to do
this once also.
+                       network6_pass1
+               fi
+               ;;
+       esac
 
-case ${ipv6_enable} in
-[Yy][Ee][Ss])
-       if [ -r /etc/rc.network6 ]; then
-               . /etc/rc.network6      # We only need to do this once
also.
-               network6_pass1
-       fi
-       ;;
-esac
+       # Mount NFS filesystems if present in /etc/fstab
+       #
+       case "`mount -d -a -t nfs 2> /dev/null`" in
+       *mount_nfs*)
+               echo -n 'Mounting NFS file systems:'
+               mount -a -t nfs
+               echo '.'
+               ;;
+       esac
 
-# Mount NFS filesystems if present in /etc/fstab
-#
-case "`mount -d -a -t nfs 2> /dev/null`" in
-*mount_nfs*)
-       echo -n 'Mounting NFS file systems:'
-       mount -a -t nfs
-       echo '.'
+       # If we booted a special kernel remove the record so we will
boot
+       # the default kernel next time
+       #
+       rm -f /boot/nextboot.conf
        ;;
 esac
-
-# If we booted a special kernel remove the record so we will boot
-# the default kernel next time
-#
-rm -f /boot/nextboot.conf
 
 # Whack the pty perms back into shape.
 #




More information about the freebsd-hackers mailing list