Help () {
echo "This script copies the boot programs to one of several"
echo "commonly used places."
echo 'When installing an "ffs" boot program, this script also runs'
echo "installboot(8) which installs the default proto bootblocks into"
echo "the appropriate filesystem partition or filesystem image."
Options
exit 0
}
Secure () {
echo "This script has to be run when the kernel is in 'insecure' mode,"
echo "or when applying bootblocks to a file image (ala vnd)."
echo "The best way is to run this script in single-user mode."
exit 1
}
while getopts b:hf:i:m:tUuv a
do
case "$a" in
h) Help;;
u) ULTRASPARC=true;;
U) ULTRASPARC=false;;
b) BOOTPROG=$OPTARG; OFWBOOTBLK=$OPTARG;;
f) DEV=$OPTARG;;
m) MDEC=$OPTARG;;
i) INSTALLBOOT=$OPTARG;;
t) TEST=1; VERBOSE=-v;;
v) VERBOSE=-v;;
\?) Usage;;
esac
done
shift $(( $OPTIND - 1 ))
if [ "$( sysctl -n kern.securelevel )" -gt 0 ] && ! [ -f "$DEV" ]; then
Secure
fi
DOIT=${TEST:+echo "=>"}
if [ $# != 2 ]; then
Usage
fi
WHAT=$1
DEST=$2
if ! [ -d "$DEST" ]; then
echo "$DEST: not a directory"
Usage
fi
if $ULTRASPARC
then
machine=sparc64
targ=ofwboot
stage2=""
netboot=ofwboot
BOOTPROG=$OFWBOOTBLK
BOOTXX=${MDEC}/bootblk
else
machine=sparc
targ=boot
stage2=${targ}
netboot=boot.net
BOOTXX=${MDEC}/bootxx
fi
case $WHAT in
"ffs")
if [ -z "$DEV" ]; then
# Lookup device mounted on DEST
DEV=$( mount | while read line; do
set -- $line
vecho "Inspecting \"$line\""
if [ "$2" = "on" ] && [ "$3" = "$DEST" ]; then
[ -b "$1" ] || continue
case "$1" in
(*/*) RAW="${1%/*}/r${1##*/}";;
(*) RAW="r$1";;
esac
[ -c "$RAW" ] || continue
echo -n "$RAW"
break;
fi
done )
if [ -z "$DEV" ]; then
echo "Cannot find \"$DEST\" in mount table"
exit 1
fi
fi