From owner-freebsd-hackers@FreeBSD.ORG Wed Sep 3 13:42:10 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F31AA16A4BF; Wed, 3 Sep 2003 13:42:09 -0700 (PDT) Received: from rwcrmhc12.comcast.net (rwcrmhc12.comcast.net [216.148.227.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id E4D1643FDF; Wed, 3 Sep 2003 13:42:06 -0700 (PDT) (envelope-from julian@elischer.org) Received: from interjet.elischer.org ([12.233.125.100]) by attbi.com (rwcrmhc12) with ESMTP id <2003090320420601400do7ihe>; Wed, 3 Sep 2003 20:42:06 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id NAA30757; Wed, 3 Sep 2003 13:42:05 -0700 (PDT) Date: Wed, 3 Sep 2003 13:42:03 -0700 (PDT) From: Julian Elischer To: hackers@freebsd.org, re@freebsd.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: possible change for 4.9 rc file? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2003 20:42:10 -0000 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. #