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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
#!/bin/sh
# $OpenBSD: upgrade.sh,v 1.3 1996/06/29 05:54:21 tholo Exp $
#
# Copyright (c) 1994 Christopher G. Demetriou
# 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.
# 3. All advertising materials mentioning features or use of this software
# must display the following acknowledgement:
# This product includes software developed by Christopher G. Demetriou.
# 4. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
# OpenBSD upgrade script.
# In a perfect world, this would be a nice C program, with a reasonable
# user interface.
DT=/etc/disktab # /etc/disktab
FSTABDIR=/mnt/etc # /mnt/etc
#DONTDOIT=echo
VERSION=1.0
FSTAB=${FSTABDIR}/fstab
getresp() {
read resp
if [ "X$resp" = "X" ]; then
resp=$1
fi
}
echo "Welcome to the OpenBSD ${VERSION} upgrade program."
echo ""
echo "This program is designed to help you put the new version of OpenBSD"
echo "on your hard disk, in a simple and rational way. To upgrade, you"
echo "must have plenty of free space on all partitions which will be"
echo "upgraded. If you have at least 1MB free on your root partition,"
echo "and several free on your /usr patition, you should be fine."
echo ""
echo "As with anything which modifies your hard drive's contents, this"
echo "program can cause SIGNIFICANT data loss, and you are advised"
echo "to make sure your hard drive is backed up before beginning the"
echo "upgrade process."
echo ""
echo "Default answers are displyed in brackets after the questions."
echo "You can hit Control-C at any time to quit, but if you do so at a"
echo "prompt, you may have to hit return. Also, quitting in the middle of"
echo "the upgrade may leave your system in an inconsistent (and unusable)"
echo "state."
echo ""
echo -n "Proceed with upgrade? [n] "
getresp "n"
case "$resp" in
y*|Y*)
echo "Cool! Let's get to it..."
;;
*)
echo ""
echo "OK, then. Enter 'halt' at the prompt to halt the"
echo "machine. Once the machine has halted, remove the"
echo "floppy and press any key to reboot."
exit
;;
esac
# find out what units are possible, and query the user.
driveunits=`ls /dev/[sw]d?a | sed -e 's,/dev/\(...\)a,\1,g'`
if [ "X${driveunits}" = "X" ]; then
echo "FATAL ERROR:"
echo "No disk devices."
echo "This is probably a bug in the install disks."
echo "Exiting install program."
exit
fi
echo ""
echo "The following disks are supported by this upgrade procedure:"
echo " "${driveunits}
echo "If your system was previously completely contained within the"
echo "disks listed above (i.e. if your system didn't occupy any space"
echo "on disks NOT listed above), this upgrade disk can upgrade your"
echo "system. If it cannot, hit Control-C at the prompt."
echo ""
while [ "X${drivename}" = "X" ]; do
echo -n "Which disk contains your root partion? "
getresp
otherdrives=`echo "${driveunits}" | sed -e s,${resp},,`
if [ "X${driveunits}" = "X${otherdrives}" ]; then
echo ""
echo "\"${resp}\" is an invalid drive name. Valid choices"
echo "are: "${driveunits}
echo ""
else
drivename=${resp}
fi
done
echo ""
echo "Root partition is on ${drivename}a."
echo ""
echo "Would you like to upgrade your file systems to the new file system"
echo -n "format? [y] "
getresp "y"
case "$resp" in
n*|N*)
echo ""
echo "You should upgrade your file systems with 'fsck -c 2'"
echo "as soon as is feasible, because the new file system"
echo "code is better-tested and more performant."
upgradefs=NO
;;
*)
upgradefs=YES
;;
esac
if [ $upgradefs = YES ]; then
echo ""
echo "Upgrading the file system on ${drivename}a..."
fsck -p -c 2 /dev/r${drivename}a
if [ $? != 0 ]; then
echo "FATAL ERROR: FILE SYSTEM UPGRADE FAILED."
echo "You should probably reboot the machine, fsck your"
echo "disk(s), and try the upgrade procedure again."
exit 1
fi
echo "Done."
fi
echo ""
echo "Mounting root partition on /mnt..."
mount /dev/${drivename}a /mnt
if [ $? != 0 ]; then
echo "FATAL ERROR: MOUNT FAILED."
echo "You should verify that your system is set up as you"
echo "described, and re-attempt the upgrade procedure."
exit 1
fi
echo "Done."
if [ $upgradefs = YES ]; then
echo ""
echo -n "Copying new fsck binary to your hard disk..."
if [ ! -d /mnt/sbin ]; then
mkdir /mnt/sbin
fi
cp /sbin/fsck /mnt/sbin/fsck
if [ $? != 0 ]; then
echo "FATAL ERROR: COPY FAILED."
echo "It in unclear why this error would occur. It looks"
echo "like you may end up having to upgrade by hand."
exit 1
fi
echo " Done."
echo ""
echo "Re-mounting root partition read-only..."
mount -u -o ro /dev/${drivename}a /mnt
if [ $? != 0 ]; then
echo "FATAL ERROR: RE-MOUNT FAILED."
echo "It in unclear why this error would occur. It looks"
echo "like you may end up having to upgrade by hand."
exit 1
fi
echo "Done."
echo ""
echo "Upgrading the rest of your file systems..."
chroot /mnt fsck -p -c 2
if [ $? != 0 ]; then
echo "FATAL ERROR: FILE SYSTEM UPGRADE(S) FAILED."
echo "You should probably reboot the machine, fsck your"
echo "file system(s), and try the upgrade procedure"
echo "again."
exit 1
fi
echo "Done."
echo ""
echo "Re-mounting root partition read-write..."
mount -u -o rw /dev/${drivename}a /mnt
if [ $? != 0 ]; then
echo "FATAL ERROR: RE-MOUNT FAILED."
echo "It in unclear why this error would occur. It looks"
echo "like you may end up having to upgrade by hand."
exit 1
fi
echo "Done."
fi
echo ""
echo "Updating boot blocks on ${drivename}..."
disklabel -r $drivename > /mnt/tmp/${drivename}.label
if [ $? != 0 ]; then
echo "FATAL ERROR: READ OF DISK LABEL FAILED."
echo "It in unclear why this error would occur. It looks"
echo "like you may end up having to upgrade by hand."
exit 1
fi
disklabel -R -B $drivename /mnt/tmp/${drivename}.label
if [ $? != 0 ]; then
echo "FATAL ERROR: UPDATE OF DISK LABEL FAILED."
echo "It in unclear why this error would occur. It looks"
echo "like you may end up having to upgrade by hand."
exit 1
fi
echo "Done."
echo ""
echo "Copying bootstrapping binaries and config files to the hard drive..."
$DONTDOIT cp /mnt/.profile /mnt/.profile.bak
$DONTDOIT pax -rw -X -k . /mnt
$DONTDOIT mv /mnt/etc/rc /mnt/etc/rc.bak
$DONTDOIT cp /tmp/.hdprofile /mnt/.profile
echo ""
echo "Mounting remaining partitions..."
chroot /mnt mount -at ufs > /dev/null 2>&1
echo "Done."
echo ""
echo ""
echo "OK! The preliminary work of setting up your disk is now complete,"
echo "and you can now upgrade the actual OpenBSD software."
echo ""
echo "Right now, your hard disk is mounted on /mnt. You should consult"
echo "the installation notes to determine how to load and install the new"
echo "OpenBSD distribution sets, and how to clean up after the upgrade"
echo "software, when you are done."
echo ""
echo "GOOD LUCK!"
echo ""
|