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