Annotation of openbsd/update_openbsd/update_openbsd, Revision 1.58
1.1 andrew 1: #!/bin/sh
1.58 ! andrew 2: # $AFresh1: update_openbsd,v 1.57 2013/12/31 18:42:31 andrew Exp $
1.41 andrew 3: #
4: # Copyright (c) 2012 Andrew Fresh <andrew@afresh1.com>
5: #
6: # Permission to use, copy, modify, and distribute this software for any
7: # purpose with or without fee is hereby granted, provided that the above
8: # copyright notice and this permission notice appear in all copies.
9: #
10: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: #
1.7 andrew 18:
1.2 andrew 19: installed_sets() {
1.5 andrew 20: local misc=/usr/share/doc/README
21: local man=/usr/share/man/cat1/intro.0
22: local comp=/usr/bin/cc
23: local game=/usr/games/
24: local xbase=/usr/X11R6/
25: local xetc=/etc/X11/xinit/xinitrc
26: local xfont=/usr/X11R6/lib/X11/fonts
27: local xserv=/usr/X11R6/bin/X
28: local xshare=/usr/X11R6/bin/startx
29:
30: local _c _d _e
31: echo -n base
32: echo -n ' etc'
1.3 andrew 33: for _d in misc man comp game xbase xetc xfont xserv xshare; do
34: eval _e=\$${_d}
35: _c=`ls $_e 2> /dev/null | wc -l`
36: #echo $_c $_d $_e
37: if [ $_c -ne 0 ]; then
1.5 andrew 38: echo -n " $_d"
1.2 andrew 39: fi
40: done
1.19 andrew 41:
1.34 andrew 42: sendmail -d0.1 --badoption </dev/null 2>/dev/null | grep -q SASL
1.19 andrew 43: if [ $? == 0 ]; then
44: echo -n ' sendmail-smtp_auth'
45: fi
1.2 andrew 46: }
1.7 andrew 47:
1.39 andrew 48: kernel_file_version() {
49: echo exit | config -e $1 | grep -A1 ^OpenBSD
50: #what $1 | sed -ne 's/[[:blank:]]\{1,\}//p'
51: }
52:
1.16 andrew 53: version_in() {
1.10 andrew 54: local _proto=${FTP%%://*}
1.16 andrew 55: local _file
1.10 andrew 56:
57: if [ X"ftp" == X"${_proto}" ]; then
1.16 andrew 58: local _list=`echo "ls base*.tgz" | ${FTP_CMD} ${FTP}/`
59: _file=`echo ${_list} | awk '/base[0-9][0-9].tgz/ { print $9 }'`
1.15 andrew 60:
1.10 andrew 61: elif [ X"http" == X"${_proto}" ]; then
1.16 andrew 62: local _list=`${FTP_CMD} -V -o - ${FTP}/`
63: _file=`echo ${_list} | awk '/[^x]base[0-9][0-9]*\.tgz/ {
1.15 andrew 64: sub("^.*base","base");
65: sub("\.tgz.*",".tgz");
66: print $0;
1.16 andrew 67: }'`
1.15 andrew 68:
69: elif [ X"scp" == X"${_proto}" ]; then
70: echo SCP is not yet supported >&2
71: return 2
72:
1.10 andrew 73: else
74: echo Unsupported FTP ${FTP} >&2
1.12 andrew 75: return 2
1.15 andrew 76:
1.10 andrew 77: fi
1.16 andrew 78:
79: local _v=${_file##*base}
80: _v=${_v%.tgz*}
81: echo $_v
1.10 andrew 82: }
1.2 andrew 83:
84: set_version() {
85: CUR_VER=`uname -r`
1.3 andrew 86: NEW_VER=`dc -e "$CUR_VER 0.1 + p"`
1.5 andrew 87: FILE_VER=""
88: FTP=""
1.2 andrew 89:
1.5 andrew 90: local _cv=`echo $CUR_VER | sed -e 's/\.//'`
91: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.9 andrew 92: local _v
1.5 andrew 93:
1.10 andrew 94: if [ X"No" != X"$FORCE_DIR" -a -d $FORCE_DIR ]; then
1.5 andrew 95: _dir=$FORCE_DIR
96: if [ -e ${_dir}/base${_nv}.tgz ]; then
97: _v=$_nv
98: elif [ -e ${_dir}/base${_cv}.tgz ]; then
99: NEW_VER=$CUR_VER
100: _v=$_cv
101: fi
1.2 andrew 102:
1.5 andrew 103: elif [ -d $CUR_VER ]; then
104: _dir=$CUR_VER
1.2 andrew 105: NEW_VER=$CUR_VER
1.5 andrew 106: if [ -e ${_dir}/base${_cv}.tgz ]; then
107: _v=$_cv
108: fi
1.2 andrew 109:
1.5 andrew 110: elif [ -d $NEW_VER ]; then
111: _dir=$NEW_VER
112: if [ -e ${_dir}/base${_nv}.tgz ]; then
113: _v=$_nv
114: fi
1.2 andrew 115:
116: fi
117:
1.17 andrew 118: if [ X"" != X"${MIRROR}" -a X"" == X"${_v}" ]; then
1.10 andrew 119: if [ X"No" == X"${FORCE_DIR}" ]; then
1.5 andrew 120: _dir=${NEW_VER}
121: else
122: _dir=${FORCE_DIR}
123: fi
124: FTP=${MIRROR}/${_dir}/`machine`
1.2 andrew 125:
1.16 andrew 126: _v=`version_in`
1.10 andrew 127:
1.16 andrew 128: if [ X"" == X"${_v}" ]; then
1.10 andrew 129: if [ X"No" != X"$FORCE_DIR" ]; then
130: echo No sets in forced [${FTP}] >&2
1.12 andrew 131: return 2
1.10 andrew 132: fi
133:
134: NEW_VER=$CUR_VER
135: _dir=${NEW_VER}
136: FTP=${MIRROR}/${_dir}/`machine`
137:
1.16 andrew 138: _v=`version_in`
1.9 andrew 139: fi
140:
1.10 andrew 141: if [ X"" == X"${_v}" ]; then
1.16 andrew 142: echo No sets in [${FTP}] >&2
1.12 andrew 143: return 2
1.10 andrew 144: elif [ X"${_cv}" == X"${_v}" ]; then
1.5 andrew 145: NEW_VER=$CUR_VER
1.9 andrew 146: elif [ X"${_nv}" == X"${_v}" ]; then
147: NEW_VER=$NEW_VER
1.2 andrew 148: else
1.10 andrew 149: echo Invalid version [$_v] >&2
1.12 andrew 150: return 2
1.2 andrew 151: fi
152:
1.10 andrew 153: if [ X"No" == X"$FORCE_DIR" ]; then
1.5 andrew 154: _dir=$NEW_VER
1.2 andrew 155: fi
156:
157: fi
158:
1.5 andrew 159: if [ X"" == X"${_v}" ]; then
160: echo ERROR: Unable to determine file version! >&2
1.12 andrew 161: return 1
1.2 andrew 162: fi
163:
1.5 andrew 164: if [ X"" == X"$RELEASEDIR" ]; then
165: RELEASEDIR=`pwd`/$_dir
1.2 andrew 166: fi
1.9 andrew 167:
1.5 andrew 168: FILE_VER=$_v
1.17 andrew 169: if [ X"" != X"${MIRROR}" ]; then
170: FTP=${MIRROR}/${_dir}/`machine`
171: fi
1.39 andrew 172:
173: BOOT_KERNEL=`( \
174: echo bsd; \
175: [ -e /boot.conf ] && sed -E '/^ *(set +image|boot) +/!d ; \
176: s///; s/^.*://; s/ .*$//' /boot.conf \
177: ) | tail -1`
1.42 andrew 178: BOOT_KERNEL=`follow_symlink /$BOOT_KERNEL`
1.39 andrew 179: BOOT_KERNEL="/${BOOT_KERNEL#/}"
180:
181: BOOT_KERNEL_VERSION=`kernel_file_version $BOOT_KERNEL`
182:
183: BOOTED_KERNEL_VERSION=`sysctl -n kern.version`
184: NEW_KERNEL_VERSION=""
185:
186: # We want to default to what we had
187: INSTALL_KERNELS="${BOOT_KERNEL#/}"
1.48 andrew 188: # if the boot kernel was our specially named bsd.sp, we install from bsd
189: if [ X"$INSTALL_KERNELS" == X"bsd.sp" ]; then
190: INSTALL_KERNELS="bsd"
191: fi
1.39 andrew 192: # with a second option of an mp kernel if is is a likely candidate
193: if [ X"$INSTALL_KERNELS" != X"bsd.mp" ]; then
194: local _ncpu=$(sysctl -n hw.ncpufound)
195: [ $_ncpu -gt 1 ] && INSTALL_KERNELS="$INSTALL_KERNELS bsd.mp"
196: fi
197: # or just bsd otherwise
198: if [ X"${INSTALL_KERNELS% *}" != X"bsd" ]; then
199: INSTALL_KERNELS="$INSTALL_KERNELS bsd"
200: fi
201: BOOT_KERNELS=$INSTALL_KERNELS
202: INSTALL_KERNELS="$INSTALL_KERNELS bsd.rd"
1.2 andrew 203: }
204:
205: get_sets() {
1.54 andrew 206: echo '==> GETTING SETS'
1.2 andrew 207: if [ X"" == X"$FTP" ]; then
1.5 andrew 208: echo ERROR: No FTP site set! >&2
1.12 andrew 209: return 1
1.2 andrew 210: fi
211:
1.5 andrew 212: mkdir -p ${RELEASEDIR}
213: cd $RELEASEDIR
1.2 andrew 214:
1.5 andrew 215: local _v=$FILE_VER
1.2 andrew 216:
1.39 andrew 217: for _b in $INSTALL_KERNELS; do
1.45 andrew 218: if [ ! -e ./${_b} ]; then
1.54 andrew 219: echo "===> $FTP_CMD ${FTP}/${_b}"
1.3 andrew 220: $FTP_CMD ${FTP}/${_b}
1.2 andrew 221: fi
222: done
223:
1.5 andrew 224: for _s in $INSTALLED_SETS; do
1.19 andrew 225: local _file=${_s}${_v}.tgz
226: if [ ${_s} == sendmail-smtp_auth ]; then
227: _file=${_s}.gz
228: fi
229:
230: if [ ! -e ./${_file} ]; then
1.54 andrew 231: echo "===> $FTP_CMD ${FTP}/${_file}"
1.19 andrew 232: $FTP_CMD ${FTP}/${_file}
1.5 andrew 233: fi
1.2 andrew 234: done
235:
1.20 andrew 236: local _type
1.56 andrew 237: local _ftp
1.20 andrew 238: for _type in $CHECKSUM_TYPES; do
1.40 andrew 239: [ -e $_type ] && break
1.56 andrew 240: _ftp=`echo "$FTP" | sed -e 's,://[^/]*/,://ftp.openbsd.org/,'`
241: echo "===> $FTP_CMD ${_ftp}/$_type"
242: $FTP_CMD ${_ftp}/$_type
1.20 andrew 243: done
1.17 andrew 244: }
245:
1.23 andrew 246: follow_symlink () {
247: local _file=$1
1.33 andrew 248: # This could go circular, but I dunno how to fix that.
249: if [ -h $_file ]; then
250: follow_symlink $( file $_file |
251: grep 'symbolic link' |
252: sed -e s/^.*\\\`// -e s/\\\'\$// )
1.23 andrew 253: else
1.33 andrew 254: echo $_file
1.23 andrew 255: fi
256: }
257:
1.20 andrew 258: check_sum () {
259: local _type=$1
1.54 andrew 260: echo "==> CHECKING $_type SUMS"
1.17 andrew 261: cd $RELEASEDIR
262:
1.20 andrew 263: if [ ! -e $_type ]; then
264: echo $_type File does not exist!
1.17 andrew 265: return 1
266: fi
1.6 andrew 267:
1.57 andrew 268: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
269:
270: (
1.58 ! andrew 271: for _b in $INSTALL_KERNELS; do echo "($_b)" ; done
! 272: for _s in $INSTALLED_SETS; do echo "($_s$_nv.tgz)"; done
1.57 andrew 273: ) > index
1.54 andrew 274: grep -f index $_type | sum -c
1.2 andrew 275:
276: if [ $? -ne 0 ]; then
1.20 andrew 277: echo ERROR: $_type does not match! >&2
1.12 andrew 278: return 1
1.2 andrew 279: fi
280: }
281:
1.17 andrew 282: check_sets() {
1.54 andrew 283: echo '==> CHECKING SETS'
1.17 andrew 284: cd $RELEASEDIR
285:
1.18 andrew 286: local _missing_sets
1.17 andrew 287: local _v=$FILE_VER
288:
1.39 andrew 289: for _n in $INSTALL_KERNELS; do
290: local _o=$_n
291: [ X"bsd" == X"${_o}" -a -e /bsd.sp ] && _o=bsd.sp
292: if [ -e /${_o} -a ! -e ./${_n} ]; then
293: echo ${_o} does not exist
294: _missing_sets=1
1.17 andrew 295: fi
1.39 andrew 296:
297: if [ X"${BOOT_KERNEL}" == X"/${_o}" -a -e ./${_n} ]; then
298: NEW_KERNEL_VERSION=`kernel_file_version ./${_n}`
1.17 andrew 299: fi
300: done
301:
1.39 andrew 302: if [ X"$NEW_KERNEL_VERSION" == X"" ]; then
303: echo Missing replacement for boot kernel $BOOT_KERNEL >&2
304: _missing_sets=1
305: fi
306:
1.17 andrew 307: for _s in $INSTALLED_SETS; do
1.19 andrew 308: local _file=${_s}${_v}.tgz
309: if [ ${_s} == sendmail-smtp_auth ]; then
310: _file=${_s}.gz
311: fi
312: if [ ! -e ./${_file} ]; then
313: echo ${_file} does not exist
1.18 andrew 314: _missing_sets=1
1.17 andrew 315: fi
316: done
1.18 andrew 317:
318: if [ X"" == X"${_missing_sets}" ]; then
1.54 andrew 319: echo '===> All OK'
1.18 andrew 320: fi
1.17 andrew 321:
1.20 andrew 322: local _type
323: for _type in $CHECKSUM_TYPES; do
324: if [ -e $_type ]; then
325: check_sum $_type
1.55 andrew 326: [ $? -ne 0 -a -z "$IGNORE_CHECKSUM_ERROR" ] && exit 1
1.20 andrew 327: fi
328: done
1.17 andrew 329: }
330:
331:
1.30 andrew 332: install_kernels() {
1.54 andrew 333: echo '==> INSTALLING KERNEL'
1.3 andrew 334: if [ X"$USER" != X"root" -a X"$SUDO" == X"" ]; then
1.2 andrew 335: echo ${0##*/} must be run as root or SUDO must be set! >&2
336: exit 1
337: fi
338:
339: if [ X"" == X"$RELEASEDIR" ]; then
1.5 andrew 340: echo ERROR: no source for new kernels! >&2
1.2 andrew 341: exit 1
342: fi
343:
1.46 andrew 344: if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
1.54 andrew 345: echo "===> Backing up $BOOT_KERNEL to /obsd"
1.46 andrew 346: $SUDO ln -f $BOOT_KERNEL /obsd
347: if [ $? -ne 0 ]; then
348: echo "Error copying old kernel!" >&2
349: exit 1
350: fi
1.2 andrew 351: fi
352:
1.39 andrew 353: cd $RELEASEDIR
1.23 andrew 354:
1.39 andrew 355: for _b in $INSTALL_KERNELS; do
1.3 andrew 356: $SUDO rm -f /nbsd
1.39 andrew 357: local _bd=$_b
358: [ X"${_b}" == X"bsd" ] && _bd="bsd.sp"
1.2 andrew 359:
1.39 andrew 360: local _is_boot=""
361: [ X"$BOOT_KERNEL" == X"/${_bd}" ] && _is_boot="# boot kernel"
362:
1.54 andrew 363: echo "===> Copying $_b to /$_bd $_is_boot"
1.39 andrew 364: $SUDO cp ${_b} /nbsd && $SUDO mv /nbsd /${_bd}
1.2 andrew 365: if [ $? -ne 0 ]; then
1.39 andrew 366: echo ERROR: Could not copy new $_bd kernel! >&2
1.2 andrew 367: exit 1
368: fi
1.39 andrew 369: done
370:
371: cd $OLDPWD
1.23 andrew 372:
1.39 andrew 373: if [ ! -h /bsd ]; then
374: cd /
375: for _b in $BOOT_KERNELS; do
376: [ X"$_b" == X"bsd" ] && _b="bsd.sp"
377: if [ -e $_b ]; then
1.54 andrew 378: echo "===> symlinking $_b to /bsd"
1.39 andrew 379: $SUDO ln -sf $_b bsd
380: if [ $? -ne 0 ]; then
381: echo ERROR: Could not symlink new kernel! >&2
382: exit 1
383: fi
384: break
385: fi
386: done
387: cd $OLDPWD
1.2 andrew 388: fi
389: }
390:
391: install_sets() {
1.54 andrew 392: echo '==> INSTALLING SETS'
1.3 andrew 393: if [ X"$USER" != X"root" -a X"$SUDO" == X"" ]; then
1.2 andrew 394: echo ${0##*/} must be run as root or SUDO must be set! >&2
395: exit 1
396: fi
397:
398: if [ X"" == X"$RELEASEDIR" ]; then
1.5 andrew 399: echo ERROR: no source for sets! >&2
1.2 andrew 400: exit 1
401: else
402: cd $RELEASEDIR
403: fi
404:
1.5 andrew 405: local _v=$FILE_VER
406:
1.21 andrew 407: local _sets=`ls *${_v}.tgz | grep -v ^base `
408: for _f in ${_sets} base${_v}.tgz; do
1.3 andrew 409: _path=$DESTDIR
410: if [ X"etc${_v}.tgz" == X"$_f" \
411: -o X"xetc${_v}.tgz" == X"$_f" ]; then
1.21 andrew 412: [ X"" != X"$SYSMERGE" ] && continue
1.2 andrew 413: _path=/var/tmp/temproot
414: fi
415:
1.54 andrew 416: echo "===> Extracting $_f to $_path"
1.3 andrew 417: $SUDO mkdir -p $_path
418: $SUDO tar -C $_path -xzphf ${RELEASEDIR}/${_f}
1.2 andrew 419: if [ $? -ne 0 ]; then
1.5 andrew 420: echo ERROR: Could not extract ${_f}! >&2
1.2 andrew 421: exit 1
422: fi
423: done
424:
1.54 andrew 425: echo '===> Extracted all sets.'
1.51 andrew 426: }
1.19 andrew 427:
1.51 andrew 428: install_sendmail_smtp_auth() {
1.19 andrew 429: if [ -e ${RELEASEDIR}/sendmail-smtp_auth.gz ]; then
430: gzcat ${RELEASEDIR}/sendmail-smtp_auth.gz > \
431: ${RELEASEDIR}/sendmail-smtp_auth
432: fi
433: if [ -e ${RELEASEDIR}/sendmail-smtp_auth ]; then
1.21 andrew 434: if ! pkg_info -qe 'cyrus-sasl-*'; then
435: $SUDO pkg_add -i cyrus-sasl
436: fi
437:
438: $SUDO install -o root -g smmsp -m 2555 \
1.19 andrew 439: ${RELEASEDIR}/sendmail-smtp_auth \
1.21 andrew 440: /usr/libexec/sendmail/sendmail
1.19 andrew 441:
1.54 andrew 442: echo '===> Installed sendmail with smtp_auth'
1.19 andrew 443: fi
1.2 andrew 444: }
445:
446: update_etc() {
1.54 andrew 447: echo '==> UPDATING ETC'
1.10 andrew 448: if [ ! -e $SYSMERGE ]; then
1.47 andrew 449: echo "ERROR: Can't find sysmerge!" >&2
450: exit 1;
1.10 andrew 451: fi
452:
1.47 andrew 453: if [ X"" == X"$RELEASEDIR" ]; then
454: echo "ERROR: no source for etc!" >&2
455: exit 1
456: fi
1.2 andrew 457:
1.47 andrew 458: cd $RELEASEDIR
1.5 andrew 459:
1.47 andrew 460: local _v=$FILE_VER
461: local _args=""
462: if [ -e etc${_v}.tgz ]; then
463: _args="$_args -s etc${_v}.tgz"
464: fi
465: if [ -e xetc${_v}.tgz ]; then
466: _args="$_args -x xetc${_v}.tgz"
467: fi
468: if [ X"" == X"$_args" ]; then
469: echo ERROR: No upgrade sets found! >&2
1.2 andrew 470: else
1.54 andrew 471: echo '==> RUNNING SYSMERGE'
1.47 andrew 472: $SUDO $SYSMERGE $_args
473: fi
1.2 andrew 474:
1.47 andrew 475: cd $OLDPWD
1.2 andrew 476: }
1.14 andrew 477:
1.20 andrew 478:
1.14 andrew 479: if [ -e /etc/update_openbsd.conf ]; then
480: . /etc/update_openbsd.conf
481: fi
482:
483: if [ -e ${HOME}/.update_openbsdrc ]; then
484: . ${HOME}/.update_openbsdrc
485: fi
486:
1.17 andrew 487: #MIRROR=${MIRROR:=ftp://ftp.openbsd.org/pub/OpenBSD}
1.14 andrew 488: FTP_CMD=${FTP_CMD:=ftp -V}
489: PKG_PATH=${PKG_PATH:=/usr/ports/packages/`machine`/all/:${MIRROR}/`uname -r`/packages/`machine`/}
490:
491: DESTDIR=${DESTDIR:=/}
492: SYSMERGE=${SYSMERGE:=/usr/sbin/sysmerge}
493: FORCE_DIR=${FORCE_DIR:=No}
494:
495: INSTALLED_SETS=${INSTALLED_SETS:=`installed_sets`}
1.2 andrew 496:
1.21 andrew 497: CHECKSUM_TYPES=${CHECKSUM_TYPES:=SHA256 MD5}
1.20 andrew 498:
1.2 andrew 499: set_version
1.12 andrew 500: local _error=$?
1.2 andrew 501:
502: echo
503: echo "-= update_openbsd - helper script to update OpenBSD =-"
504: echo "------------------------------------------------------"
505: echo
1.39 andrew 506: echo " SUDO: $SUDO"
507: echo " SYSMERGE: $SYSMERGE"
508: echo " MIRROR: $MIRROR"
509: echo " RELEASEDIR: $RELEASEDIR"
510: echo " DESTDIR: $DESTDIR"
511: echo " BOOT_KERNEL: $BOOT_KERNEL"
512: echo "INSTALL_KERNELS: $INSTALL_KERNELS"
513: echo " INSTALLED_SETS: $INSTALLED_SETS"
1.8 andrew 514: echo
1.39 andrew 515: echo " CUR_VER: $CUR_VER"
516: echo " NEW_VER: $NEW_VER"
517: #echo " FILE_VER: $FILE_VER"
1.2 andrew 518: echo
1.12 andrew 519:
520: if [ ${_error} -ne 0 ]; then
521: exit ${_error}
522: fi
1.2 andrew 523:
1.17 andrew 524: if [ X"" != X"${FTP}" ]; then
1.20 andrew 525: get_sets
1.17 andrew 526: fi
527:
528: check_sets || exit
1.39 andrew 529:
1.54 andrew 530: echo "===> Last booted:\n$BOOTED_KERNEL_VERSION"
1.39 andrew 531: if [ X"$BOOT_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" \
532: -a X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
533: echo "Next boot (unless replaced):\n$BOOT_KERNEL_VERSION"
534: fi
535: if [ -n "$NEW_KERNEL_VERSION" ]; then
1.54 andrew 536: echo "===> New $BOOT_KERNEL:\n$NEW_KERNEL_VERSION";
1.39 andrew 537: else
538: echo "\n!!! WARNING: Will not replace boot kernel $BOOT_KERNEL! !!!\n" >&2
539: echo "ctrl+C to cancel, enter to continue anyway" >&2
1.44 andrew 540: local _temp
541: read _temp
1.53 andrew 542: NEW_KERNEL_VERSION=$BOOT_KERNEL_VERSION
1.44 andrew 543: fi
544:
545: if [ -n "$SUDO" -a $CUR_VER != $NEW_VER ]; then
546: echo >&2
547: echo "!!! You are upgrading between OpenBSD versions. !!!" >&2
548: echo "!!! You should make sure you have a root shell open !!!" >&2
549: echo "!!! It is needed in order to run /sbin/oreboot. !!!" >&2
550: echo "!!! sudo MAY NOT WORK after sets are extracted. !!!" >&2
551: echo >&2
552: echo "ctrl+C to cancel, enter to continue" >&2
1.39 andrew 553: local _temp
554: read _temp
555: fi
1.2 andrew 556:
1.43 andrew 557: if [ -n "$SUDO" ]; then
558: echo
559: echo You may be asked for your sudo password multiple times.
560: $SUDO -v -p "sudo Password: "
1.50 andrew 561: fi
562:
1.53 andrew 563: if [ X"$NEW_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" \
1.50 andrew 564: -a ! -e /sbin/oreboot ]; then
565: $SUDO cp /sbin/reboot /sbin/oreboot
566: if [ $? -ne 0 ]; then
567: echo "Error copying old reboot command!" >&2
568: exit 1
569: fi
570: echo "/sbin/reboot copied to /sbin/oreboot"
1.2 andrew 571: fi
572:
1.30 andrew 573: install_kernels
1.21 andrew 574: install_sets
1.2 andrew 575:
1.53 andrew 576: if [ X"$NEW_KERNEL_VERSION" == X"$BOOTED_KERNEL_VERSION" ]; then
1.51 andrew 577: install_sendmail_smtp_auth
578:
1.21 andrew 579: if [ -e /sbin/oreboot ]; then
580: echo Removing /sbin/oreboot
581: $SUDO rm -f /sbin/oreboot
582: fi
1.2 andrew 583: update_etc
584:
1.54 andrew 585: echo '==> UPDATING PACKAGES'
1.2 andrew 586: $SUDO pkg_add -ui -F update -F updatedepends
587:
588: else
589: echo Instructions for updating to the new version available from
1.36 andrew 590: if [ X"snapshots" == X"$FORCE_DIR" ]; then
1.30 andrew 591: echo " http://www.openbsd.org/faq/current.html"
592: else
593: echo " http://www.openbsd.org/faq/upgrade${FILE_VER}.html"
594: fi
1.2 andrew 595: fi
596:
597: echo New kernel installed. Please reboot!
1.22 andrew 598: if [ -e /sbin/oreboot ]; then
599: echo Possibly using /sbin/oreboot
600: fi
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>