[BACK]Return to update_openbsd CVS log [TXT][DIR] Up to [local] / openbsd / update_openbsd

Annotation of openbsd/update_openbsd/update_openbsd, Revision 1.84

1.1       andrew      1: #!/bin/sh
1.84    ! andrew      2: # $AFresh1: update_openbsd,v 1.83 2016/10/01 20:12:17 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
1.77      andrew    260:         follow_symlink $( readlink -f $_file )
1.23      andrew    261:     else
1.33      andrew    262:         echo $_file
1.23      andrew    263:     fi
                    264: }
                    265:
1.20      andrew    266: check_sum () {
                    267:     local _type=$1
1.54      andrew    268:     echo "==> CHECKING $_type SUMS"
1.17      andrew    269:     cd $RELEASEDIR
                    270:
1.20      andrew    271:     if [ ! -e $_type ]; then
                    272:         echo $_type File does not exist!
1.17      andrew    273:         return 1
                    274:     fi
1.6       andrew    275:
1.57      andrew    276:     local _nv=`echo $NEW_VER | sed -e 's/\.//'`
1.61      andrew    277:     local _signify=`which signify 2>/dev/null`
1.67      andrew    278:     local _keyfile=/etc/signify/openbsd-${_nv}-base.pub
1.59      andrew    279:     local _b _s
1.57      andrew    280:
                    281:     (
1.58      andrew    282:         for _b in $INSTALL_KERNELS; do echo "($_b)"        ; done
                    283:         for _s in $INSTALLED_SETS;  do echo "($_s$_nv.tgz)"; done
1.57      andrew    284:     ) > index
1.59      andrew    285:
                    286:
                    287:     if [ -n "$_signify" -a "$_type" != "${_type%.sig}" ]; then
                    288:         echo "===> Checking signature";
                    289:         if [ ! -e $_keyfile ]; then
                    290:             echo "key [$_keyfile] does not exist, cannot check $_type" >&2
                    291:             return 2
                    292:         fi
1.67      andrew    293:         signify -V -e -p $_keyfile -x $_type -m - | grep -f index | sha256 -c -
1.59      andrew    294:     else
1.73      andrew    295:        grep -f index $_type | sha256 -c
1.59      andrew    296:     fi
1.2       andrew    297:
                    298:     if [ $? -ne 0 ]; then
1.20      andrew    299:         echo ERROR: $_type does not match! >&2
1.12      andrew    300:         return 1
1.2       andrew    301:     fi
                    302: }
                    303:
1.17      andrew    304: check_sets() {
1.54      andrew    305:     echo '==> CHECKING SETS'
1.17      andrew    306:     cd $RELEASEDIR
                    307:
1.18      andrew    308:     local _missing_sets
1.17      andrew    309:     local _v=$FILE_VER
                    310:
1.39      andrew    311:     for _n in $INSTALL_KERNELS; do
                    312:         local _o=$_n
                    313:         [ X"bsd" == X"${_o}" -a -e /bsd.sp ] && _o=bsd.sp
                    314:         if [ -e /${_o} -a ! -e ./${_n} ]; then
                    315:             echo ${_o} does not exist
                    316:             _missing_sets=1
1.17      andrew    317:         fi
1.39      andrew    318:
                    319:         if [ X"${BOOT_KERNEL}" == X"/${_o}" -a -e ./${_n} ]; then
                    320:             NEW_KERNEL_VERSION=`kernel_file_version ./${_n}`
1.17      andrew    321:         fi
                    322:     done
                    323:
1.39      andrew    324:     if [ X"$NEW_KERNEL_VERSION" == X"" ]; then
                    325:         echo Missing replacement for boot kernel $BOOT_KERNEL >&2
                    326:         _missing_sets=1
                    327:     fi
                    328:
1.17      andrew    329:     for _s in $INSTALLED_SETS; do
1.71      andrew    330:         [ "$_v" -ge "57" -a "$_s" != "${_s%etc}" ] && continue
1.19      andrew    331:         local _file=${_s}${_v}.tgz
                    332:         if [ ${_s} == sendmail-smtp_auth ]; then
                    333:             _file=${_s}.gz
                    334:         fi
                    335:         if [ ! -e ./${_file} ]; then
                    336:             echo ${_file} does not exist
1.18      andrew    337:             _missing_sets=1
1.17      andrew    338:         fi
                    339:     done
1.18      andrew    340:
                    341:     if [ X"" == X"${_missing_sets}" ]; then
1.54      andrew    342:         echo '===> All OK'
1.18      andrew    343:     fi
1.17      andrew    344:
1.20      andrew    345:     local _type
                    346:     for _type in $CHECKSUM_TYPES; do
1.74      andrew    347:        [ -n "$NO_SIGNIFY" -a "$_type" != "${_type%.sig}" ] && continue
1.20      andrew    348:         if [ -e $_type ]; then
1.59      andrew    349:             check_sum $_type && break
1.62      andrew    350:             [ -z "$IGNORE_CHECKSUM_ERROR" ] && exit 1
1.20      andrew    351:         fi
                    352:     done
1.59      andrew    353:
                    354:     return 0
1.17      andrew    355: }
                    356:
                    357:
1.30      andrew    358: install_kernels() {
1.54      andrew    359:     echo '==> INSTALLING KERNEL'
1.2       andrew    360:
                    361:     if [ X"" == X"$RELEASEDIR" ]; then
1.5       andrew    362:         echo ERROR: no source for new kernels! >&2
1.2       andrew    363:         exit 1
                    364:     fi
                    365:
1.46      andrew    366:     if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
1.54      andrew    367:         echo "===> Backing up $BOOT_KERNEL to /obsd"
1.65      andrew    368:         ln -f $BOOT_KERNEL /obsd
1.46      andrew    369:         if [ $? -ne 0 ]; then
                    370:             echo "Error copying old kernel!" >&2
                    371:             exit 1
                    372:         fi
1.2       andrew    373:     fi
                    374:
1.39      andrew    375:     cd $RELEASEDIR
1.23      andrew    376:
1.39      andrew    377:     for _b in $INSTALL_KERNELS; do
1.65      andrew    378:         rm -f /nbsd
1.39      andrew    379:         local _bd=$_b
                    380:         [ X"${_b}" == X"bsd" ] && _bd="bsd.sp"
1.2       andrew    381:
1.39      andrew    382:         local _is_boot=""
                    383:         [ X"$BOOT_KERNEL" == X"/${_bd}" ] && _is_boot="# boot kernel"
                    384:
1.54      andrew    385:         echo "===> Copying $_b to /$_bd $_is_boot"
1.65      andrew    386:         cp ${_b} /nbsd && mv /nbsd /${_bd}
1.2       andrew    387:         if [ $? -ne 0 ]; then
1.39      andrew    388:             echo ERROR: Could not copy new $_bd kernel! >&2
1.2       andrew    389:             exit 1
                    390:         fi
1.39      andrew    391:     done
                    392:
                    393:     cd $OLDPWD
1.23      andrew    394:
1.39      andrew    395:     if [ ! -h /bsd ]; then
                    396:            cd /
                    397:         for _b in $BOOT_KERNELS; do
                    398:             [ X"$_b" == X"bsd" ] && _b="bsd.sp"
                    399:             if [ -e $_b ]; then
1.54      andrew    400:                 echo "===> symlinking $_b to /bsd"
1.65      andrew    401:                 ln -sf $_b bsd
1.39      andrew    402:                 if [ $? -ne 0 ]; then
                    403:                     echo ERROR: Could not symlink new kernel! >&2
                    404:                     exit 1
                    405:                 fi
                    406:                 break
                    407:             fi
                    408:         done
                    409:            cd $OLDPWD
1.2       andrew    410:     fi
                    411: }
                    412:
                    413: install_sets() {
1.54      andrew    414:     echo '==> INSTALLING SETS'
1.2       andrew    415:
                    416:     if [ X"" == X"$RELEASEDIR" ]; then
1.5       andrew    417:         echo ERROR: no source for sets! >&2
1.2       andrew    418:         exit 1
                    419:     else
                    420:         cd $RELEASEDIR
                    421:     fi
                    422:
1.5       andrew    423:     local _v=$FILE_VER
                    424:
1.21      andrew    425:     local _sets=`ls *${_v}.tgz | grep -v ^base `
                    426:     for _f in ${_sets} base${_v}.tgz; do
1.3       andrew    427:         _path=$DESTDIR
                    428:         if [ X"etc${_v}.tgz"  == X"$_f" \
                    429:             -o X"xetc${_v}.tgz" == X"$_f" ]; then
1.21      andrew    430:             [ X"" != X"$SYSMERGE" ] && continue
1.2       andrew    431:             _path=/var/tmp/temproot
                    432:         fi
                    433:
1.54      andrew    434:         echo "===> Extracting $_f to $_path"
1.65      andrew    435:         mkdir -p $_path
                    436:         tar -C $_path -xzphf ${RELEASEDIR}/${_f}
1.2       andrew    437:         if [ $? -ne 0 ]; then
1.5       andrew    438:             echo ERROR: Could not extract ${_f}! >&2
1.2       andrew    439:             exit 1
                    440:         fi
                    441:     done
                    442:
1.54      andrew    443:     echo '===> Extracted all sets.'
1.51      andrew    444: }
1.19      andrew    445:
1.51      andrew    446: install_sendmail_smtp_auth() {
1.19      andrew    447:     if [ -e ${RELEASEDIR}/sendmail-smtp_auth.gz ]; then
                    448:         gzcat ${RELEASEDIR}/sendmail-smtp_auth.gz > \
                    449:             ${RELEASEDIR}/sendmail-smtp_auth
                    450:     fi
                    451:     if [ -e ${RELEASEDIR}/sendmail-smtp_auth ]; then
1.21      andrew    452:         if ! pkg_info -qe 'cyrus-sasl-*'; then
1.65      andrew    453:             pkg_add -i cyrus-sasl
1.21      andrew    454:         fi
                    455:
1.65      andrew    456:         install -o root -g smmsp -m 2555 \
1.19      andrew    457:             ${RELEASEDIR}/sendmail-smtp_auth \
1.21      andrew    458:             /usr/libexec/sendmail/sendmail
1.19      andrew    459:
1.54      andrew    460:         echo '===> Installed sendmail with smtp_auth'
1.19      andrew    461:     fi
1.2       andrew    462: }
                    463:
                    464: update_etc() {
1.54      andrew    465:     echo '==> UPDATING ETC'
1.10      andrew    466:     if [ ! -e $SYSMERGE ]; then
1.47      andrew    467:         echo "ERROR: Can't find sysmerge!" >&2
                    468:         exit 1;
1.10      andrew    469:     fi
                    470:
1.68      andrew    471:     local _v=$FILE_VER
                    472:     local _args=""
                    473:
1.80      andrew    474:     if [ ! -e /var/sysmerge/etc.tgz ]; then
1.68      andrew    475:         if [ X"" == X"$RELEASEDIR" ]; then
                    476:             echo "ERROR: no source for etc!" >&2
                    477:             exit 1
                    478:         fi
1.2       andrew    479:
1.68      andrew    480:         cd $RELEASEDIR
1.5       andrew    481:
1.68      andrew    482:         if [ -e etc${_v}.tgz ]; then
                    483:             _args="$_args -s ${RELEASEDIR}/etc${_v}.tgz"
                    484:         fi
                    485:         if [ -e xetc${_v}.tgz ]; then
                    486:             _args="$_args -x ${RELEASEDIR}/xetc${_v}.tgz"
                    487:         fi
                    488:         if [ X"" == X"$_args" ]; then
                    489:             echo ERROR: No upgrade sets found! >&2
                    490:             exit 1
                    491:         fi
1.47      andrew    492:     fi
1.68      andrew    493:
                    494:     echo '==> RUNNING SYSMERGE'
                    495:     $SYSMERGE $_args
1.2       andrew    496:
1.47      andrew    497:     cd $OLDPWD
1.2       andrew    498: }
1.14      andrew    499:
1.20      andrew    500:
1.65      andrew    501: if [ $(id -u) != 0 ]; then
                    502:     echo 'ERROR: need root privileges to run this script' >&2
                    503:     exit 1
                    504: fi
                    505:
1.14      andrew    506: if [ -e /etc/update_openbsd.conf ]; then
                    507:     . /etc/update_openbsd.conf
                    508: fi
                    509:
                    510: if [ -e ${HOME}/.update_openbsdrc ]; then
                    511:     . ${HOME}/.update_openbsdrc
                    512: fi
                    513:
1.17      andrew    514: #MIRROR=${MIRROR:=ftp://ftp.openbsd.org/pub/OpenBSD}
1.14      andrew    515: FTP_CMD=${FTP_CMD:=ftp -V}
                    516: PKG_PATH=${PKG_PATH:=/usr/ports/packages/`machine`/all/:${MIRROR}/`uname -r`/packages/`machine`/}
                    517:
                    518: DESTDIR=${DESTDIR:=/}
                    519: SYSMERGE=${SYSMERGE:=/usr/sbin/sysmerge}
                    520: FORCE_DIR=${FORCE_DIR:=No}
1.79      andrew    521:
1.84    ! andrew    522: export PKG_PATH TRUSTED_PKG_PATH
        !           523:
1.79      andrew    524: set_version
1.14      andrew    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.84    ! andrew    536: echo "        SYSMERGE: $SYSMERGE"
        !           537: echo "          MIRROR: $MIRROR"
        !           538: echo "        PKG_PATH: $PKG_PATH"
        !           539: echo "TRUSTED_PKG_PATH: $TRUSTED_PKG_PATH"
        !           540: echo "      RELEASEDIR: $RELEASEDIR"
        !           541: echo "         DESTDIR: $DESTDIR"
        !           542: echo "     BOOT_KERNEL: $BOOT_KERNEL"
        !           543: echo " INSTALL_KERNELS: $INSTALL_KERNELS"
        !           544: echo "  INSTALLED_SETS: $INSTALLED_SETS"
1.8       andrew    545: echo
1.84    ! andrew    546: echo "         CUR_VER: $CUR_VER"
        !           547: echo "         NEW_VER: $NEW_VER"
        !           548: #echo "        FILE_VER: $FILE_VER"
1.2       andrew    549: echo
1.70      andrew    550:
                    551: for k in $INSTALL_KERNELS; do
                    552:     if [ -e "/$k" ]; then
                    553:         echo "Existing $k"
                    554:         kernel_file_version "/$k"
                    555:     fi
                    556: done
1.12      andrew    557:
                    558: if [ ${_error} -ne 0 ]; then
                    559:        exit ${_error}
                    560: fi
1.2       andrew    561:
1.17      andrew    562: if [ X"" != X"${FTP}" ]; then
1.20      andrew    563:     get_sets
1.17      andrew    564: fi
                    565:
                    566: check_sets || exit
1.39      andrew    567:
1.54      andrew    568: echo "===> Last booted:\n$BOOTED_KERNEL_VERSION"
1.39      andrew    569: if [ X"$BOOT_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" \
                    570:   -a X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then
                    571:     echo "Next boot (unless replaced):\n$BOOT_KERNEL_VERSION"
                    572: fi
                    573: if [ -n "$NEW_KERNEL_VERSION" ]; then
1.54      andrew    574:     echo "===> New $BOOT_KERNEL:\n$NEW_KERNEL_VERSION";
1.39      andrew    575: else
                    576:     echo "\n!!! WARNING: Will not replace boot kernel $BOOT_KERNEL! !!!\n" >&2
                    577:     echo "ctrl+C to cancel, enter to continue anyway" >&2
1.44      andrew    578:     local _temp
                    579:     read _temp
1.53      andrew    580:     NEW_KERNEL_VERSION=$BOOT_KERNEL_VERSION
1.44      andrew    581: fi
                    582:
1.66      andrew    583: if [ X"$NEW_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" ]; then
1.44      andrew    584:     echo >&2
1.66      andrew    585:     echo "!!!  You are upgrading the OpenBSD kernel.        !!!" >&2
                    586:     echo "!!!  You will be given the opportunity to reboot  !!!" >&2
                    587:     echo "!!!  at the end of the proces but it is safer to  !!!" >&2
                    588:     echo "!!!  have a separate root shell open.             !!!" >&2
                    589:     echo "!!!  It is needed in order to run /sbin/oreboot.  !!!" >&2
1.78      andrew    590:     echo "!!!  doas MAY NOT WORK after sets are extracted.  !!!" >&2
1.44      andrew    591:     echo >&2
1.66      andrew    592:     echo "enter to continue, ctrl+C to cancel" >&2
1.39      andrew    593:     local _temp
                    594:     read _temp
1.2       andrew    595:
1.66      andrew    596:     if [ ! -e /sbin/oreboot ]; then
                    597:         cp /sbin/reboot /sbin/oreboot
                    598:         if [ $? -ne 0 ]; then
                    599:             echo "Error copying old reboot command!" >&2
                    600:             exit 1
                    601:         fi
                    602:         echo "/sbin/reboot copied to /sbin/oreboot"
1.50      andrew    603:     fi
1.2       andrew    604: fi
                    605:
1.30      andrew    606: install_kernels
1.21      andrew    607: install_sets
1.2       andrew    608:
1.53      andrew    609: if [ X"$NEW_KERNEL_VERSION" == X"$BOOTED_KERNEL_VERSION" ]; then
1.51      andrew    610:     install_sendmail_smtp_auth
                    611:
1.21      andrew    612:     if [ -e /sbin/oreboot ]; then
                    613:         echo Removing /sbin/oreboot
1.69      andrew    614:         rm -f /sbin/oreboot
1.21      andrew    615:     fi
1.2       andrew    616:     update_etc
                    617:
1.81      andrew    618:     OPENUP=$( which openup 2>/dev/null )
1.76      andrew    619:     if [ -n "$OPENUP" ]; then
                    620:         echo "==> UPDATING WITH $OPENUP"
                    621:         $OPENUP
                    622:     else
                    623:         echo '==> UPDATING PACKAGES'
                    624:         pkg_add -ui -F update -F updatedepends
                    625:     fi
1.72      andrew    626:
                    627:     echo '==> UPDATING FIRMWARE'
                    628:     fw_update
1.2       andrew    629:
                    630: else
1.83      andrew    631:     [ -e /etc/rc.sysmerge ] && grep -q $SYSMERGE /etc/rc.sysmerge ||
1.82      andrew    632:         echo "$SYSMERGE -b" >>/etc/rc.sysmerge &&
                    633:         echo "==> RUNNING $SYSMERGE -b ON REBOOT"
                    634:
1.2       andrew    635:     echo Instructions for updating to the new version available from
1.36      andrew    636:     if [ X"snapshots" == X"$FORCE_DIR" ]; then
1.30      andrew    637:         echo "  http://www.openbsd.org/faq/current.html"
                    638:     else
                    639:         echo "  http://www.openbsd.org/faq/upgrade${FILE_VER}.html"
                    640:     fi
1.2       andrew    641: fi
                    642:
1.66      andrew    643: echo Update complete. enter to reboot, ctrl+C to cancel
1.65      andrew    644: read _temp
1.22      andrew    645: if [ -e /sbin/oreboot ]; then
1.66      andrew    646:     echo using /sbin/oreboot
1.65      andrew    647:     /sbin/oreboot
                    648: else
                    649:     /sbin/reboot
1.22      andrew    650: fi

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>