version 1.105, 2017/12/11 02:58:57 |
version 1.110, 2018/10/01 00:31:27 |
|
|
#!/bin/sh |
#!/bin/sh |
# $AFresh1: update_openbsd,v 1.103 2017/12/11 02:50:09 andrew Exp $ |
# $AFresh1: update_openbsd,v 1.109 2018/02/08 19:08:01 andrew Exp $ |
# |
# |
# Copyright (c) 2012 Andrew Fresh <andrew@afresh1.com> |
# Copyright (c) 2012 Andrew Fresh <andrew@afresh1.com> |
# |
# |
|
|
boot_device_mounted="" |
boot_device_mounted="" |
mount_boot_device() { |
mount_boot_device() { |
[ "$boot_device_mounted" ] && return |
[ "$boot_device_mounted" ] && return |
|
[ "$BOOT_DEVICE" ] || return |
|
|
local default_mount=$( df -lnP /bsd | sed -ne 's!/dev/.* !!p' ) |
local default_mount=$( df -lnP /bsd | sed -ne 's!/dev/.* !!p' ) |
local boot_mount=$( mount | |
local boot_mount=$( mount | |
|
|
cd $KERNEL_ROOT |
cd $KERNEL_ROOT |
BOOT_KERNEL=$( find_boot_kernel ) |
BOOT_KERNEL=$( find_boot_kernel ) |
BOOT_KERNEL_VERSION=$( kernel_file_version $BOOT_KERNEL ) |
BOOT_KERNEL_VERSION=$( kernel_file_version $BOOT_KERNEL ) |
kernel_is_multiprocessor $BOOT_KERNEL && BOOT_KERNEL=bsd.mp |
if [ $(sysctl -n hw.ncpufound) -gt 1 ] || kernel_is_multiprocessor $BOOT_KERNEL; then |
cd $OLDPWD |
BOOT_KERNEL=bsd.mp |
umount_boot_device |
fi |
|
|
BOOTED_KERNEL_VERSION=`sysctl -n kern.version` |
BOOTED_KERNEL_VERSION=`sysctl -n kern.version` |
NEW_KERNEL_VERSION="" |
NEW_KERNEL_VERSION="" |
|
|
if [ X"$INSTALL_KERNELS" == X"bsd.sp" ]; then |
if [ X"$INSTALL_KERNELS" == X"bsd.sp" ]; then |
INSTALL_KERNELS="bsd" |
INSTALL_KERNELS="bsd" |
fi |
fi |
# with a second option of an mp kernel if is is a likely candidate |
|
if [ X"$INSTALL_KERNELS" != X"bsd.mp" ]; then |
# We want to update all kernels that exist |
local _ncpu=$(sysctl -n hw.ncpufound) |
# either in the $KERNEL_ROOT or in / |
[ $_ncpu -gt 1 ] && INSTALL_KERNELS="$INSTALL_KERNELS bsd.mp" |
for b in bsd bsd.mp; do |
fi |
[ -e $b -o -e /$b ] || continue |
# or just bsd otherwise |
if [ X"${INSTALL_KERNELS% *}" != X"$b" ]; then |
if [ X"${INSTALL_KERNELS% *}" != X"bsd" ]; then |
INSTALL_KERNELS="$INSTALL_KERNELS $b" |
INSTALL_KERNELS="$INSTALL_KERNELS bsd" |
fi |
fi |
done |
|
|
|
cd $OLDPWD |
|
umount_boot_device |
|
|
BOOT_KERNELS=$INSTALL_KERNELS |
BOOT_KERNELS=$INSTALL_KERNELS |
INSTALL_KERNELS="$INSTALL_KERNELS bsd.rd" |
INSTALL_KERNELS="$INSTALL_KERNELS bsd.rd" |
} |
} |
|
|
|
|
|
|
install_kernels() { |
install_kernels() { |
local _d=$1 |
local _d="$1" |
local default_mount |
local default_mount |
local boot_mount |
local boot_mount |
local mount_is_msdos |
local mount_is_msdos |
|
|
if [ ! "$_d" ]; then |
if [ "$_d" ]; then |
|
_d=$( readlink -nf "$_d" ) |
|
else |
default_mount=$( df -lnP /bsd | sed -ne 's!/dev/.* !!p' ) |
default_mount=$( df -lnP /bsd | sed -ne 's!/dev/.* !!p' ) |
mount_boot_device |
mount_boot_device |
|
|
|
|
fi |
fi |
|
|
[ $_d != / ] && mount | grep -q " on ${_d%/} .* msdos" && mount_is_msdos=1 |
[ $_d != / ] && mount | grep -q " on ${_d%/} .* msdos" && mount_is_msdos=1 |
|
[ $_d != / ] && $_d=$_d/ |
|
|
if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then |
if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then |
echo "===> Backing up $BOOT_KERNEL to ${_d}obsd" |
echo "===> Backing up $BOOT_KERNEL to ${_d}obsd" |
if [ $mount_is_msdos ]; then |
if [ $mount_is_msdos ]; then |
cp $BOOT_KERNEL ${_d}obsd |
cp ${_d}$BOOT_KERNEL ${_d}obsd |
else |
else |
ln -f $BOOT_KERNEL ${_d}obsd |
ln -f ${_d}$BOOT_KERNEL ${_d}obsd |
fi |
fi |
if [ $? -ne 0 ]; then |
if [ $? -ne 0 ]; then |
echo "Error copying old kernel!" >&2 |
echo "Error copying old kernel!" >&2 |
|
|
. ${HOME}/.update_openbsdrc |
. ${HOME}/.update_openbsdrc |
fi |
fi |
|
|
MIRROR=${MIRROR:=http://fastly.cdn.openbsd.org/pub/OpenBSD} |
MIRROR=${MIRROR:=http://cdn.openbsd.org/pub/OpenBSD} |
FTP_CMD=${FTP_CMD:=ftp -V} |
FTP_CMD=${FTP_CMD:=ftp -V} |
|
|
DESTDIR=${DESTDIR:=/} |
DESTDIR=${DESTDIR:=/} |