Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/newbtconf import script to setup directories for mainta...
details: https://anonhg.NetBSD.org/src/rev/5001a7bcae6f
branches: trunk
changeset: 476984:5001a7bcae6f
user: darrenr <darrenr%NetBSD.org@localhost>
date: Tue Oct 05 11:22:43 1999 +0000
description:
import script to setup directories for maintaining separate boot configs.
diffstat:
sbin/newbtconf/Makefile | 7 +
sbin/newbtconf/newbtconf.8 | 213 ++++++++++++++++++++++++++++++++++++++++++++
sbin/newbtconf/newbtconf.sh | 56 +++++++++++
3 files changed, 276 insertions(+), 0 deletions(-)
diffs (288 lines):
diff -r b0b45864ee4d -r 5001a7bcae6f sbin/newbtconf/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/newbtconf/Makefile Tue Oct 05 11:22:43 1999 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile,v 1.1.1.1 1999/10/05 11:22:43 darrenr Exp $
+# @(#)Makefile 8.1 (Berkeley) 6/5/93
+
+MAN= newbtconf.8
+SCRIPTS=newbtconf.sh
+
+.include <bsd.prog.mk>
diff -r b0b45864ee4d -r 5001a7bcae6f sbin/newbtconf/newbtconf.8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/newbtconf/newbtconf.8 Tue Oct 05 11:22:43 1999 +0000
@@ -0,0 +1,213 @@
+.\" $NetBSD: newbtconf.8,v 1.1.1.1 1999/10/05 11:22:43 darrenr Exp $
+.\"
+.\" Copyright (c) 1999
+.\" Darren Reed. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the author nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd October 3, 1999
+.Dt NEWBTCONF 1
+.Os
+.Sh NAME
+.Nm newbtconf
+.Nd multiple boot-up configurations
+.Sh SYNOPSIS
+.Nm
+.Ar new-conf-name
+.Op Ar orig-conf-name
+.Nm ""
+.Li init
+.Sh DESCRIPTION
+.Bl -tag -width indent
+.Nm
+is used to setup the system in such a way that the user is offered a
+selection of environments in which to boot the system up into. The most
+obvious application being for laptops to provide a network and non-network
+environment after a successful boot into multi-user mode.
+.Ss BACKGROUND
+.Pp
+In order to accomplish this task, the files usually associated with
+establishing the current system's running configuration are replaced with
+symbolic links which are adjusted with each boot to point to the appropriate
+file for the desired run-time environment. This is accomplished by directing
+all of the symbolic links through a directory which itself is a symbolic
+link (
+.Pa /etc/etc.current
+), to the destination files.
+At each bootup, the selection made changes which directory
+.Pa /etc/etc.current
+points to.
+.Pp
+Though doing this and reloading
+.Pa /etc/rc.conf
+in
+.Pa /etc/rc after
+the link has
+been established, the resulting run-time configuration is effectively
+controlled without the need to directly edit any files. The default boot-up
+environment is selected by manually directing which configuration directory
+.Pa /etc/etc.default
+points to. As opposed to
+.Pa /etc/etc.current
+(which is updated
+with every boot),
+.Pa /etc/etc.default
+is not automatically updated.
+.Ss GETTING STARTED
+.Pp
+By default, NetBSD only has one boot-up configuration - that set in the
+file
+.Pa "/etc/rc.conf" .
+In order to initialize the system for operating in a
+manner which supports multiple boot configurations,
+.Nm
+must be run with the
+.B init
+option. This will create two symbolic
+.Pa /etc/etc.current
+and
+.Pa /etc/etc.default
+to the directory
+.Pa "/etc/etc.network".
+The following files are all moved into
+that directory and symbolic links put in their place, in /etc, pointing to
+.Pa /etc/etc.current/<filename>
+:
+.Bd -literal
+/etc/fstab
+/etc/rc.conf
+/etc/mrouted.conf
+/etc/resolv.conf
+/etc/ntp.conf
+/etc/ifconfig.*
+/etc/nsswitch.conf
+/etc/rbootd.conf
+/etc/inetd.conf
+.Ed
+.Pp
+To test that this has been performed correctly, reboot your system into
+NetBSD. After the kernel has autoconfigured and tty flags have been set,
+a prompt should appear, preceeded by the following like, looking like this:
+.Bd -literal
+[network]
+Which configuration [network] ?
+.Ed
+.Pp
+The []'s are used to indicate the default configuration, which can be
+selected by just pressing return. If there were other configurations
+available at this stage, you would have 30 seconds to enter that name
+and press return.
+.Ss MUTILPLE CONFIGURATIONS
+.Pp
+Once an initial configuration has been setup, we can proceed to setup further
+run time environments. This is done by invoking
+.Nm
+with the name of the new configuration to be created. By default, this step
+will use the current configuration files as the basis for this setup unless
+a second parameter is given - that of the configuration to use as the basis
+for the new one. Upon completion, a new directory, /etc/etc.<newname>, will
+have been created, priming the directory with the appropriate files for
+editting. For example, if we do
+.Nm
+\fInonet\fP \fInetwork\fP it would create a directory named /etc/etc.nonet
+and copy all the files from
+.Pa /etc/etc.network
+into that directory. Upon
+rebooting, we should see:
+.Bd -literal
+[network] nonet
+Which configuration [network] ?
+.Ed
+.Pp
+To setup the system for booting into the "nonet" configuration, the files
+in /etc/etc.nonet need be editted.
+.Pp
+If you wanted to make "nonet" the default configuration when booting, you
+would need delete the symbolic link
+.Pa /etc/etc.default
+and create a new symbolic link (with the same name) to
+.Pa "/etc/etc.nonet" .
+Booting up after having made such a change would
+result in the following being displayed:
+.Bd -literal
+network [nonet]
+Which configuration [nonet] ?
+.Ed
+.Ss NO NETWORK
+Assuming that we performed the above command successfully, in order to
+successfully configure NetBSD to not configure interfaces (or generate no
+errors from attempting to do so), the following settings (at least) should
+be used in
+.Pa "/etc/etc.nonet/rc.conf" :
+.Bd -literal
+auto_ifconfig=NO
+net_interfaces=NO
+.Ed
+.Pp
+Of course other networking services, such as NTP, routed, etc, are all
+expected to be "NO". In general, the only settings which should be "YES"
+are syslogd and update, with perhaps cron (if your cron scripts don't
+need the network) and screenblank/wscons (if applicable). Other actions
+such as deleting any NFS mounts from
+.Pa /etc/etc.nonet/fstab
+would also need to be undertaken.
+.El
+.Sh FILES
+.Bl -tag -width /etc/mrouted.current -compact
+.It Pa /etc/etc.current
+Symbolic link to current config dir.
+.It Pa /etc/etc.default
+Symbolic link to default config dir.
+.It Pa /etc/fstab
+These files all become symbolic links.
+.It Pa /etc/ifconfig.*
+.It Pa /etc/rc.conf
+.It Pa /etc/mrouted.conf
+.It Pa /etc/resolv.conf
+.It Pa /etc/ntp.conf
+.It Pa /etc/rbootd.conf
+.It Pa /etc/ntp.conf
+.It Pa /etc/inetd.conf
+.El
+.Sh SEE ALSO
+.Xr rc.conf 8 ,
+.Xr rc 8
+.Sh HISTORY
+The
+.Nm
+program first appeared in NetBSD-current, October 1999.
+.Sh BUGS
+.Pp
+It presently does not display a count down timer whilst waiting for input
+to select which configuration and nor does it abort said timer when a key
+is first pressed.
+.Pp
+The management of the overall collection of multiple configurations is much
+more manual than it ought to be. A general system configuration tool needs
+to be written to ease their management.
+.Sh AUTHORS
+This shell script was written by Darren Reed <darrenr%netbsd.org@localhost> with
+initial input from Matthew Green <mrg%netbsd.org@localhost> on how to approach this
+problem.
diff -r b0b45864ee4d -r 5001a7bcae6f sbin/newbtconf/newbtconf.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/newbtconf/newbtconf.sh Tue Oct 05 11:22:43 1999 +0000
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# Setup a new config directory
+#
+if [ $# -lt 1 ] ; then
+ echo "Usage: $0 <newconfig> [<baseconfig>]"
+ echo "Usage: $0 init"
+ exit 1;
+fi
+dir=$1
+
+if [ $dir = init ] ; then
+ if [ -d /etc/etc.network -o -e /etc/etc/current ] ; then
+ echo "Error: multi-configuration already initialized"
+ exit 1
+ fi
+ dir=etc.network
+ cd /etc
+ mkdir -m 755 $dir
+ ln -s $dir etc.current
+ ln -s $dir etc.default
+ for i in fstab rc.conf netstart mrouted.conf ntp.conf resolv.conf \
+ nsswitch.conf rbootd.conf inetd.conf ifconfig.* myname \
+ mygate defaultdomain; do
+ if [ -f $i ] ; then
+ mv $i $dir
+ ln -s etc.current/$i .
+ fi
+ done
+ echo "/etc/$dir has now been created and populated."
+ exit 0
+fi
+
+if [ "`expr $dir : 'etc\.\(.*\)'`" != $dir ] ; then
+ dir=etc.$dir
+fi
+if [ -e /etc/$dir ] ; then
+ echo "Error: $dir already exists"
+ exit 1;
+fi
+newname=`expr $dir : 'etc.\(.*\)'`
+if [ $# -lt 2 ] ; then
+ orig=etc.current
+ echo "Using current config as base for $newname"
+else
+ orig=$2
+fi
+
+if [ -z "`expr $orig : 'etc.\(.*\)'`" ] ; then
+ orig=etc.$orig
+fi
+
+mkdir -m 755 /etc/$dir
+cp -p /etc/$orig/* /etc/$dir
+echo "/etc/$dir has now been created and populated."
+exit 0
Home |
Main Index |
Thread Index |
Old Index