Annotation of openbsd/update_openbsd/update_openbsd, Revision 1.94
1.1 andrew 1: #!/bin/sh
1.94 ! andrew 2: # $AFresh1: update_openbsd,v 1.93 2017/11/28 03:54:31 andrew Exp $
! 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.16 andrew 64: local _list=`${FTP_CMD} -V -o - ${FTP}/`
65: _file=`echo ${_list} | awk '/[^x]base[0-9][0-9]*\.tgz/ {
1.15 andrew 66: sub("^.*base","base");
67: sub("\.tgz.*",".tgz");
68: print $0;
1.16 andrew 69: }'`
1.15 andrew 70:
71: elif [ X"scp" == X"${_proto}" ]; then
72: echo SCP is not yet supported >&2
73: return 2
74:
1.10 andrew 75: else
76: echo Unsupported FTP ${FTP} >&2
1.12 andrew 77: return 2
1.15 andrew 78:
1.10 andrew 79: fi
1.16 andrew 80:
81: local _v=${_file##*base}
82: _v=${_v%.tgz*}
83: echo $_v
1.10 andrew 84: }
1.2 andrew 85:
86: set_version() {
87: CUR_VER=`uname -r`
1.3 andrew 88: NEW_VER=`dc -e "$CUR_VER 0.1 + p"`
1.5 andrew 89: FILE_VER=""
90: FTP=""
1.2 andrew 91:
1.5 andrew 92: local _cv=`echo $CUR_VER | sed -e 's/\.//'`
93: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.9 andrew 94: local _v
1.5 andrew 95:
1.10 andrew 96: if [ X"No" != X"$FORCE_DIR" -a -d $FORCE_DIR ]; then
1.5 andrew 97: _dir=$FORCE_DIR
98: if [ -e ${_dir}/base${_nv}.tgz ]; then
99: _v=$_nv
100: elif [ -e ${_dir}/base${_cv}.tgz ]; then
101: NEW_VER=$CUR_VER
102: _v=$_cv
103: fi
1.2 andrew 104:
1.5 andrew 105: elif [ -d $CUR_VER ]; then
106: _dir=$CUR_VER
1.2 andrew 107: NEW_VER=$CUR_VER
1.5 andrew 108: if [ -e ${_dir}/base${_cv}.tgz ]; then
109: _v=$_cv
110: fi
1.2 andrew 111:
1.5 andrew 112: elif [ -d $NEW_VER ]; then
113: _dir=$NEW_VER
114: if [ -e ${_dir}/base${_nv}.tgz ]; then
115: _v=$_nv
116: fi
1.2 andrew 117:
118: fi
119:
1.17 andrew 120: if [ X"" != X"${MIRROR}" -a X"" == X"${_v}" ]; then
1.89 andrew 121: if [ X"No" != X"${FORCE_DIR}" ]; then
122: _dir=${FORCE_DIR}
123: elif sysctl kern.version | grep -q -- '-current '; then
124: _dir=snapshots
125: FORCE_DIR=snapshots
126: else
1.5 andrew 127: _dir=${NEW_VER}
128: fi
129: FTP=${MIRROR}/${_dir}/`machine`
1.2 andrew 130:
1.16 andrew 131: _v=`version_in`
1.10 andrew 132:
1.16 andrew 133: if [ X"" == X"${_v}" ]; then
1.10 andrew 134: if [ X"No" != X"$FORCE_DIR" ]; then
135: echo No sets in forced [${FTP}] >&2
1.12 andrew 136: return 2
1.10 andrew 137: fi
138:
139: NEW_VER=$CUR_VER
140: _dir=${NEW_VER}
141: FTP=${MIRROR}/${_dir}/`machine`
142:
1.16 andrew 143: _v=`version_in`
1.9 andrew 144: fi
145:
1.10 andrew 146: if [ X"" == X"${_v}" ]; then
1.16 andrew 147: echo No sets in [${FTP}] >&2
1.94 ! andrew 148: return 2
1.10 andrew 149: elif [ X"${_cv}" == X"${_v}" ]; then
1.5 andrew 150: NEW_VER=$CUR_VER
1.9 andrew 151: elif [ X"${_nv}" == X"${_v}" ]; then
152: NEW_VER=$NEW_VER
1.2 andrew 153: else
1.10 andrew 154: echo Invalid version [$_v] >&2
1.12 andrew 155: return 2
1.2 andrew 156: fi
157:
1.10 andrew 158: if [ X"No" == X"$FORCE_DIR" ]; then
1.5 andrew 159: _dir=$NEW_VER
1.2 andrew 160: fi
161:
162: fi
163:
1.5 andrew 164: if [ X"" == X"${_v}" ]; then
1.64 andrew 165: if [ X"" == X"${MIRROR}" ]; then
166: echo ERROR: No sets, and no MIRROR, unable to continue. >&2
167: else
168: echo ERROR: Unable to determine FILE_VER, check your MIRROR. >&2
169: fi
1.12 andrew 170: return 1
1.2 andrew 171: fi
172:
1.5 andrew 173: if [ X"" == X"$RELEASEDIR" ]; then
174: RELEASEDIR=`pwd`/$_dir
1.2 andrew 175: fi
1.9 andrew 176:
1.5 andrew 177: FILE_VER=$_v
1.17 andrew 178: if [ X"" != X"${MIRROR}" ]; then
179: FTP=${MIRROR}/${_dir}/`machine`
180: fi
1.39 andrew 181:
182: BOOT_KERNEL=`( \
183: echo bsd; \
184: [ -e /boot.conf ] && sed -E '/^ *(set +image|boot) +/!d ; \
185: s///; s/^.*://; s/ .*$//' /boot.conf \
186: ) | tail -1`
1.42 andrew 187: BOOT_KERNEL=`follow_symlink /$BOOT_KERNEL`
1.39 andrew 188: BOOT_KERNEL="/${BOOT_KERNEL#/}"
189:
190: BOOT_KERNEL_VERSION=`kernel_file_version $BOOT_KERNEL`
191:
192: BOOTED_KERNEL_VERSION=`sysctl -n kern.version`
193: NEW_KERNEL_VERSION=""
194:
195: # We want to default to what we had
196: INSTALL_KERNELS="${BOOT_KERNEL#/}"
1.48 andrew 197: # if the boot kernel was our specially named bsd.sp, we install from bsd
198: if [ X"$INSTALL_KERNELS" == X"bsd.sp" ]; then
199: INSTALL_KERNELS="bsd"
200: fi
1.39 andrew 201: # with a second option of an mp kernel if is is a likely candidate
202: if [ X"$INSTALL_KERNELS" != X"bsd.mp" ]; then
203: local _ncpu=$(sysctl -n hw.ncpufound)
204: [ $_ncpu -gt 1 ] && INSTALL_KERNELS="$INSTALL_KERNELS bsd.mp"
205: fi
206: # or just bsd otherwise
207: if [ X"${INSTALL_KERNELS% *}" != X"bsd" ]; then
208: INSTALL_KERNELS="$INSTALL_KERNELS bsd"
209: fi
210: BOOT_KERNELS=$INSTALL_KERNELS
211: INSTALL_KERNELS="$INSTALL_KERNELS bsd.rd"
1.2 andrew 212: }
213:
214: get_sets() {
1.54 andrew 215: echo '==> GETTING SETS'
1.2 andrew 216: if [ X"" == X"$FTP" ]; then
1.5 andrew 217: echo ERROR: No FTP site set! >&2
1.12 andrew 218: return 1
1.2 andrew 219: fi
220:
1.5 andrew 221: mkdir -p ${RELEASEDIR}
222: cd $RELEASEDIR
1.2 andrew 223:
1.5 andrew 224: local _v=$FILE_VER
1.2 andrew 225:
1.39 andrew 226: for _b in $INSTALL_KERNELS; do
1.45 andrew 227: if [ ! -e ./${_b} ]; then
1.54 andrew 228: echo "===> $FTP_CMD ${FTP}/${_b}"
1.3 andrew 229: $FTP_CMD ${FTP}/${_b}
1.70 andrew 230: else
231: echo "===> Have ${_b}"
1.2 andrew 232: fi
1.70 andrew 233: kernel_file_version "${_b}"
1.2 andrew 234: done
235:
1.5 andrew 236: for _s in $INSTALLED_SETS; do
1.71 andrew 237: [ "$_v" -ge "57" -a "$_s" != "${_s%etc}" ] && continue
1.19 andrew 238: local _file=${_s}${_v}.tgz
239: if [ ${_s} == sendmail-smtp_auth ]; then
240: _file=${_s}.gz
241: fi
242:
243: if [ ! -e ./${_file} ]; then
1.54 andrew 244: echo "===> $FTP_CMD ${FTP}/${_file}"
1.19 andrew 245: $FTP_CMD ${FTP}/${_file}
1.5 andrew 246: fi
1.2 andrew 247: done
248:
1.20 andrew 249: local _type
1.56 andrew 250: local _ftp
1.20 andrew 251: for _type in $CHECKSUM_TYPES; do
1.40 andrew 252: [ -e $_type ] && break
1.56 andrew 253: _ftp=`echo "$FTP" | sed -e 's,://[^/]*/,://ftp.openbsd.org/,'`
254: echo "===> $FTP_CMD ${_ftp}/$_type"
255: $FTP_CMD ${_ftp}/$_type
1.20 andrew 256: done
1.17 andrew 257: }
258:
1.23 andrew 259: follow_symlink () {
260: local _file=$1
1.33 andrew 261: # This could go circular, but I dunno how to fix that.
262: if [ -h $_file ]; then
1.77 andrew 263: follow_symlink $( readlink -f $_file )
1.23 andrew 264: else
1.33 andrew 265: echo $_file
1.23 andrew 266: fi
267: }
268:
1.20 andrew 269: check_sum () {
270: local _type=$1
1.54 andrew 271: echo "==> CHECKING $_type SUMS"
1.17 andrew 272: cd $RELEASEDIR
273:
1.20 andrew 274: if [ ! -e $_type ]; then
275: echo $_type File does not exist!
1.17 andrew 276: return 1
277: fi
1.6 andrew 278:
1.57 andrew 279: local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.61 andrew 280: local _signify=`which signify 2>/dev/null`
1.94 ! andrew 281: local _keyfile=/etc/signify/openbsd-${_nv}-base.pub
1.59 andrew 282: local _b _s
1.57 andrew 283:
284: (
1.58 andrew 285: for _b in $INSTALL_KERNELS; do echo "($_b)" ; done
286: for _s in $INSTALLED_SETS; do echo "($_s$_nv.tgz)"; done
1.57 andrew 287: ) > index
1.94 ! andrew 288:
1.59 andrew 289:
290: if [ -n "$_signify" -a "$_type" != "${_type%.sig}" ]; then
291: echo "===> Checking signature";
292: if [ ! -e $_keyfile ]; then
293: echo "key [$_keyfile] does not exist, cannot check $_type" >&2
294: return 2
295: fi
1.67 andrew 296: signify -V -e -p $_keyfile -x $_type -m - | grep -f index | sha256 -c -
1.59 andrew 297: else
1.73 andrew 298: grep -f index $_type | sha256 -c
1.59 andrew 299: fi
1.2 andrew 300:
301: if [ $? -ne 0 ]; then
1.20 andrew 302: echo ERROR: $_type does not match! >&2
1.12 andrew 303: return 1
1.2 andrew 304: fi
305: }
306:
1.17 andrew 307: check_sets() {
1.54 andrew 308: echo '==> CHECKING SETS'
1.17 andrew 309: cd $RELEASEDIR
310:
1.18 andrew 311: local _missing_sets
1.17 andrew 312: local _v=$FILE_VER
313:
1.39 andrew 314: for _n in $INSTALL_KERNELS; do
315: local _o=$_n
316: [ X"bsd" == X"${_o}" -a -e /bsd.sp ] && _o=bsd.sp
317: if [ -e /${_o} -a ! -e ./${_n} ]; then
318: echo ${_o} does not exist
319: _missing_sets=1
1.17 andrew 320: fi
1.39 andrew 321:
322: if [ X"${BOOT_KERNEL}" == X"/${_o}" -a -e ./${_n} ]; then
323: NEW_KERNEL_VERSION=`kernel_file_version ./${_n}`
1.17 andrew 324: fi
325: done
326:
1.39 andrew 327: if [ X"$NEW_KERNEL_VERSION" == X"" ]; then
328: echo Missing replacement for boot kernel $BOOT_KERNEL >&2
329: _missing_sets=1
330: fi
331:
1.17 andrew 332: for _s in $INSTALLED_SETS; do
1.71 andrew 333: [ "$_v" -ge "57" -a "$_s" != "${_s%etc}" ] && continue
1.19 andrew 334: local _file=${_s}${_v}.tgz
335: if [ ${_s} == sendmail-smtp_auth ]; then
336: _file=${_s}.gz
337: fi
338: if [ ! -e ./${_file} ]; then
339: echo ${_file} does not exist
1.18 andrew 340: _missing_sets=1
1.17 andrew 341: fi
342: done
1.18 andrew 343:
344: if [ X"" == X"${_missing_sets}" ]; then
1.85 andrew 345: echo 'All OK'
1.18 andrew 346: fi
1.17 andrew 347:
1.20 andrew 348: local _type
349: for _type in $CHECKSUM_TYPES; do
1.74 andrew 350: [ -n "$NO_SIGNIFY" -a "$_type" != "${_type%.sig}" ] && continue
1.20 andrew 351: if [ -e $_type ]; then
1.59 andrew 352: check_sum $_type && break
1.62 andrew 353: [ -z "$IGNORE_CHECKSUM_ERROR" ] && exit 1
1.20 andrew 354: fi
355: done
1.59 andrew 356:
357: return 0
1.17 andrew 358: }
359:
360:
1.30 andrew 361: install_kernels() {
1.54 andrew 362: echo '==> INSTALLING KERNEL'
1.2 andrew 363:
364: if [ X"" == X"$RELEASEDIR" ]; then
1.5 andrew 365: echo ERROR: no source for new kernels! >&2
1.2 andrew 366: exit 1
367: fi
368:
1.46 andrew 369: if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
1.54 andrew 370: echo "===> Backing up $BOOT_KERNEL to /obsd"
1.65 andrew 371: ln -f $BOOT_KERNEL /obsd
1.46 andrew 372: if [ $? -ne 0 ]; then
373: echo "Error copying old kernel!" >&2
374: exit 1
375: fi
1.2 andrew 376: fi
377:
1.39 andrew 378: cd $RELEASEDIR
1.23 andrew 379:
1.39 andrew 380: for _b in $INSTALL_KERNELS; do
1.65 andrew 381: rm -f /nbsd
1.39 andrew 382: local _bd=$_b
383: [ X"${_b}" == X"bsd" ] && _bd="bsd.sp"
1.2 andrew 384:
1.39 andrew 385: local _is_boot=""
386: [ X"$BOOT_KERNEL" == X"/${_bd}" ] && _is_boot="# boot kernel"
1.94 ! andrew 387:
1.85 andrew 388: echo "Copying $_b to /$_bd $_is_boot"
1.65 andrew 389: cp ${_b} /nbsd && mv /nbsd /${_bd}
1.2 andrew 390: if [ $? -ne 0 ]; then
1.39 andrew 391: echo ERROR: Could not copy new $_bd kernel! >&2
1.2 andrew 392: exit 1
393: fi
1.39 andrew 394: done
395:
396: cd $OLDPWD
1.23 andrew 397:
1.39 andrew 398: if [ ! -h /bsd ]; then
399: cd /
400: for _b in $BOOT_KERNELS; do
401: [ X"$_b" == X"bsd" ] && _b="bsd.sp"
402: if [ -e $_b ]; then
1.54 andrew 403: echo "===> symlinking $_b to /bsd"
1.65 andrew 404: ln -sf $_b bsd
1.39 andrew 405: if [ $? -ne 0 ]; then
406: echo ERROR: Could not symlink new kernel! >&2
407: exit 1
408: fi
409: break
410: fi
411: done
412: cd $OLDPWD
1.2 andrew 413: fi
414: }
415:
416: install_sets() {
1.54 andrew 417: echo '==> INSTALLING SETS'
1.2 andrew 418:
419: if [ X"" == X"$RELEASEDIR" ]; then
1.5 andrew 420: echo ERROR: no source for sets! >&2
1.2 andrew 421: exit 1
422: else
423: cd $RELEASEDIR
424: fi
425:
1.5 andrew 426: local _v=$FILE_VER
427:
1.21 andrew 428: local _sets=`ls *${_v}.tgz | grep -v ^base `
429: for _f in ${_sets} base${_v}.tgz; do
1.3 andrew 430: _path=$DESTDIR
431: if [ X"etc${_v}.tgz" == X"$_f" \
432: -o X"xetc${_v}.tgz" == X"$_f" ]; then
1.21 andrew 433: [ X"" != X"$SYSMERGE" ] && continue
1.2 andrew 434: _path=/var/tmp/temproot
435: fi
436:
1.85 andrew 437: echo "Extracting $_f to $_path"
1.65 andrew 438: mkdir -p $_path
439: tar -C $_path -xzphf ${RELEASEDIR}/${_f}
1.2 andrew 440: if [ $? -ne 0 ]; then
1.5 andrew 441: echo ERROR: Could not extract ${_f}! >&2
1.2 andrew 442: exit 1
443: fi
444: done
445:
1.54 andrew 446: echo '===> Extracted all sets.'
1.51 andrew 447: }
1.19 andrew 448:
1.51 andrew 449: install_sendmail_smtp_auth() {
1.19 andrew 450: if [ -e ${RELEASEDIR}/sendmail-smtp_auth.gz ]; then
451: gzcat ${RELEASEDIR}/sendmail-smtp_auth.gz > \
452: ${RELEASEDIR}/sendmail-smtp_auth
453: fi
454: if [ -e ${RELEASEDIR}/sendmail-smtp_auth ]; then
1.21 andrew 455: if ! pkg_info -qe 'cyrus-sasl-*'; then
1.65 andrew 456: pkg_add -i cyrus-sasl
1.21 andrew 457: fi
458:
1.65 andrew 459: install -o root -g smmsp -m 2555 \
1.19 andrew 460: ${RELEASEDIR}/sendmail-smtp_auth \
1.21 andrew 461: /usr/libexec/sendmail/sendmail
1.19 andrew 462:
1.54 andrew 463: echo '===> Installed sendmail with smtp_auth'
1.19 andrew 464: fi
1.2 andrew 465: }
466:
467: update_etc() {
1.54 andrew 468: echo '==> UPDATING ETC'
1.10 andrew 469: if [ ! -e $SYSMERGE ]; then
1.47 andrew 470: echo "ERROR: Can't find sysmerge!" >&2
471: exit 1;
1.10 andrew 472: fi
473:
1.68 andrew 474: local _v=$FILE_VER
475: local _args=""
476:
1.80 andrew 477: if [ ! -e /var/sysmerge/etc.tgz ]; then
1.68 andrew 478: if [ X"" == X"$RELEASEDIR" ]; then
479: echo "ERROR: no source for etc!" >&2
480: exit 1
481: fi
1.2 andrew 482:
1.68 andrew 483: cd $RELEASEDIR
1.5 andrew 484:
1.68 andrew 485: if [ -e etc${_v}.tgz ]; then
486: _args="$_args -s ${RELEASEDIR}/etc${_v}.tgz"
487: fi
488: if [ -e xetc${_v}.tgz ]; then
489: _args="$_args -x ${RELEASEDIR}/xetc${_v}.tgz"
490: fi
1.94 ! andrew 491: if [ X"" == X"$_args" ]; then
1.68 andrew 492: echo ERROR: No upgrade sets found! >&2
493: exit 1
494: fi
1.47 andrew 495: fi
1.68 andrew 496:
497: echo '==> RUNNING SYSMERGE'
498: $SYSMERGE $_args
1.2 andrew 499:
1.47 andrew 500: cd $OLDPWD
1.2 andrew 501: }
1.14 andrew 502:
1.20 andrew 503:
1.65 andrew 504: if [ $(id -u) != 0 ]; then
505: echo 'ERROR: need root privileges to run this script' >&2
506: exit 1
507: fi
508:
1.14 andrew 509: if [ -e /etc/update_openbsd.conf ]; then
510: . /etc/update_openbsd.conf
511: fi
512:
513: if [ -e ${HOME}/.update_openbsdrc ]; then
514: . ${HOME}/.update_openbsdrc
515: fi
516:
1.90 andrew 517: MIRROR=${MIRROR:=http://fastly.cdn.openbsd.org/pub/OpenBSD}
1.14 andrew 518: FTP_CMD=${FTP_CMD:=ftp -V}
519:
520: DESTDIR=${DESTDIR:=/}
521: SYSMERGE=${SYSMERGE:=/usr/sbin/sysmerge}
522: FORCE_DIR=${FORCE_DIR:=No}
1.79 andrew 523:
1.84 andrew 524: export PKG_PATH TRUSTED_PKG_PATH
525:
1.79 andrew 526: set_version
1.91 andrew 527:
1.93 andrew 528: PKG_PATH=${PKG_PATH:=${MIRROR}/${FORCE_DIR:=$NEW_VER}/packages/`machine -a`/}
529: TRUSTED_PKG_PATH=${TRUSTED_PKG_PATH:=/usr/ports/packages/`machine -a`/all/}
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>