2002-07-18 05:00:17 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2003-08-07 21:06:32 +00:00
|
|
|
# Copyright (c) 1999 Matt Dillon
|
2000-10-08 19:20:36 +00:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
#
|
1999-09-13 15:44:20 +00:00
|
|
|
# $FreeBSD$
|
2003-10-13 08:20:55 +00:00
|
|
|
|
2002-12-22 22:18:41 +00:00
|
|
|
# On entry to this script the entire system consists of a read-only root
|
2004-03-31 08:43:20 +00:00
|
|
|
# mounted via NFS. The kernel has run BOOTP and configured an interface
|
2002-12-22 22:18:41 +00:00
|
|
|
# (otherwise it would not have been able to mount the NFS root!)
|
|
|
|
#
|
2004-03-31 08:43:20 +00:00
|
|
|
# We use the contents of /conf to create and populate memory filesystems
|
|
|
|
# that are mounted on top of this root to implement the writable
|
|
|
|
# (and host-specific) parts of the root filesystem, and other volatile
|
|
|
|
# filesystems.
|
|
|
|
#
|
|
|
|
# The hierarchy in /conf has the form /conf/T/M/ where M are directories
|
|
|
|
# for which memory filesystems will be created and filled,
|
|
|
|
# and T is one of the "template" directories below:
|
|
|
|
#
|
|
|
|
# base universal base, typically a replica of the original root;
|
|
|
|
# default secondary universal base, typically overriding some
|
|
|
|
# of the files in the original root;
|
|
|
|
# ${ipba} where ${ipba} is the assigned broadcast IP address
|
2005-08-17 00:28:38 +00:00
|
|
|
# bcast/${ipba} same as above
|
2004-03-31 08:43:20 +00:00
|
|
|
# ${class} where ${class} is a list of directories supplied by
|
|
|
|
# bootp/dhcp through the T134 option.
|
2012-01-07 16:10:32 +00:00
|
|
|
# ${ipba} and ${class} are typically used to configure features
|
2004-03-31 08:43:20 +00:00
|
|
|
# for group of diskless clients, or even individual features;
|
|
|
|
# ${ip} where ${ip} is the machine's assigned IP address, typically
|
|
|
|
# used to set host-specific features;
|
2005-08-17 00:28:38 +00:00
|
|
|
# ip/${ip} same as above
|
2004-06-06 11:46:29 +00:00
|
|
|
#
|
2004-03-31 08:43:20 +00:00
|
|
|
# Template directories are scanned in the order they are listed above,
|
2012-01-07 16:10:32 +00:00
|
|
|
# with each successive directory overriding (merged into) the previous one;
|
2005-08-17 00:28:38 +00:00
|
|
|
# non-existing directories are ignored. The subdirectory forms exist to
|
2012-01-07 16:10:32 +00:00
|
|
|
# help keep the top level /conf manageable in large installations.
|
2004-03-31 08:43:20 +00:00
|
|
|
#
|
|
|
|
# The existence of a directory /conf/T/M causes this script to create a
|
|
|
|
# memory filesystem mounted as /M on the client.
|
|
|
|
#
|
|
|
|
# Some files in /conf have special meaning, namely:
|
|
|
|
#
|
|
|
|
# Filename Action
|
|
|
|
# ----------------------------------------------------------------
|
|
|
|
# /conf/T/M/remount
|
|
|
|
# The contents of the file is a mount command. E.g. if
|
|
|
|
# /conf/1.2.3.4/foo/remount contains "mount -o ro /dev/ad0s3",
|
2017-12-27 03:23:01 +00:00
|
|
|
# then /dev/ad0s3 will be mounted on /conf/1.2.3.4/foo/
|
2004-03-31 08:43:20 +00:00
|
|
|
#
|
2008-05-15 11:00:23 +00:00
|
|
|
# /conf/T/M/remount_optional
|
|
|
|
# If this file exists, then failure to execute the mount
|
|
|
|
# command contained in /conf/T/M/remount is non-fatal.
|
|
|
|
#
|
2008-09-09 18:40:50 +00:00
|
|
|
# /conf/T/M/remount_subdir
|
|
|
|
# If this file exists, then the behaviour of /conf/T/M/remount
|
|
|
|
# changes as follows:
|
|
|
|
# 1. /conf/T/M/remount is invoked to mount the root of the
|
|
|
|
# filesystem where the configuration data exists on a
|
|
|
|
# temporary mountpoint.
|
|
|
|
# 2. /conf/T/M/remount_subdir is then invoked to mount a
|
|
|
|
# *subdirectory* of the filesystem mounted by
|
|
|
|
# /conf/T/M/remount on /conf/T/M/.
|
|
|
|
#
|
2004-03-31 08:43:20 +00:00
|
|
|
# /conf/T/M/diskless_remount
|
2006-12-03 23:50:29 +00:00
|
|
|
# The contents of the file points to an NFS filesystem,
|
|
|
|
# possibly followed by mount_nfs options. If the server name
|
|
|
|
# is omitted, the script will prepend the root path used when
|
|
|
|
# booting. E.g. if you booted from foo.com:/path/to/root,
|
|
|
|
# an entry for /conf/base/etc/diskless_remount could be any of
|
|
|
|
# foo.com:/path/to/root/etc
|
|
|
|
# /etc -o ro
|
2006-09-01 16:33:15 +00:00
|
|
|
# Because mount_nfs understands ".." in paths, it is
|
|
|
|
# possible to mount from locations above the NFS root with
|
|
|
|
# paths such as "/../../etc".
|
2004-03-31 08:43:20 +00:00
|
|
|
#
|
|
|
|
# /conf/T/M/md_size
|
|
|
|
# The contents of the file specifies the size of the memory
|
|
|
|
# filesystem to be created, in 512 byte blocks.
|
|
|
|
# The default size is 10240 blocks (5MB). E.g. if
|
|
|
|
# /conf/base/etc/md_size contains "30000" then a 15MB MFS
|
|
|
|
# will be created. In case of multiple entries for the same
|
|
|
|
# directory M, the last one in the scanning order is used.
|
|
|
|
# NOTE: If you only need to create a memory filesystem but not
|
2016-05-01 16:43:22 +00:00
|
|
|
# initialize it from a template, it is preferable to specify
|
2004-03-31 08:43:20 +00:00
|
|
|
# it in fstab e.g. as "md /tmp mfs -s=30m,rw 0 0"
|
|
|
|
#
|
|
|
|
# /conf/T/SUBDIR.cpio.gz
|
|
|
|
# The file is cpio'd into /SUBDIR (and a memory filesystem is
|
|
|
|
# created for /SUBDIR if necessary). The presence of this file
|
|
|
|
# prevents the copy from /conf/T/SUBDIR/
|
|
|
|
#
|
2018-10-20 18:13:51 +00:00
|
|
|
# /conf/T/M/extract
|
|
|
|
# This is alternative to SUBDIR.cpio.gz and remount.
|
|
|
|
# Similar to remount case, a memory filesystem is created
|
|
|
|
# for /M and initialized from a template but no mounting
|
|
|
|
# performed. Instead, this file is run passing /M as singe
|
|
|
|
# argument. It is expected to extract template override to /M
|
|
|
|
# using auxiliary storage found in some embedded systems
|
|
|
|
# having NVRAM too small to hold mountable file system.
|
|
|
|
#
|
2004-03-31 08:43:20 +00:00
|
|
|
# /conf/T/SUBDIR.remove
|
|
|
|
# The list of paths contained in the file are rm -rf'd
|
|
|
|
# relative to /SUBDIR.
|
|
|
|
#
|
2006-09-01 16:33:15 +00:00
|
|
|
# /conf/diskless_remount
|
|
|
|
# Similar to /conf/T/M/diskless_remount above, but allows
|
|
|
|
# all of /conf to be remounted. This can be used to allow
|
|
|
|
# multiple roots to share the same /conf.
|
2010-05-14 04:53:57 +00:00
|
|
|
#
|
2006-09-01 16:33:15 +00:00
|
|
|
#
|
2004-03-31 08:43:20 +00:00
|
|
|
# You will almost universally want to create the following files under /conf
|
|
|
|
#
|
2006-08-22 16:21:16 +00:00
|
|
|
# File Content
|
|
|
|
# ---------------------------- ----------------------------------
|
|
|
|
# /conf/base/etc/md_size size of /etc filesystem
|
|
|
|
# /conf/base/etc/diskless_remount "/etc"
|
|
|
|
# /conf/default/etc/rc.conf generic diskless config parameters
|
|
|
|
# /conf/default/etc/fstab generic diskless fstab e.g. like this
|
|
|
|
#
|
|
|
|
# foo:/root_part / nfs ro 0 0
|
|
|
|
# foo:/usr_part /usr nfs ro 0 0
|
|
|
|
# foo:/home_part /home nfs rw 0 0
|
|
|
|
# md /tmp mfs -s=30m,rw 0 0
|
|
|
|
# md /var mfs -s=30m,rw 0 0
|
|
|
|
# proc /proc procfs rw 0 0
|
2004-03-31 08:43:20 +00:00
|
|
|
#
|
|
|
|
# plus, possibly, overrides for password files etc.
|
|
|
|
#
|
|
|
|
# NOTE! /var, /tmp, and /dev will be typically created elsewhere, e.g.
|
|
|
|
# as entries in the fstab as above.
|
2004-03-12 04:40:16 +00:00
|
|
|
# Those filesystems should not be specified in /conf.
|
2004-03-31 08:43:20 +00:00
|
|
|
#
|
|
|
|
# (end of documentation, now get to the real code)
|
2002-12-22 22:18:41 +00:00
|
|
|
|
|
|
|
dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null`
|
1999-02-09 17:17:18 +00:00
|
|
|
|
2006-12-03 23:50:29 +00:00
|
|
|
# DEBUGGING
|
|
|
|
# log something on stdout if verbose.
|
|
|
|
o_verbose=0 # set to 1 or 2 if you want more debugging
|
|
|
|
log() {
|
|
|
|
[ ${o_verbose} -gt 0 ] && echo "*** $* ***"
|
|
|
|
[ ${o_verbose} -gt 1 ] && read -p "=== Press enter to continue" foo
|
|
|
|
}
|
|
|
|
|
1999-02-09 17:17:18 +00:00
|
|
|
# chkerr:
|
|
|
|
#
|
|
|
|
# Routine to check for error
|
|
|
|
#
|
|
|
|
# checks error code and drops into shell on failure.
|
|
|
|
# if shell exits, terminates script as well as /etc/rc.
|
2008-05-15 11:00:23 +00:00
|
|
|
# if remount_optional exists under the mountpoint, skip this check.
|
1999-09-13 15:44:20 +00:00
|
|
|
#
|
2002-12-22 22:18:41 +00:00
|
|
|
chkerr() {
|
2008-05-15 11:00:23 +00:00
|
|
|
lastitem () ( n=$(($# - 1)) ; shift $n ; echo $1 )
|
|
|
|
mountpoint="$(lastitem $2)"
|
|
|
|
[ -r $mountpoint/remount_optional ] && ( echo "$2 failed: ignoring due to remount_optional" ; return )
|
2002-12-22 22:18:41 +00:00
|
|
|
case $1 in
|
|
|
|
0)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "$2 failed: dropping into /bin/sh"
|
|
|
|
/bin/sh
|
|
|
|
# RESUME
|
|
|
|
;;
|
|
|
|
esac
|
1999-02-09 17:17:18 +00:00
|
|
|
}
|
|
|
|
|
2006-12-03 23:50:29 +00:00
|
|
|
# The list of filesystems to umount after the copy
|
|
|
|
to_umount=""
|
|
|
|
|
|
|
|
handle_remount() { # $1 = mount point
|
|
|
|
local nfspt mountopts b
|
|
|
|
b=$1
|
|
|
|
log handle_remount $1
|
|
|
|
[ -d $b -a -f $b/diskless_remount ] || return
|
|
|
|
read nfspt mountopts < $b/diskless_remount
|
|
|
|
log "nfspt ${nfspt} mountopts ${mountopts}"
|
|
|
|
# prepend the nfs root if not present
|
|
|
|
[ `expr "$nfspt" : '\(.\)'` = "/" ] && nfspt="${nfsroot}${nfspt}"
|
|
|
|
mount_nfs $mountopts $nfspt $b
|
|
|
|
chkerr $? "mount_nfs $nfspt $b"
|
|
|
|
to_umount="$b ${to_umount}"
|
|
|
|
}
|
|
|
|
|
Enhance mdmfs(8) to work with tmpfs(5).
Existing scripts and associated config such as rc.initdiskless, rc.d/var,
and others, use mdmfs to create memory filesystems. That program accepts a
size argument which allows SI suffixes and treats an unsuffixed number as a
count of 512 byte sectors. That makes it difficult to convert existing
scripts to use tmpfs instead of mdmfs, because tmpfs treats unsuffixed
numbers as a count of bytes. The script logic to deal with existing user
config that might include suffixed and unsuffixed numbers is... unpleasant.
Also, there is no g'tee that tmpfs will be available. It is sometimes
configured out of small-resource embedded systems to save memory and flash
storage space.
These changes enhance mdmfs(8) so that it accepts two new values for the
'md-device' arg: 'tmpfs' and 'auto'. With tmpfs, the program always uses
tmpfs(5) (and fails if it's not available). With 'auto' the program prefers
tmpfs, but falls back to using md(4) if tmpfs isn't available. It also
handles the -s <size> argument so that the mdconfig interpetation of
unsuffixed numbers applies when tmpfs is used as well, so that existing user
config keeps working after a switch to tmpfs.
A new rc setting, mfs_type, is added to etc/defaults/rc.conf to let users
force the use of tmpfs or md; the default value is "auto".
Differential Revision: https://reviews.freebsd.org/D12301
2017-09-29 22:13:26 +00:00
|
|
|
# Create a generic memory disk.
|
|
|
|
# The 'auto' parameter will attempt to use tmpfs(5), falls back to md(4).
|
2017-09-29 22:21:42 +00:00
|
|
|
# $1 is size in 512-byte sectors, $2 is the mount point.
|
2002-12-22 22:18:41 +00:00
|
|
|
mount_md() {
|
2017-09-29 22:21:42 +00:00
|
|
|
/sbin/mdmfs -s $1 auto $2
|
2002-12-22 22:18:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create the memory filesystem if it has not already been created
|
|
|
|
#
|
|
|
|
create_md() {
|
2006-12-03 23:50:29 +00:00
|
|
|
[ "x`eval echo \\$md_created_$1`" = "x" ] || return # only once
|
2003-02-15 16:29:20 +00:00
|
|
|
if [ "x`eval echo \\$md_size_$1`" = "x" ]; then
|
2003-10-12 00:19:45 +00:00
|
|
|
md_size=10240
|
2002-12-22 22:18:41 +00:00
|
|
|
else
|
|
|
|
md_size=`eval echo \\$md_size_$1`
|
|
|
|
fi
|
2006-12-03 23:50:29 +00:00
|
|
|
log create_md $1 with size $md_size
|
2002-12-22 22:18:41 +00:00
|
|
|
mount_md $md_size /$1
|
|
|
|
/bin/chmod 755 /$1
|
|
|
|
eval md_created_$1=created
|
2001-04-25 05:46:40 +00:00
|
|
|
}
|
|
|
|
|
1999-02-09 17:17:18 +00:00
|
|
|
# DEBUGGING
|
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
# set -v
|
1999-02-09 17:17:18 +00:00
|
|
|
|
1999-09-13 15:44:20 +00:00
|
|
|
# Figure out our interface and IP.
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2000-01-06 18:17:38 +00:00
|
|
|
bootp_ifc=""
|
|
|
|
bootp_ipa=""
|
|
|
|
bootp_ipbca=""
|
2005-08-17 00:28:38 +00:00
|
|
|
class=""
|
2004-03-09 23:06:50 +00:00
|
|
|
if [ ${dlv:=0} -ne 0 ] ; then
|
|
|
|
iflist=`ifconfig -l`
|
|
|
|
for i in ${iflist} ; do
|
2004-04-28 09:09:27 +00:00
|
|
|
set -- `ifconfig ${i}`
|
2004-03-09 23:06:50 +00:00
|
|
|
while [ $# -ge 1 ] ; do
|
|
|
|
if [ "${bootp_ifc}" = "" -a "$1" = "inet" ] ; then
|
|
|
|
bootp_ifc=${i} ; bootp_ipa=${2} ; shift
|
|
|
|
fi
|
|
|
|
if [ "${bootp_ipbca}" = "" -a "$1" = "broadcast" ] ; then
|
|
|
|
bootp_ipbca=$2; shift
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
if [ "${bootp_ifc}" != "" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2005-08-17 00:28:38 +00:00
|
|
|
# Get the values passed with the T134 bootp cookie.
|
2005-09-15 16:09:28 +00:00
|
|
|
class="`/sbin/sysctl -qn kern.bootp_cookie`"
|
2004-03-31 07:24:15 +00:00
|
|
|
|
2005-08-17 00:28:38 +00:00
|
|
|
echo "Interface ${bootp_ifc} IP-Address ${bootp_ipa} Broadcast ${bootp_ipbca} ${class}"
|
2004-03-09 23:06:50 +00:00
|
|
|
fi
|
1999-02-09 17:17:18 +00:00
|
|
|
|
2006-12-03 23:50:29 +00:00
|
|
|
log Figure out our NFS root path
|
2003-10-13 08:20:55 +00:00
|
|
|
#
|
2004-04-28 09:09:27 +00:00
|
|
|
set -- `mount -t nfs`
|
2003-06-30 21:47:06 +00:00
|
|
|
while [ $# -ge 1 ] ; do
|
|
|
|
if [ "$2" = "on" -a "$3" = "/" ]; then
|
|
|
|
nfsroot="$1"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2004-03-31 07:24:15 +00:00
|
|
|
# The list of directories with template files
|
2005-08-17 00:28:38 +00:00
|
|
|
templates="base default"
|
|
|
|
if [ -n "${bootp_ipbca}" ]; then
|
|
|
|
templates="${templates} ${bootp_ipbca} bcast/${bootp_ipbca}"
|
|
|
|
fi
|
|
|
|
if [ -n "${class}" ]; then
|
|
|
|
templates="${templates} ${class}"
|
|
|
|
fi
|
|
|
|
if [ -n "${bootp_ipa}" ]; then
|
|
|
|
templates="${templates} ${bootp_ipa} ip/${bootp_ipa}"
|
|
|
|
fi
|
2004-03-31 07:24:15 +00:00
|
|
|
|
2006-09-01 16:33:15 +00:00
|
|
|
# If /conf/diskless_remount exists, remount all of /conf.
|
2006-12-03 23:50:29 +00:00
|
|
|
handle_remount /conf
|
2004-03-12 04:40:16 +00:00
|
|
|
|
2002-12-22 22:18:41 +00:00
|
|
|
# Resolve templates in /conf/base, /conf/default, /conf/${bootp_ipbca},
|
2003-10-13 08:20:55 +00:00
|
|
|
# and /conf/${bootp_ipa}. For each subdirectory found within these
|
2002-12-22 22:18:41 +00:00
|
|
|
# directories:
|
|
|
|
#
|
|
|
|
# - calculate memory filesystem sizes. If the subdirectory (prior to
|
|
|
|
# NFS remounting) contains the file 'md_size', the contents specified
|
|
|
|
# in 512 byte sectors will be used to size the memory filesystem. Otherwise
|
|
|
|
# 8192 sectors (4MB) is used.
|
1999-02-09 17:17:18 +00:00
|
|
|
#
|
2002-12-22 22:18:41 +00:00
|
|
|
# - handle NFS remounts. If the subdirectory contains the file
|
|
|
|
# diskless_remount, the contents of the file is NFS mounted over
|
|
|
|
# the directory. For example /conf/base/etc/diskless_remount
|
|
|
|
# might contain 'myserver:/etc'. NFS remounts allow you to avoid
|
|
|
|
# having to dup your system directories in /conf. Your server must
|
|
|
|
# be sure to export those filesystems -alldirs, however.
|
2003-06-30 21:47:06 +00:00
|
|
|
# If the diskless_remount file contains a string beginning with a
|
|
|
|
# '/' it is assumed that the local nfsroot should be prepended to
|
|
|
|
# it before attemping to the remount. This allows the root to be
|
|
|
|
# relocated without needing to change the remount files.
|
2002-12-22 22:18:41 +00:00
|
|
|
#
|
2006-12-03 23:50:29 +00:00
|
|
|
log "templates are ${templates}"
|
2004-03-31 07:24:15 +00:00
|
|
|
for i in ${templates} ; do
|
2002-12-22 22:18:41 +00:00
|
|
|
for j in /conf/$i/* ; do
|
2006-12-03 23:50:29 +00:00
|
|
|
[ -d $j ] || continue
|
|
|
|
|
2002-12-22 22:18:41 +00:00
|
|
|
# memory filesystem size specification
|
|
|
|
subdir=${j##*/}
|
2006-12-03 23:50:29 +00:00
|
|
|
[ -f $j/md_size ] && eval md_size_$subdir=`cat $j/md_size`
|
2001-04-20 23:10:11 +00:00
|
|
|
|
2006-12-03 23:50:29 +00:00
|
|
|
# remount. Beware, the command is in the file itself!
|
|
|
|
if [ -f $j/remount ]; then
|
2008-09-09 18:40:50 +00:00
|
|
|
if [ -f $j/remount_subdir ]; then
|
|
|
|
k="/conf.tmp/$i/$subdir"
|
|
|
|
[ -d $k ] || continue
|
|
|
|
|
|
|
|
# Mount the filesystem root where the config data is
|
|
|
|
# on the temporary mount point.
|
|
|
|
nfspt=`/bin/cat $j/remount`
|
|
|
|
$nfspt $k
|
|
|
|
chkerr $? "$nfspt $k"
|
|
|
|
|
|
|
|
# Now use a nullfs mount to get the data where we
|
|
|
|
# really want to see it.
|
|
|
|
remount_subdir=`/bin/cat $j/remount_subdir`
|
|
|
|
remount_subdir_cmd="mount -t nullfs $k/$remount_subdir"
|
|
|
|
|
|
|
|
$remount_subdir_cmd $j
|
|
|
|
chkerr $? "$remount_subdir_cmd $j"
|
|
|
|
|
|
|
|
# XXX check order -- we must force $k to be unmounted
|
|
|
|
# after j, as j depends on k.
|
|
|
|
to_umount="$j $k ${to_umount}"
|
|
|
|
else
|
|
|
|
nfspt=`/bin/cat $j/remount`
|
|
|
|
$nfspt $j
|
|
|
|
chkerr $? "$nfspt $j"
|
|
|
|
to_umount="$j ${to_umount}" # XXX hope it is really a mount!
|
|
|
|
fi
|
2004-03-09 23:06:50 +00:00
|
|
|
fi
|
|
|
|
|
2002-12-22 22:18:41 +00:00
|
|
|
# NFS remount
|
2006-12-03 23:50:29 +00:00
|
|
|
handle_remount $j
|
2002-12-22 22:18:41 +00:00
|
|
|
done
|
2001-04-20 23:10:11 +00:00
|
|
|
done
|
1999-02-09 17:17:18 +00:00
|
|
|
|
2002-12-22 22:18:41 +00:00
|
|
|
# - Create all required MFS filesystems and populate them from
|
|
|
|
# our templates. Support both a direct template and a dir.cpio.gz
|
2018-10-20 18:13:51 +00:00
|
|
|
# archive. Support for auxiliary NVRAM. Support dir.remove files containing
|
|
|
|
# a list of relative paths to remove.
|
2002-04-22 21:42:18 +00:00
|
|
|
#
|
2004-03-31 07:24:15 +00:00
|
|
|
# The dir.cpio.gz form is there to make the copy process more efficient,
|
|
|
|
# so if the cpio archive is present, it prevents the files from dir/
|
|
|
|
# from being copied.
|
2002-04-22 21:42:18 +00:00
|
|
|
|
2004-03-31 07:24:15 +00:00
|
|
|
for i in ${templates} ; do
|
2002-12-22 22:18:41 +00:00
|
|
|
for j in /conf/$i/* ; do
|
|
|
|
subdir=${j##*/}
|
2004-03-31 07:24:15 +00:00
|
|
|
if [ -d $j -a ! -f $j.cpio.gz ]; then
|
2002-12-22 22:18:41 +00:00
|
|
|
create_md $subdir
|
2012-11-21 18:12:28 +00:00
|
|
|
cp -Rp $j/ /$subdir
|
2002-12-22 22:18:41 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
for j in /conf/$i/*.cpio.gz ; do
|
|
|
|
subdir=${j%*.cpio.gz}
|
|
|
|
subdir=${subdir##*/}
|
|
|
|
if [ -f $j ]; then
|
|
|
|
create_md $subdir
|
|
|
|
echo "Loading /$subdir from cpio archive $j"
|
2005-10-31 22:00:44 +00:00
|
|
|
(cd / ; /rescue/tar -xpf $j)
|
2002-12-22 22:18:41 +00:00
|
|
|
fi
|
|
|
|
done
|
2018-10-20 18:13:51 +00:00
|
|
|
for j in /conf/$i/*/extract ; do
|
|
|
|
if [ -x $j ]; then
|
|
|
|
subdir=${j%*/extract}
|
|
|
|
subdir=${subdir##*/}
|
|
|
|
create_md $subdir
|
|
|
|
echo "Loading /$subdir using auxiliary command $j"
|
|
|
|
$j /$subdir
|
|
|
|
fi
|
|
|
|
done
|
2002-12-22 22:18:41 +00:00
|
|
|
for j in /conf/$i/*.remove ; do
|
|
|
|
subdir=${j%*.remove}
|
|
|
|
subdir=${subdir##*/}
|
|
|
|
if [ -f $j ]; then
|
|
|
|
# doubly sure it is a memory disk before rm -rf'ing
|
|
|
|
create_md $subdir
|
|
|
|
(cd /$subdir; rm -rf `/bin/cat $j`)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2002-10-02 00:59:14 +00:00
|
|
|
|
2004-03-31 07:24:15 +00:00
|
|
|
# umount partitions used to fill the memory filesystems
|
|
|
|
[ -n "${to_umount}" ] && umount $to_umount
|