#!/bin/bash # Copyright (C) 2008 Richard Hughes # # Some material taken from yum-cron, Copyright 2007 Alec Habig # # Licensed under the GNU General Public License Version 2 # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. [ -f /etc/sysconfig/packagekit-background ] && . /etc/sysconfig/packagekit-background # are we disabled? if [ "$ENABLED" = "no" ]; then exit 0 fi # set default for SYSTEM_NAME [ -z "$SYSTEM_NAME" ] && SYSTEM_NAME=$(hostname) PKTMP=$(mktemp /var/run/packagekit-cron.XXXXXX) PKGCLI_OPTIONS="--background --yes --no-color --quiet" # wait a random amount of time to avoid hammering the servers [ -z "$SLEEP_MAX" ] && SLEEP_MAX=$RANDOM sleep $(( $RANDOM % $SLEEP_MAX + 1 )) # do action if [ "$CHECK_ONLY" = "yes" ]; then pkgcli $PKGCLI_OPTIONS list-updates &> $PKTMP PKGCLI_RETVAL=$? else if [ "$UPDATE_OFFLINE" = "yes" ]; then pkgcli $PKGCLI_OPTIONS offline-update &>> $PKTMP PKGCLI_RETVAL=$? else pkgcli $PKGCLI_OPTIONS update &> $PKTMP PKGCLI_RETVAL=$? fi fi # this is when something useful was done if [ $PKGCLI_RETVAL -ne 5 ]; then # send email if [ -n "$MAILTO" ]; then mail -s "System updates available: $SYSTEM_NAME" $MAILTO < $PKTMP else # default behavior is to use cron's internal mailing of output from cron-script cat $PKTMP fi fi rm -f $PKTMP