#!/bin/bash # update mode for zypper # dup or up ZYPPER_OFFLINE_UPDATE_MODE=up # include recommended patches # yes or no ZYPPER_OFFLINE_UPDATE_RECOMENDS=no ZYPPER_OFFLINE_UPDATE_STATUS_FILE=/var/run/zypper-update-triggered if [ -e /etc/sysconfig/zypper-offline-update ]; then . /etc/sysconfig/zypper-offline-update fi if [ $ZYPPER_OFFLINE_UPDATE_RECOMENDS = no ]; then NORECOMMENDS=--no-recommends fi function log() { LEVEL=$1 MESSAGE=$2 echo $MESSAGE echo $MESSAGE | systemd-cat -t zypper-auto-update -p $LEVEL } # Refresh repositories /usr/bin/zypper refresh # Download updates (non-interactive) without changing recommendations and other specified options if /usr/bin/zypper $ZYPPER_OFFLINE_UPDATE_MODE -y $NORECOMMENDS --download-only; then # Create a flag file to indicate the update was triggered and completed successfully echo 1 > $ZYPPER_OFFLINE_UPDATE_STATUS_FILE log "info" "Update download completed successfully" else echo 2 > $ZYPPER_OFFLINE_UPDATE_STATUS_FILE log "err" "Update download failed" exit 1 fi # Ensure the service exits cleanly exit 0