#!/bin/bash if [ -f /etc/profile.d/profile.sh ]; then . /etc/profile.d/profile.sh fi zyppercmd="/usr/bin/zypper" zcmd="/bin/false" syscfgfile="/etc/sysconfig/zypper-online-update" if [ -x ${zyppercmd} ] then zcmd="${zyppercmd} --non-interactive --quiet patch" else echo "zypper is not installed. Can not run online update." exit 1 fi if [ -f ${syscfgfile} ] then . ${syscfgfile} fi if [ ! "$ZYPPER_ONLINE_UPDATE_ENABLE_CRONJOB" = "yes" ] then echo "Online Update is disabled in ${syscfgfile}. Will not run update." exit 0 fi if [ "${ZYPPER_ONLINE_UPDATE_SKIP_INTERACTIVE_PATCHES}" = "yes" ] ; then zcmd="$zcmd --skip-interactive" else zcmd="$zcmd --with-interactive" fi if [ "${ZYPPER_ONLINE_UPDATE_AUTO_AGREE_WITH_LICENSES}" = "yes" ] ; then zcmd="$zcmd --auto-agree-with-licenses" fi if [ "${ZYPPER_ONLINE_UPDATE_RECOMMENDS}" = "yes" ] ; then zcmd="$zcmd --recommends" else zcmd="$zcmd --no-recommends" fi function runzypper { # run passed arguments "$@" local status=$? # the return code 103 indicates a succesful patch of the zypper package # other patches might stil be waiting if [ $status -eq 103 ]; then echo "The Zypper package was patched, rerunning update to apply remaining patches." # rerun passed zypper command and use new status as return value "$@" status=$? fi return $status } # trim whitespaces ZYPPER_ONLINE_UPDATE_PATCH_CATEGORIES=`echo $ZYPPER_ONLINE_UPDATE_PATCH_CATEGORIES` # run the update if [ -z "$ZYPPER_ONLINE_UPDATE_PATCH_CATEGORIES" ] ; then runzypper $zcmd else # handle errors for multiple categories ret=0 for cat in $ZYPPER_ONLINE_UPDATE_PATCH_CATEGORIES ; do runzypper $zcmd --category "$cat" || ret=$? done exit $ret fi