Annotation of openbsd/update_openbsd/update_openbsd, Revision 1.96
1.1 andrew 1: #!/bin/sh
1.96 ! andrew 2: # $AFresh1: update_openbsd,v 1.95 2017/12/10 21:19:11 andrew Exp $
1.94 andrew 3: #
1.41 andrew 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
1.63 andrew 21: local man=/usr/share/man/man1/intro.1
1.5 andrew 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:
1.75 andrew 30: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.5 andrew 31: local _c _d _e
32: echo -n base
1.75 andrew 33: [ $_nv -lt 57 ] && echo -n ' etc'
1.3 andrew 34: for _d in misc man comp game xbase xetc xfont xserv xshare; do
1.75 andrew 35: [ $_d = xetc -a $_nv -ge 57 ] && continue
1.3 andrew 36: eval _e=\$${_d}
37: _c=`ls $_e 2> /dev/null | wc -l`
38: #echo $_c $_d $_e
39: if [ $_c -ne 0 ]; then
1.5 andrew 40: echo -n " $_d"
1.2 andrew 41: fi
42: done
1.19 andrew 43:
1.34 andrew 44: sendmail -d0.1 --badoption </dev/null 2>/dev/null | grep -q SASL
1.94 andrew 45: if [ $? == 0 ]; then
1.19 andrew 46: echo -n ' sendmail-smtp_auth'
47: fi
1.2 andrew 48: }
1.7 andrew 49:
1.39 andrew 50: kernel_file_version() {
51: echo exit | config -e $1 | grep -A1 ^OpenBSD
52: #what $1 | sed -ne 's/[[:blank:]]\{1,\}//p'
53: }
54:
1.16 andrew 55: version_in() {
1.10 andrew 56: local _proto=${FTP%%://*}
1.16 andrew 57: local _file
1.10 andrew 58:
59: if [ X"ftp" == X"${_proto}" ]; then
1.16 andrew 60: local _list=`echo "ls base*.tgz" | ${FTP_CMD} ${FTP}/`
61: _file=`echo ${_list} | awk '/base[0-9][0-9].tgz/ { print $9 }'`
1.15 andrew 62:
1.87 andrew 63: elif [ X"http" == X"${_proto}" -o X"https" == X"${_proto}" ]; then
1.96 ! andrew 64: _file=`${FTP_CMD} -V -o - ${FTP}/index.txt |
! 65: sed -ne 's/.*\(base[0-9][0-9].tgz\).*/\1/p'`
1.15 andrew 66:
67: elif [ X"scp" == X"${_proto}" ]; then
68: echo SCP is not yet supported >&2
69: return 2
70:
1.96 ! andrew 71: else
1.10 andrew 72: echo Unsupported FTP ${FTP} >&2
1.12 andrew 73: return 2
1.15 andrew 74:
1.10 andrew 75: fi
1.16 andrew 76:
77: local _v=${_file##*base}
78: _v=${_v%.tgz*}
79: echo $_v
1.10 andrew 80: }
1.2 andrew 81:
82: set_version() {
83: CUR_VER=`uname -r`
1.3 andrew 84: NEW_VER=`dc -e "$CUR_VER 0.1 + p"`
1.5 andrew 85: FILE_VER=""
86: FTP=""
1.2 andrew 87:
1.5 andrew 88: local _cv=`echo $CUR_VER | sed -e 's/\.//'`
89: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.9 andrew 90: local _v
1.5 andrew 91:
1.10 andrew 92: if [ X"No" != X"$FORCE_DIR" -a -d $FORCE_DIR ]; then
1.5 andrew 93: _dir=$FORCE_DIR
94: if [ -e ${_dir}/base${_nv}.tgz ]; then
95: _v=$_nv
96: elif [ -e ${_dir}/base${_cv}.tgz ]; then
97: NEW_VER=$CUR_VER
98: _v=$_cv
99: fi
1.2 andrew 100:
1.5 andrew 101: elif [ -d $CUR_VER ]; then
102: _dir=$CUR_VER
1.2 andrew 103: NEW_VER=$CUR_VER
1.5 andrew 104: if [ -e ${_dir}/base${_cv}.tgz ]; then
105: _v=$_cv
106: fi
1.2 andrew 107:
1.5 andrew 108: elif [ -d $NEW_VER ]; then
109: _dir=$NEW_VER
110: if [ -e ${_dir}/base${_nv}.tgz ]; then
111: _v=$_nv
112: fi
1.2 andrew 113:
114: fi
115:
1.17 andrew 116: if [ X"" != X"${MIRROR}" -a X"" == X"${_v}" ]; then
1.89 andrew 117: if [ X"No" != X"${FORCE_DIR}" ]; then
118: _dir=${FORCE_DIR}
119: elif sysctl kern.version | grep -q -- '-current '; then
120: _dir=snapshots
121: FORCE_DIR=snapshots
122: else
1.5 andrew 123: _dir=${NEW_VER}
124: fi
125: FTP=${MIRROR}/${_dir}/`machine`
1.2 andrew 126:
1.16 andrew 127: _v=`version_in`
1.10 andrew 128:
1.16 andrew 129: if [ X"" == X"${_v}" ]; then
1.10 andrew 130: if [ X"No" != X"$FORCE_DIR" ]; then
131: echo No sets in forced [${FTP}] >&2
1.12 andrew 132: return 2
1.10 andrew 133: fi
134:
135: NEW_VER=$CUR_VER
136: _dir=${NEW_VER}
137: FTP=${MIRROR}/${_dir}/`machine`
138:
1.16 andrew 139: _v=`version_in`
1.9 andrew 140: fi
141:
1.10 andrew 142: if [ X"" == X"${_v}" ]; then
1.16 andrew 143: echo No sets in [${FTP}] >&2
1.94 andrew 144: return 2
1.10 andrew 145: elif [ X"${_cv}" == X"${_v}" ]; then
1.5 andrew 146: NEW_VER=$CUR_VER
1.9 andrew 147: elif [ X"${_nv}" == X"${_v}" ]; then
148: NEW_VER=$NEW_VER
1.2 andrew 149: else
1.10 andrew 150: echo Invalid version [$_v] >&2
1.12 andrew 151: return 2
1.2 andrew 152: fi
153:
1.10 andrew 154: if [ X"No" == X"$FORCE_DIR" ]; then
1.5 andrew 155: _dir=$NEW_VER
1.2 andrew 156: fi
157:
158: fi
159:
1.5 andrew 160: if [ X"" == X"${_v}" ]; then
1.64 andrew 161: if [ X"" == X"${MIRROR}" ]; then
162: echo ERROR: No sets, and no MIRROR, unable to continue. >&2
163: else
164: echo ERROR: Unable to determine FILE_VER, check your MIRROR. >&2
165: fi
1.12 andrew 166: return 1
1.2 andrew 167: fi
168:
1.5 andrew 169: if [ X"" == X"$RELEASEDIR" ]; then
170: RELEASEDIR=`pwd`/$_dir
1.2 andrew 171: fi
1.9 andrew 172:
1.5 andrew 173: FILE_VER=$_v
1.17 andrew 174: if [ X"" != X"${MIRROR}" ]; then
175: FTP=${MIRROR}/${_dir}/`machine`
176: fi
1.39 andrew 177:
178: BOOT_KERNEL=`( \
179: echo bsd; \
180: [ -e /boot.conf ] && sed -E '/^ *(set +image|boot) +/!d ; \
181: s///; s/^.*://; s/ .*$//' /boot.conf \
182: ) | tail -1`
1.42 andrew 183: BOOT_KERNEL=`follow_symlink /$BOOT_KERNEL`
1.39 andrew 184: BOOT_KERNEL="/${BOOT_KERNEL#/}"
185:
186: BOOT_KERNEL_VERSION=`kernel_file_version $BOOT_KERNEL`
187:
188: BOOTED_KERNEL_VERSION=`sysctl -n kern.version`
189: NEW_KERNEL_VERSION=""
190:
191: # We want to default to what we had
192: INSTALL_KERNELS="${BOOT_KERNEL#/}"
1.48 andrew 193: # if the boot kernel was our specially named bsd.sp, we install from bsd
194: if [ X"$INSTALL_KERNELS" == X"bsd.sp" ]; then
195: INSTALL_KERNELS="bsd"
196: fi
1.39 andrew 197: # with a second option of an mp kernel if is is a likely candidate
198: if [ X"$INSTALL_KERNELS" != X"bsd.mp" ]; then
199: local _ncpu=$(sysctl -n hw.ncpufound)
200: [ $_ncpu -gt 1 ] && INSTALL_KERNELS="$INSTALL_KERNELS bsd.mp"
201: fi
202: # or just bsd otherwise
203: if [ X"${INSTALL_KERNELS% *}" != X"bsd" ]; then
204: INSTALL_KERNELS="$INSTALL_KERNELS bsd"
205: fi
206: BOOT_KERNELS=$INSTALL_KERNELS
207: INSTALL_KERNELS="$INSTALL_KERNELS bsd.rd"
1.2 andrew 208: }
209:
210: get_sets() {
1.54 andrew 211: echo '==> GETTING SETS'
1.2 andrew 212: if [ X"" == X"$FTP" ]; then
1.5 andrew 213: echo ERROR: No FTP site set! >&2
1.12 andrew 214: return 1
1.2 andrew 215: fi
216:
1.5 andrew 217: mkdir -p ${RELEASEDIR}
218: cd $RELEASEDIR
1.2 andrew 219:
1.5 andrew 220: local _v=$FILE_VER
1.2 andrew 221:
1.39 andrew 222: for _b in $INSTALL_KERNELS; do
1.45 andrew 223: if [ ! -e ./${_b} ]; then
1.54 andrew 224: echo "===> $FTP_CMD ${FTP}/${_b}"
1.3 andrew 225: $FTP_CMD ${FTP}/${_b}
1.70 andrew 226: else
227: echo "===> Have ${_b}"
1.2 andrew 228: fi
1.70 andrew 229: kernel_file_version "${_b}"
1.2 andrew 230: done
231:
1.5 andrew 232: for _s in $INSTALLED_SETS; do
1.71 andrew 233: [ "$_v" -ge "57" -a "$_s" != "${_s%etc}" ] && continue
1.19 andrew 234: local _file=${_s}${_v}.tgz
235: if [ ${_s} == sendmail-smtp_auth ]; then
236: _file=${_s}.gz
237: fi
238:
239: if [ ! -e ./${_file} ]; then
1.54 andrew 240: echo "===> $FTP_CMD ${FTP}/${_file}"
1.19 andrew 241: $FTP_CMD ${FTP}/${_file}
1.5 andrew 242: fi
1.2 andrew 243: done
244:
1.20 andrew 245: local _type
1.56 andrew 246: local _ftp
1.20 andrew 247: for _type in $CHECKSUM_TYPES; do
1.40 andrew 248: [ -e $_type ] && break
1.56 andrew 249: _ftp=`echo "$FTP" | sed -e 's,://[^/]*/,://ftp.openbsd.org/,'`
250: echo "===> $FTP_CMD ${_ftp}/$_type"
251: $FTP_CMD ${_ftp}/$_type
1.20 andrew 252: done
1.17 andrew 253: }
254:
1.23 andrew 255: follow_symlink () {
256: local _file=$1
1.33 andrew 257: # This could go circular, but I dunno how to fix that.
258: if [ -h $_file ]; then
1.77 andrew 259: follow_symlink $( readlink -f $_file )
1.23 andrew 260: else
1.33 andrew 261: echo $_file
1.23 andrew 262: fi
263: }
264:
1.20 andrew 265: check_sum () {
266: local _type=$1
1.54 andrew 267: echo "==> CHECKING $_type SUMS"
1.17 andrew 268: cd $RELEASEDIR
269:
1.20 andrew 270: if [ ! -e $_type ]; then
271: echo $_type File does not exist!
1.17 andrew 272: return 1
273: fi
1.6 andrew 274:
1.57 andrew 275: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.61 andrew 276: local _signify=`which signify 2>/dev/null`
1.94 andrew 277: local _keyfile=/etc/signify/openbsd-${_nv}-base.pub
1.59 andrew 278: local _b _s
1.57 andrew 279:
280: (
1.58 andrew 281: for _b in $INSTALL_KERNELS; do echo "($_b)" ; done
282: for _s in $INSTALLED_SETS; do echo "($_s$_nv.tgz)"; done
1.57 andrew 283: ) > index
1.94 andrew 284:
1.59 andrew 285:
286: if [ -n "$_signify" -a "$_type" != "${_type%.sig}" ]; then
287: echo "===> Checking signature";
288: if [ ! -e $_keyfile ]; then
289: echo "key [$_keyfile] does not exist, cannot check $_type" >&2
290: return 2
291: fi
1.67 andrew 292: signify -V -e -p $_keyfile -x $_type -m - | grep -f index | sha256 -c -
1.59 andrew 293: else
1.73 andrew 294: grep -f index $_type | sha256 -c
1.59 andrew 295: fi
1.2 andrew 296:
297: if [ $? -ne 0 ]; then
1.20 andrew 298: echo ERROR: $_type does not match! >&2
1.12 andrew 299: return 1
1.2 andrew 300: fi
301: }
302:
1.17 andrew 303: check_sets() {
1.54 andrew 304: echo '==> CHECKING SETS'
1.17 andrew 305: cd $RELEASEDIR
306:
1.18 andrew 307: local _missing_sets
1.17 andrew 308: local _v=$FILE_VER
309:
1.39 andrew 310: for _n in $INSTALL_KERNELS; do
311: local _o=$_n
312: [ X"bsd" == X"${_o}" -a -e /bsd.sp ] && _o=bsd.sp
313: if [ -e /${_o} -a ! -e ./${_n} ]; then
314: echo ${_o} does not exist
315: _missing_sets=1
1.17 andrew 316: fi
1.39 andrew 317:
318: if [ X"${BOOT_KERNEL}" == X"/${_o}" -a -e ./${_n} ]; then
319: NEW_KERNEL_VERSION=`kernel_file_version ./${_n}`
1.17 andrew 320: fi
321: done
322:
1.39 andrew 323: if [ X"$NEW_KERNEL_VERSION" == X"" ]; then
324: echo Missing replacement for boot kernel $BOOT_KERNEL >&2
325: _missing_sets=1
326: fi
327:
1.17 andrew 328: for _s in $INSTALLED_SETS; do
1.71 andrew 329: [ "$_v" -ge "57" -a "$_s" != "${_s%etc}" ] && continue
1.19 andrew 330: local _file=${_s}${_v}.tgz
331: if [ ${_s} == sendmail-smtp_auth ]; then
332: _file=${_s}.gz
333: fi
334: if [ ! -e ./${_file} ]; then
335: echo ${_file} does not exist
1.18 andrew 336: _missing_sets=1
1.17 andrew 337: fi
338: done
1.18 andrew 339:
340: if [ X"" == X"${_missing_sets}" ]; then
1.85 andrew 341: echo 'All OK'
1.18 andrew 342: fi
1.17 andrew 343:
1.20 andrew 344: local _type
345: for _type in $CHECKSUM_TYPES; do
1.74 andrew 346: [ -n "$NO_SIGNIFY" -a "$_type" != "${_type%.sig}" ] && continue
1.20 andrew 347: if [ -e $_type ]; then
1.59 andrew 348: check_sum $_type && break
1.62 andrew 349: [ -z "$IGNORE_CHECKSUM_ERROR" ] && exit 1
1.20 andrew 350: fi
351: done
1.59 andrew 352:
353: return 0
1.17 andrew 354: }
355:
356:
1.30 andrew 357: install_kernels() {
1.54 andrew 358: echo '==> INSTALLING KERNEL'
1.2 andrew 359:
360: if [ X"" == X"$RELEASEDIR" ]; then
1.5 andrew 361: echo ERROR: no source for new kernels! >&2
1.2 andrew 362: exit 1
363: fi
364:
1.46 andrew 365: if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
1.54 andrew 366: echo "===> Backing up $BOOT_KERNEL to /obsd"
1.65 andrew 367: ln -f $BOOT_KERNEL /obsd
1.46 andrew 368: if [ $? -ne 0 ]; then
369: echo "Error copying old kernel!" >&2
370: exit 1
371: fi
1.2 andrew 372: fi
373:
1.39 andrew 374: cd $RELEASEDIR
1.23 andrew 375:
1.39 andrew 376: for _b in $INSTALL_KERNELS; do
1.65 andrew 377: rm -f /nbsd
1.39 andrew 378: local _bd=$_b
379: [ X"${_b}" == X"bsd" ] && _bd="bsd.sp"
1.2 andrew 380:
1.39 andrew 381: local _is_boot=""
382: [ X"$BOOT_KERNEL" == X"/${_bd}" ] && _is_boot="# boot kernel"
1.94 andrew 383:
1.85 andrew 384: echo "Copying $_b to /$_bd $_is_boot"
1.65 andrew 385: cp ${_b} /nbsd && mv /nbsd /${_bd}
1.2 andrew 386: if [ $? -ne 0 ]; then
1.39 andrew 387: echo ERROR: Could not copy new $_bd kernel! >&2
1.2 andrew 388: exit 1
389: fi
1.39 andrew 390: done
391:
392: cd $OLDPWD
1.23 andrew 393:
1.39 andrew 394: if [ ! -h /bsd ]; then
395: cd /
396: for _b in $BOOT_KERNELS; do
397: [ X"$_b" == X"bsd" ] && _b="bsd.sp"
398: if [ -e $_b ]; then
1.54 andrew 399: echo "===> symlinking $_b to /bsd"
1.65 andrew 400: ln -sf $_b bsd
1.39 andrew 401: if [ $? -ne 0 ]; then
402: echo ERROR: Could not symlink new kernel! >&2
403: exit 1
404: fi
405: break
406: fi
407: done
408: cd $OLDPWD
1.2 andrew 409: fi
410: }
411:
412: install_sets() {
1.54 andrew 413: echo '==> INSTALLING SETS'
1.2 andrew 414:
415: if [ X"" == X"$RELEASEDIR" ]; then
1.5 andrew 416: echo ERROR: no source for sets! >&2
1.2 andrew 417: exit 1
418: else
419: cd $RELEASEDIR
420: fi
421:
1.5 andrew 422: local _v=$FILE_VER
423:
1.21 andrew 424: local _sets=`ls *${_v}.tgz | grep -v ^base `
425: for _f in ${_sets} base${_v}.tgz; do
1.3 andrew 426: _path=$DESTDIR
427: if [ X"etc${_v}.tgz" == X"$_f" \
428: -o X"xetc${_v}.tgz" == X"$_f" ]; then
1.21 andrew 429: [ X"" != X"$SYSMERGE" ] && continue
1.2 andrew 430: _path=/var/tmp/temproot
431: fi
432:
1.85 andrew 433: echo "Extracting $_f to $_path"
1.65 andrew 434: mkdir -p $_path
435: tar -C $_path -xzphf ${RELEASEDIR}/${_f}
1.2 andrew 436: if [ $? -ne 0 ]; then
1.5 andrew 437: echo ERROR: Could not extract ${_f}! >&2
1.2 andrew 438: exit 1
439: fi
440: done
441:
1.54 andrew 442: echo '===> Extracted all sets.'
1.51 andrew 443: }
1.19 andrew 444:
1.51 andrew 445: install_sendmail_smtp_auth() {
1.19 andrew 446: if [ -e ${RELEASEDIR}/sendmail-smtp_auth.gz ]; then
447: gzcat ${RELEASEDIR}/sendmail-smtp_auth.gz > \
448: ${RELEASEDIR}/sendmail-smtp_auth
449: fi
450: if [ -e ${RELEASEDIR}/sendmail-smtp_auth ]; then
1.21 andrew 451: if ! pkg_info -qe 'cyrus-sasl-*'; then
1.65 andrew 452: pkg_add -i cyrus-sasl
1.21 andrew 453: fi
454:
1.65 andrew 455: install -o root -g smmsp -m 2555 \
1.19 andrew 456: ${RELEASEDIR}/sendmail-smtp_auth \
1.21 andrew 457: /usr/libexec/sendmail/sendmail
1.19 andrew 458:
1.54 andrew 459: echo '===> Installed sendmail with smtp_auth'
1.19 andrew 460: fi
1.2 andrew 461: }
462:
463: update_etc() {
1.54 andrew 464: echo '==> UPDATING ETC'
1.10 andrew 465: if [ ! -e $SYSMERGE ]; then
1.47 andrew 466: echo "ERROR: Can't find sysmerge!" >&2
467: exit 1;
1.10 andrew 468: fi
469:
1.68 andrew 470: local _v=$FILE_VER
471: local _args=""
472:
1.80 andrew 473: if [ ! -e /var/sysmerge/etc.tgz ]; then
1.68 andrew 474: if [ X"" == X"$RELEASEDIR" ]; then
475: echo "ERROR: no source for etc!" >&2
476: exit 1
477: fi
1.2 andrew 478:
1.68 andrew 479: cd $RELEASEDIR
1.5 andrew 480:
1.68 andrew 481: if [ -e etc${_v}.tgz ]; then
482: _args="$_args -s ${RELEASEDIR}/etc${_v}.tgz"
483: fi
484: if [ -e xetc${_v}.tgz ]; then
485: _args="$_args -x ${RELEASEDIR}/xetc${_v}.tgz"
486: fi
1.94 andrew 487: if [ X"" == X"$_args" ]; then
1.68 andrew 488: echo ERROR: No upgrade sets found! >&2
489: exit 1
490: fi
1.47 andrew 491: fi
1.68 andrew 492:
493: echo '==> RUNNING SYSMERGE'
494: $SYSMERGE $_args
1.2 andrew 495:
1.47 andrew 496: cd $OLDPWD
1.2 andrew 497: }
1.14 andrew 498:
1.20 andrew 499:
1.65 andrew 500: if [ $(id -u) != 0 ]; then
501: echo 'ERROR: need root privileges to run this script' >&2
502: exit 1
503: fi
504:
1.14 andrew 505: if [ -e /etc/update_openbsd.conf ]; then
506: . /etc/update_openbsd.conf
507: fi
508:
509: if [ -e ${HOME}/.update_openbsdrc ]; then
510: . ${HOME}/.update_openbsdrc
511: fi
512:
1.90 andrew 513: MIRROR=${MIRROR:=http://fastly.cdn.openbsd.org/pub/OpenBSD}
1.14 andrew 514: FTP_CMD=${FTP_CMD:=ftp -V}
515:
516: DESTDIR=${DESTDIR:=/}
517: SYSMERGE=${SYSMERGE:=/usr/sbin/sysmerge}
518: FORCE_DIR=${FORCE_DIR:=No}
1.79 andrew 519:
1.84 andrew 520: export PKG_PATH TRUSTED_PKG_PATH
521:
1.79 andrew 522: set_version
1.91 andrew 523:
1.95 andrew 524: TRUSTED_PKG_PATH=${TRUSTED_PKG_PATH:=/usr/ports/packages/`machine -a`/all}
525: if [ "$FORCE_DIR" = "No" ]; then
526: PKG_PATH=${PKG_PATH:=${MIRROR}/$NEW_VER/packages/`machine -a`}
527: else
528: PKG_PATH=${PKG_PATH:=${MIRROR}/$FORCE_DIR/packages/`machine -a`}
529: fi
1.14 andrew 530:
531: INSTALLED_SETS=${INSTALLED_SETS:=`installed_sets`}
1.2 andrew 532:
1.59 andrew 533: CHECKSUM_TYPES=${CHECKSUM_TYPES:=SHA256.sig SHA256}
1.20 andrew 534:
1.12 andrew 535: local _error=$?
1.2 andrew 536:
537: echo
538: echo "-= update_openbsd - helper script to update OpenBSD =-"
539: echo "------------------------------------------------------"
540: echo
1.84 andrew 541: echo " SYSMERGE: $SYSMERGE"
1.88 andrew 542: echo " MIRROR: $FTP"
1.84 andrew 543: echo " PKG_PATH: $PKG_PATH"
544: echo "TRUSTED_PKG_PATH: $TRUSTED_PKG_PATH"
545: echo " RELEASEDIR: $RELEASEDIR"
546: echo " DESTDIR: $DESTDIR"
547: echo " BOOT_KERNEL: $BOOT_KERNEL"
548: echo " INSTALL_KERNELS: $INSTALL_KERNELS"
549: echo " INSTALLED_SETS: $INSTALLED_SETS"
1.8 andrew 550: echo
1.84 andrew 551: echo " CUR_VER: $CUR_VER"
552: echo " NEW_VER: $NEW_VER"
553: #echo " FILE_VER: $FILE_VER"
1.2 andrew 554: echo
1.70 andrew 555:
556: for k in $INSTALL_KERNELS; do
557: if [ -e "/$k" ]; then
558: echo "Existing $k"
559: kernel_file_version "/$k"
560: fi
561: done
1.12 andrew 562:
563: if [ ${_error} -ne 0 ]; then
564: exit ${_error}
565: fi
1.2 andrew 566:
1.17 andrew 567: if [ X"" != X"${FTP}" ]; then
1.20 andrew 568: get_sets
1.17 andrew 569: fi
570:
571: check_sets || exit
1.39 andrew 572:
1.54 andrew 573: echo "===> Last booted:\n$BOOTED_KERNEL_VERSION"
1.39 andrew 574: if [ X"$BOOT_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" \
575: -a X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
576: echo "Next boot (unless replaced):\n$BOOT_KERNEL_VERSION"
577: fi
578: if [ -n "$NEW_KERNEL_VERSION" ]; then
1.54 andrew 579: echo "===> New $BOOT_KERNEL:\n$NEW_KERNEL_VERSION";
1.39 andrew 580: else
581: echo "\n!!! WARNING: Will not replace boot kernel $BOOT_KERNEL! !!!\n" >&2
582: echo "ctrl+C to cancel, enter to continue anyway" >&2
1.44 andrew 583: local _temp
584: read _temp
1.53 andrew 585: NEW_KERNEL_VERSION=$BOOT_KERNEL_VERSION
1.44 andrew 586: fi
587:
1.66 andrew 588: if [ X"$NEW_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" ]; then
1.44 andrew 589: echo >&2
1.66 andrew 590: echo "!!! You are upgrading the OpenBSD kernel. !!!" >&2
591: echo "!!! You will be given the opportunity to reboot !!!" >&2
1.94 andrew 592: echo "!!! at the end of the proces but it is safer to !!!" >&2
1.66 andrew 593: echo "!!! have a separate root shell open. !!!" >&2
594: echo "!!! It is needed in order to run /sbin/oreboot. !!!" >&2
1.78 andrew 595: echo "!!! doas MAY NOT WORK after sets are extracted. !!!" >&2
1.44 andrew 596: echo >&2
1.66 andrew 597: echo "enter to continue, ctrl+C to cancel" >&2
1.39 andrew 598: local _temp
599: read _temp
1.2 andrew 600:
1.66 andrew 601: if [ ! -e /sbin/oreboot ]; then
602: cp /sbin/reboot /sbin/oreboot
603: if [ $? -ne 0 ]; then
604: echo "Error copying old reboot command!" >&2
605: exit 1
606: fi
607: echo "/sbin/reboot copied to /sbin/oreboot"
1.50 andrew 608: fi
1.2 andrew 609: fi
610:
1.30 andrew 611: install_kernels
1.21 andrew 612: install_sets
1.2 andrew 613:
1.53 andrew 614: if [ X"$NEW_KERNEL_VERSION" == X"$BOOTED_KERNEL_VERSION" ]; then
1.51 andrew 615: install_sendmail_smtp_auth
616:
1.21 andrew 617: if [ -e /sbin/oreboot ]; then
618: echo Removing /sbin/oreboot
1.69 andrew 619: rm -f /sbin/oreboot
1.21 andrew 620: fi
1.2 andrew 621: update_etc
622:
1.81 andrew 623: OPENUP=$( which openup 2>/dev/null )
1.76 andrew 624: if [ -n "$OPENUP" ]; then
625: echo "==> UPDATING WITH $OPENUP"
626: $OPENUP
627: else
628: echo '==> UPDATING PACKAGES'
1.86 andrew 629: pkg_add -u
1.76 andrew 630: fi
1.72 andrew 631:
632: echo '==> UPDATING FIRMWARE'
633: fw_update
1.2 andrew 634:
635: else
1.83 andrew 636: [ -e /etc/rc.sysmerge ] && grep -q $SYSMERGE /etc/rc.sysmerge ||
1.82 andrew 637: echo "$SYSMERGE -b" >>/etc/rc.sysmerge &&
638: echo "==> RUNNING $SYSMERGE -b ON REBOOT"
639:
1.94 andrew 640: echo Instructions for updating to the new version available from
1.36 andrew 641: if [ X"snapshots" == X"$FORCE_DIR" ]; then
1.30 andrew 642: echo " http://www.openbsd.org/faq/current.html"
643: else
644: echo " http://www.openbsd.org/faq/upgrade${FILE_VER}.html"
645: fi
1.2 andrew 646: fi
647:
1.66 andrew 648: echo Update complete. enter to reboot, ctrl+C to cancel
1.65 andrew 649: read _temp
1.22 andrew 650: if [ -e /sbin/oreboot ]; then
1.66 andrew 651: echo using /sbin/oreboot
1.65 andrew 652: /sbin/oreboot
653: else
654: /sbin/reboot
1.22 andrew 655: fi
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>