Commit 6a4501a7 authored by Mike Hibler's avatar Mike Hibler

New strategy for dealing with loader.conf on FreeBSD.

Before doing anything, make a copy of loader.conf to loader.conf.preemulab.
Have prepare script copy back loader.conf.preemulab before creating a new
image. This will hopefully get rid of node-specific cruft that we put into
that file at slicefix time (e.g., disabling interfaces, changing the
console device). We also just append all our variable settings to the end
of that file rather than trying to clean out other settings or change them
in place. This allows another potential form of cleanup--just remove
everything after a certain point in the file.

This should conclude (modulo bug fixes) my recent unhealthy obsession with
rc.frisbee/slicefix...
parent 2f0f4d58
#!/usr/bin/perl -w
#
# Copyright (c) 2000-2014 University of Utah and the Flux Group.
# Copyright (c) 2000-2015 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -46,6 +46,7 @@ my $SFSUSERS = "/etc/sfs/sfs_users";
my $SFSHOSTKEY = "/etc/sfs/sfs_host_key";
my $MOUNTINFO = "/var/db/mounttab";
my $ENTROPY = "/var/db/entropy/*";
my $LOADERCONF = "/boot/loader.conf";
#
# Dead wood in $BINDIR
......@@ -240,6 +241,14 @@ if (-f $NTPDRIFT) {
close(DRIFT);
}
#
# Restore a clean loader.conf file.
#
if (-f "$LOADERCONF.preemulab") {
print "Restoring original $LOADERCONF ...\n";
system("cp -p $LOADERCONF.preemulab $LOADERCONF");
}
print "Cleaning .pid files ...\n";
system("rm -rf $RUNDIR/*.pid /var/spool/*/*.pid");
......
......@@ -554,7 +554,22 @@ dofreebsd() {
dd if=/dev/random of=/mnt/entropy bs=4096 count=1 >/dev/null 2>&1
fi
lcbak=".preemulab"
#
# Modify /boot/loader.conf.
#
# We append all our settings at the end, prefixed by a header line.
# We also create a copy of the file before we make any modifications.
# This way the "prepare" script run when creating a new image can
# remove all these settings easily.
#
cp -p /mnt/boot/loader.conf /mnt/boot/loader.conf.preemulab || {
echo "WARNING: could not create a copy of loader.conf"
}
cat <<EOF4 >>/mnt/boot/loader.conf
# The remaining lines were added by Emulab slicefix.
# DO NOT ADD ANYTHING AFTER THIS POINT AS IT WILL GET REMOVED.
EOF4
if [ $changeacpi -eq 1 ]; then
if [ $ACPI = "no" ]; then
on="dis"
......@@ -562,12 +577,6 @@ dofreebsd() {
on="en"
fi
echo " ${on}abling ACPI"
sed -E -i "$lcbak" -e "/[Aa][Cc][Pp][Ii]/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
lcbak=""
if [ $ACPI = "no" ]; then
cat <<EOF1 >>/mnt/boot/loader.conf
# disable ACPI
......@@ -591,12 +600,6 @@ EOF2
on="en"
fi
echo " ${on}abling ASF"
sed -E -i "$lcbak" -e "/[Aa][Ss][Ff]/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
lcbak=""
if [ $ASF = "no" ]; then
cat <<EOF1 >>/mnt/boot/loader.conf
# disable ASF
......@@ -628,14 +631,6 @@ EOF0
if [ $changecons -eq 1 ]; then
echo " setting console to $CONSOLE"
# get rid of any existing console setting
sed -E -i "$lcbak" -e "/^console=/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
lcbak=""
case $CONSOLE in
null|vid)
cname="${CONSOLE}console"
......@@ -671,11 +666,6 @@ EOF0
console="$cname"
EOF1
# get rid of any comconsole excesses
if [ "$curconsole" = "comconsole" ]; then
sed -E -i "$lcbak" -e "/^comconsole/d" -e "/^hint.$drv./d" /mnt/boot/loader.conf
fi
# now deal with comconsole settings
if [ "$cname" = "comconsole" ]; then
#
......@@ -729,12 +719,6 @@ EOF2
on="en"
fi
echo " ${on}abling use of CLFLUSH"
sed -E -i "$lcbak" -e "/clflush_disable/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
lcbak=""
cat <<EOF1 >>/mnt/boot/loader.conf
# ${on}able CLFLUSH (hw.clflush_disable)
hw.clflush_disable=$NOCLFLUSH
......
......@@ -599,7 +599,22 @@ dofreebsd() {
dd if=/dev/random of=/mnt/entropy bs=4096 count=1 >/dev/null 2>&1
fi
lcbak=".preemulab"
#
# Modify /boot/loader.conf.
#
# We append all our settings at the end, prefixed by a header line.
# We also create a copy of the file before we make any modifications.
# This way the "prepare" script run when creating a new image can
# remove all these settings easily.
#
cp -p /mnt/boot/loader.conf /mnt/boot/loader.conf.preemulab || {
echo "WARNING: could not create a copy of loader.conf"
}
cat <<EOF4 >>/mnt/boot/loader.conf
# The remaining lines were added by Emulab slicefix.
# DO NOT ADD ANYTHING AFTER THIS POINT AS IT WILL GET REMOVED.
EOF4
if [ $changeacpi -eq 1 ]; then
if [ $ACPI = "no" ]; then
on="dis"
......@@ -607,15 +622,6 @@ dofreebsd() {
on="en"
fi
echo " ${on}abling ACPI"
if [ -n "$lcbak" ]; then
cp -fp /mnt/boot/loader.conf /mnt/boot/loader.conf${lcbak}
lcbak=""
fi
sed -i -e "/[Aa][Cc][Pp][Ii]/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
if [ $ACPI = "no" ]; then
cat <<EOF1 >>/mnt/boot/loader.conf
# disable ACPI
......@@ -639,15 +645,6 @@ EOF2
on="en"
fi
echo " ${on}abling ASF"
if [ -n "$lcbak" ]; then
cp -fp /mnt/boot/loader.conf /mnt/boot/loader.conf${lcbak}
lcbak=""
fi
sed -i -e "/[Aa][Ss][Ff]/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
if [ $ASF = "no" ]; then
cat <<EOF1 >>/mnt/boot/loader.conf
# disable ASF
......@@ -679,17 +676,6 @@ EOF0
if [ $changecons -eq 1 ]; then
echo " setting console to $CONSOLE"
if [ -n "$lcbak" ]; then
cp -fp /mnt/boot/loader.conf /mnt/boot/loader.conf${lcbak}
lcbak=""
fi
# get rid of any existing console setting
sed -i -e "/^console=/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
case $CONSOLE in
null|vid)
cname="${CONSOLE}console"
......@@ -725,11 +711,6 @@ EOF0
console="$cname"
EOF1
# get rid of any comconsole excesses
if [ "$curconsole" = "comconsole" ]; then
sed -E -i -e "/^comconsole/d" -e "/^hint.$drv./d" /mnt/boot/loader.conf
fi
# now deal with comconsole settings
if [ "$cname" = "comconsole" ]; then
#
......@@ -783,15 +764,6 @@ EOF2
on="en"
fi
echo " ${on}abling use of CLFLUSH"
if [ -n "$lcbak" ]; then
cp -fp /mnt/boot/loader.conf /mnt/boot/loader.conf${lcbak}
lcbak=""
fi
sed -E -i -e "/clflush_disable/d" /mnt/boot/loader.conf || {
echo "Failed to update /boot/loader.conf"
umount $rootdev
return 1
}
cat <<EOF1 >>/mnt/boot/loader.conf
# ${on}able CLFLUSH (hw.clflush_disable)
hw.clflush_disable=$NOCLFLUSH
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment