=================================================================== RCS file: /cvs/openbsd/update_openbsd/update_openbsd,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- openbsd/update_openbsd/update_openbsd 2014/02/01 16:31:51 1.64 +++ openbsd/update_openbsd/update_openbsd 2014/02/01 19:13:53 1.65 @@ -1,5 +1,5 @@ #!/bin/sh -# $AFresh1: update_openbsd,v 1.63 2014/01/23 03:17:06 andrew Exp $ +# $AFresh1: update_openbsd,v 1.64 2014/02/01 16:31:51 andrew Exp $ # # Copyright (c) 2012 Andrew Fresh # @@ -351,10 +351,6 @@ install_kernels() { echo '==> INSTALLING KERNEL' - if [ X"$USER" != X"root" -a X"$SUDO" == X"" ]; then - echo ${0##*/} must be run as root or SUDO must be set! >&2 - exit 1 - fi if [ X"" == X"$RELEASEDIR" ]; then echo ERROR: no source for new kernels! >&2 @@ -363,7 +359,7 @@ if [ X"$BOOT_KERNEL_VERSION" != X"$NEW_KERNEL_VERSION" ]; then echo "===> Backing up $BOOT_KERNEL to /obsd" - $SUDO ln -f $BOOT_KERNEL /obsd + ln -f $BOOT_KERNEL /obsd if [ $? -ne 0 ]; then echo "Error copying old kernel!" >&2 exit 1 @@ -373,7 +369,7 @@ cd $RELEASEDIR for _b in $INSTALL_KERNELS; do - $SUDO rm -f /nbsd + rm -f /nbsd local _bd=$_b [ X"${_b}" == X"bsd" ] && _bd="bsd.sp" @@ -381,7 +377,7 @@ [ X"$BOOT_KERNEL" == X"/${_bd}" ] && _is_boot="# boot kernel" echo "===> Copying $_b to /$_bd $_is_boot" - $SUDO cp ${_b} /nbsd && $SUDO mv /nbsd /${_bd} + cp ${_b} /nbsd && mv /nbsd /${_bd} if [ $? -ne 0 ]; then echo ERROR: Could not copy new $_bd kernel! >&2 exit 1 @@ -396,7 +392,7 @@ [ X"$_b" == X"bsd" ] && _b="bsd.sp" if [ -e $_b ]; then echo "===> symlinking $_b to /bsd" - $SUDO ln -sf $_b bsd + ln -sf $_b bsd if [ $? -ne 0 ]; then echo ERROR: Could not symlink new kernel! >&2 exit 1 @@ -410,10 +406,6 @@ install_sets() { echo '==> INSTALLING SETS' - if [ X"$USER" != X"root" -a X"$SUDO" == X"" ]; then - echo ${0##*/} must be run as root or SUDO must be set! >&2 - exit 1 - fi if [ X"" == X"$RELEASEDIR" ]; then echo ERROR: no source for sets! >&2 @@ -434,8 +426,8 @@ fi echo "===> Extracting $_f to $_path" - $SUDO mkdir -p $_path - $SUDO tar -C $_path -xzphf ${RELEASEDIR}/${_f} + mkdir -p $_path + tar -C $_path -xzphf ${RELEASEDIR}/${_f} if [ $? -ne 0 ]; then echo ERROR: Could not extract ${_f}! >&2 exit 1 @@ -452,10 +444,10 @@ fi if [ -e ${RELEASEDIR}/sendmail-smtp_auth ]; then if ! pkg_info -qe 'cyrus-sasl-*'; then - $SUDO pkg_add -i cyrus-sasl + pkg_add -i cyrus-sasl fi - $SUDO install -o root -g smmsp -m 2555 \ + install -o root -g smmsp -m 2555 \ ${RELEASEDIR}/sendmail-smtp_auth \ /usr/libexec/sendmail/sendmail @@ -489,13 +481,18 @@ echo ERROR: No upgrade sets found! >&2 else echo '==> RUNNING SYSMERGE' - $SUDO $SYSMERGE $_args + $SYSMERGE $_args fi cd $OLDPWD } +if [ $(id -u) != 0 ]; then + echo 'ERROR: need root privileges to run this script' >&2 + exit 1 +fi + if [ -e /etc/update_openbsd.conf ]; then . /etc/update_openbsd.conf fi @@ -523,7 +520,6 @@ echo "-= update_openbsd - helper script to update OpenBSD =-" echo "------------------------------------------------------" echo -echo " SUDO: $SUDO" echo " SYSMERGE: $SYSMERGE" echo " MIRROR: $MIRROR" echo " RELEASEDIR: $RELEASEDIR" @@ -562,7 +558,7 @@ NEW_KERNEL_VERSION=$BOOT_KERNEL_VERSION fi -if [ -n "$SUDO" -a $CUR_VER != $NEW_VER ]; then +if [ $CUR_VER != $NEW_VER ]; then echo >&2 echo "!!! You are upgrading between OpenBSD versions. !!!" >&2 echo "!!! You should make sure you have a root shell open !!!" >&2 @@ -574,15 +570,9 @@ read _temp fi -if [ -n "$SUDO" ]; then - echo - echo You may be asked for your sudo password multiple times. - $SUDO -v -p "sudo Password: " -fi - if [ X"$NEW_KERNEL_VERSION" != X"$BOOTED_KERNEL_VERSION" \ -a ! -e /sbin/oreboot ]; then - $SUDO cp /sbin/reboot /sbin/oreboot + cp /sbin/reboot /sbin/oreboot if [ $? -ne 0 ]; then echo "Error copying old reboot command!" >&2 exit 1 @@ -598,12 +588,12 @@ if [ -e /sbin/oreboot ]; then echo Removing /sbin/oreboot - $SUDO rm -f /sbin/oreboot + $rm -f /sbin/oreboot fi update_etc echo '==> UPDATING PACKAGES' - $SUDO pkg_add -ui -F update -F updatedepends + pkg_add -ui -F update -F updatedepends else echo Instructions for updating to the new version available from @@ -614,7 +604,10 @@ fi fi -echo New kernel installed. Please reboot! +echo Update complete press any key to reboot, ctrl+C to cancel +read _temp if [ -e /sbin/oreboot ]; then - echo Possibly using /sbin/oreboot + /sbin/oreboot +else + /sbin/reboot fi