slack-autoupdate

Update your Slackware system automatically
git clone git://git.server.ky/slackcoder/slack-autoupdate
Log | Files | Refs | README

rc.slack-autoupdate (1403B)


      1 #!/bin/bash 
      2 #
      3 # Automatically update your system on reboot using packages in the PACKAGE_DIR.
      4 #
      5 # Sometimes there are additional steps to make when your kernel is updated.
      6 # You can define these in a custom 'install-kernel' command which this script
      7 # will run if found.  We recommend placing this under /usr/local/sbin.
      8 #
      9 
     10 export PATH=$PATH:/usr/local/bin:/usr/local/sbin
     11 
     12 # Duration in seconds to wait before installing pending updates.
     13 WAIT_TIME=5
     14 
     15 # Where packages are stored pending installation.  You can use sub-directories
     16 # to order and group packages.
     17 PACKAGE_DIR="/var/spool/slack-autoupdate"
     18 
     19 UPDATES="$(find "$PACKAGE_DIR" -name '*.t*z' | sort)"
     20 
     21 if [ -z "$UPDATES" ]; then
     22   exit 0
     23 fi
     24 
     25 if read -r -t "$WAIT_TIME" -p "Your system has pending software updates.  They will be installed in ${WAIT_TIME} seconds.  Press enter to skip..."; then
     26   exit 0
     27 fi
     28 echo " proceeding."
     29 
     30 OLD_KERNEL="$(md5sum /boot/vmlinuz | cut -f1 -d' ')"
     31 
     32 for PKG in $UPDATES; do
     33   upgradepkg --install-new --terse "$PKG"
     34 done
     35 
     36 NEW_KERNEL="$(md5sum /boot/vmlinuz | cut -f1 -d' ')"
     37 if [ "$OLD_KERNEL" != "$NEW_KERNEL" ]; then
     38   if command -v install-kernel &> /dev/null; then
     39     install-kernel /boot/vmlinuz
     40   fi
     41 fi
     42 
     43 # All package updates have been processed.
     44 #
     45 # This will error out if PACKAGE_DIR is accidentally unset.
     46 find "$PACKAGE_DIR" -mindepth 1 | xargs rm -fr
     47 
     48 echo "All updates have been installed."
     49 
     50 reboot