blob: 552a18ef41c012d12e97227920f4a0c0f7ed9729 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
#!/bin/sh
# $NetBSD: binstall.sh,v 1.1.2.1 1995/10/13 19:55:03 pk Exp $
#
vecho () {
# echo if VERBOSE on
if [ "$VERBOSE" = "1" ]; then
echo "$@" 1>&2
fi
return 0
}
Usage () {
echo "Usage: $0 [-hvt] [-m<path>] net|ffs directory"
exit 1
}
Help () {
echo "This script copies the boot programs to one of several"
echo "commonly used places. It takes care of stripping the"
echo "a.out(5) header off the installed boot program on sun4 machines."
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."
echo "Options:"
echo " -h - display this message"
echo " -m<path> - Look for boot programs in <path> (default: /usr/mdec)"
echo " -v - verbose mode"
echo " -t - test mode (implies -v)"
exit 0
}
PATH=/bin:/usr/bin:/sbin:/usr/sbin
MDEC=${MDEC:-/usr/mdec}
set -- `getopt "hm:tv" "$@"`
if [ $? -gt 0 ]; then
Usage
fi
for a in $*
do
case $1 in
-h) Help; shift ;;
-m) MDEC=$2; shift 2 ;;
-t) TEST=1; VERBOSE=1; shift ;;
-v) VERBOSE=1; shift ;;
--) shift; break ;;
esac
done
DOIT=${TEST:+echo "=>"}
if [ $# != 2 ]; then
Usage
fi
WHAT=$1
DEST=$2
if [ "`sysctl -n hw.model | cut -b1-5`" = "SUN/4" ]; then
KARCH=sun4
else
KARCH=sun4c
fi
vecho "Kernel architecture: $KARCH"
if [ ! -d $DEST ]; then
echo "$DEST: not a directory"
Usage
fi
if [ $KARCH = sun4 ]; then SKIP=1; else SKIP=0; fi
case $WHAT in
"ffs")
DEV=`mount | while read line; do
set -- $line
vecho "Inspecting \"$line\""
if [ "$2" = "on" -a "$3" = "$DEST" ]; then
if [ ! -b $1 ]; then
continue
fi
RAW=\`echo -n "$1" | sed -e 's;/dev/;/dev/r;'\`
if [ ! -c \$RAW ]; then
continue
fi
echo -n $RAW
break;
fi
done`
if [ "$DEV" = "" ]; then
echo "Cannot find \"$DEST\" in mount table"
exit 1
fi
TARGET=$DEST/boot
vecho Boot device: $DEV
vecho Target: $TARGET
$DOIT dd if=${MDEC}/boot of=$TARGET skip=$SKIP bs=32
sync; sync; sync
vecho installboot ${VERBOSE:+-v} $TARGET ${MDEC}/bootxx $DEV
$DOIT installboot ${VERBOSE:+-v} $TARGET ${MDEC}/bootxx $DEV
;;
"net")
TARGET=$DEST/boot.sparc.openbsd.$KARCH
vecho Target: $TARGET
$DOIT dd if=${MDEC}/boot of=$TARGET skip=$SKIP bs=32
;;
*)
echo "$WHAT: not recognised"
exit 1
;;
esac
exit $?
|