summaryrefslogtreecommitdiffstats
path: root/etc/rc.d
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>1999-02-09 17:17:18 +0000
committerdillon <dillon@FreeBSD.org>1999-02-09 17:17:18 +0000
commita99e9a02dfae99dc45c5b6673bbedb1f2ce60a9e (patch)
treedb3899cf78d76011f17aae9679281affe32feef1 /etc/rc.d
parent433e0009a0470d087a405de80860e9765b785cca (diff)
downloadFreeBSD-src-a99e9a02dfae99dc45c5b6673bbedb1f2ce60a9e.zip
FreeBSD-src-a99e9a02dfae99dc45c5b6673bbedb1f2ce60a9e.tar.gz
Revamp rc.diskless. Split into rc.diskless1 and rc.diskless2. provide
more opportunities for overriding. Clean up /etc/rc ( remove conf_dir, remove startup mount special cases, remove other special cases )
Diffstat (limited to 'etc/rc.d')
-rw-r--r--etc/rc.d/diskless39
-rw-r--r--etc/rc.d/initdiskless100
-rw-r--r--etc/rc.d/resolv39
-rw-r--r--etc/rc.d/tmp39
-rw-r--r--etc/rc.d/var39
5 files changed, 256 insertions, 0 deletions
diff --git a/etc/rc.d/diskless b/etc/rc.d/diskless
new file mode 100644
index 0000000..ddd52fc
--- /dev/null
+++ b/etc/rc.d/diskless
@@ -0,0 +1,39 @@
+
+# PROVIDE: diskless
+# REQUIRE: initdiskless mountcritlocal
+ if [ -n "$4" ]; then
+ bpi="-i $4"
+
+if [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+}
+
+mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
+mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
+mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
+mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
+chmod 755 /var/run
+chmod 755 /var/db
+chmod 755 /var/spool
+chmod 1777 /var/tmp
+fi
+if [ ! -h /tmp -a ! -h /var/tmp ]; then
+ mount_null /var/tmp /tmp
+fi
+#
+mkdir /var/spool/mqueue
+mkdir /var/spool/lpd
+mkdir /var/spool/output
+mkdir /var/spool/output/lpd
+chown -R root.daemon /var/spool/output
+chgrp daemon /var/spool/lpd
+
+( cd /; find -x dev | cpio -o -H newc ) > /tmp/dev.tmp
+mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+( cd /; cpio -i -H newc -d < /tmp/dev.tmp )
+
+ # extract a list of device entries, then copy them to a writable fs
+ (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
+ mount_md 4096 /dev 3 512
+ (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
+fi
diff --git a/etc/rc.d/initdiskless b/etc/rc.d/initdiskless
new file mode 100644
index 0000000..5ce555f
--- /dev/null
+++ b/etc/rc.d/initdiskless
@@ -0,0 +1,100 @@
+#
+# /etc/rc.diskless - general BOOTP startup
+#
+# BOOTP has mounted / for us. Assume a read-only mount. We must then
+# - figure out where the NFS mount is coming from
+# - figure out our IP by querying the interface
+# - retarget /conf/ME softlink to proper configuration script directory
+#
+# It is expected that /etc/fstab and /etc/rc.conf.local will be
+# set by the system operator on the server to be softlinks to
+# /conf/ME/fstab and /conf/ME/rc.conf.local. The system operator may
+# choose to retarget other files as well. The server itself boots
+# properly with its default /conf/ME softlink pointing to
+# /conf/server.host.name.
+#
+# During a diskless boot, we retarget the /conf/ME softlink to point
+# to /conf/DISKLESS.CLIENT.IP.ADDRESS. Thus, various system config
+# files that are softlinks through /conf/ME also get retargeted.
+#
+# SEE SAMPLE FILES IN /usr/share/examples/diskless.
+
+# 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.
+
+chkerr() {
+ if [ $1 != 0 ]; then
+ echo "$2 failed: dropping into /bin/sh"
+ /bin/sh
+ # RESUME
+ fi
+}
+
+# DEBUGGING
+#
+set -v
+
+# Figure out where the root mount is coming from, synthesize a mount
+# for /usr and mount it.
+#
+# e.g. nfs_root might wind up as "A.B.C.D:/"
+#
+# NOTE! the /usr mount is only temporary so we can access commands necessary
+# to retarget /conf/ME. The actual /usr mount should be part of the
+# retargeted /etc/fstab. See instructions in /usr/share/examples/diskless.
+#
+set `/bin/df /`
+nfs_root=$8
+mount_nfs -o ro ${nfs_root}/usr /usr
+
+chkerr $? "mount of /usr"
+
+# Figure out our interface and IP.
+#
+
+bootp_ifc=`route -n get default | fgrep interface | awk '{ print $2; }'`
+bootp_ipa=`ifconfig $bootp_ifc | fgrep inet | head -1 | awk '{ print $2; }'`
+
+echo "Interface $bootp_ifc IP-Address $bootp_ipa"
+
+umount /usr
+
+# retarget /conf/ME
+#
+# MFS's background process takes a bit to startup. Various config files
+# on server should be softlinks through /conf/ME. The server's own /conf/ME
+# points to the server's version of the files.
+#
+# We retarget /conf/ME using a -o union mount. This allows
+# us to 'mkdir' over whatever was there previously.
+#
+# WARNING! null mounts cannot handle mmap, and since many programs
+# use mmap (such as 'cp'), we have to copy.
+
+mount_mfs -s 256 -T qp120at -o union dummy /conf
+chkerr $? "MFS mount on /conf"
+
+mkdir /conf/ME
+cp -Rp /conf/$bootp_ipa/* /conf/ME
+
+# retarget the kernel
+#
+
+sysctl -w kern.bootfile=/conf/ME/kernel
+
+# Tell /etc/rc to run the specified script after
+# it does its mounts but before it does anything
+# else.
+#
+# This script is responsible for setting up the
+# diskless mount environment. This can be
+# overriden by /conf/ME/rc.conf.local if, for
+# example, you do not want to run the standard
+# system /etc/rc.diskless2
+
+diskless_mount="/etc/rc.diskless2"
+
diff --git a/etc/rc.d/resolv b/etc/rc.d/resolv
new file mode 100644
index 0000000..ddd52fc
--- /dev/null
+++ b/etc/rc.d/resolv
@@ -0,0 +1,39 @@
+
+# PROVIDE: diskless
+# REQUIRE: initdiskless mountcritlocal
+ if [ -n "$4" ]; then
+ bpi="-i $4"
+
+if [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+}
+
+mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
+mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
+mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
+mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
+chmod 755 /var/run
+chmod 755 /var/db
+chmod 755 /var/spool
+chmod 1777 /var/tmp
+fi
+if [ ! -h /tmp -a ! -h /var/tmp ]; then
+ mount_null /var/tmp /tmp
+fi
+#
+mkdir /var/spool/mqueue
+mkdir /var/spool/lpd
+mkdir /var/spool/output
+mkdir /var/spool/output/lpd
+chown -R root.daemon /var/spool/output
+chgrp daemon /var/spool/lpd
+
+( cd /; find -x dev | cpio -o -H newc ) > /tmp/dev.tmp
+mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+( cd /; cpio -i -H newc -d < /tmp/dev.tmp )
+
+ # extract a list of device entries, then copy them to a writable fs
+ (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
+ mount_md 4096 /dev 3 512
+ (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
+fi
diff --git a/etc/rc.d/tmp b/etc/rc.d/tmp
new file mode 100644
index 0000000..ddd52fc
--- /dev/null
+++ b/etc/rc.d/tmp
@@ -0,0 +1,39 @@
+
+# PROVIDE: diskless
+# REQUIRE: initdiskless mountcritlocal
+ if [ -n "$4" ]; then
+ bpi="-i $4"
+
+if [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+}
+
+mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
+mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
+mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
+mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
+chmod 755 /var/run
+chmod 755 /var/db
+chmod 755 /var/spool
+chmod 1777 /var/tmp
+fi
+if [ ! -h /tmp -a ! -h /var/tmp ]; then
+ mount_null /var/tmp /tmp
+fi
+#
+mkdir /var/spool/mqueue
+mkdir /var/spool/lpd
+mkdir /var/spool/output
+mkdir /var/spool/output/lpd
+chown -R root.daemon /var/spool/output
+chgrp daemon /var/spool/lpd
+
+( cd /; find -x dev | cpio -o -H newc ) > /tmp/dev.tmp
+mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+( cd /; cpio -i -H newc -d < /tmp/dev.tmp )
+
+ # extract a list of device entries, then copy them to a writable fs
+ (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
+ mount_md 4096 /dev 3 512
+ (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
+fi
diff --git a/etc/rc.d/var b/etc/rc.d/var
new file mode 100644
index 0000000..ddd52fc
--- /dev/null
+++ b/etc/rc.d/var
@@ -0,0 +1,39 @@
+
+# PROVIDE: diskless
+# REQUIRE: initdiskless mountcritlocal
+ if [ -n "$4" ]; then
+ bpi="-i $4"
+
+if [ -f /etc/rc.conf ]; then
+ . /etc/rc.conf
+}
+
+mount_mfs -s ${var_run_sectors:=2048} -T qp120at dummy /var/run
+mount_mfs -s ${var_db_sectors:=16384} -T qp120at dummy /var/db
+mount_mfs -s ${var_tmp_sectors:=65536} -T qp120at dummy /var/tmp
+mount_mfs -s ${var_spool_sectors:=65536} -T qp120at dummy /var/spool
+chmod 755 /var/run
+chmod 755 /var/db
+chmod 755 /var/spool
+chmod 1777 /var/tmp
+fi
+if [ ! -h /tmp -a ! -h /var/tmp ]; then
+ mount_null /var/tmp /tmp
+fi
+#
+mkdir /var/spool/mqueue
+mkdir /var/spool/lpd
+mkdir /var/spool/output
+mkdir /var/spool/output/lpd
+chown -R root.daemon /var/spool/output
+chgrp daemon /var/spool/lpd
+
+( cd /; find -x dev | cpio -o -H newc ) > /tmp/dev.tmp
+mount_mfs -s 4096 -i 512 -T qp120at dummy /dev
+( cd /; cpio -i -H newc -d < /tmp/dev.tmp )
+
+ # extract a list of device entries, then copy them to a writable fs
+ (cd /; find -x dev | cpio -o -H newc) > /tmp/dev.tmp
+ mount_md 4096 /dev 3 512
+ (cd /; cpio -i -H newc -d < /tmp/dev.tmp)
+fi
OpenPOWER on IntegriCloud