2008-03-04 03:08:16 -08:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (C) 2008 Richard Hughes <richard@hughsie.com>
|
|
|
|
#
|
|
|
|
# Some material taken from yum-cron, Copyright 2007 Alec Habig <ahabig@umn.edu>
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
|
2008-03-16 11:46:03 -07:00
|
|
|
# are we disabled?
|
2009-06-05 03:56:42 -07:00
|
|
|
if [ "$ENABLED" = "no" ]; then
|
2008-03-16 11:46:03 -07:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2008-03-04 03:08:16 -08:00
|
|
|
# set default for SYSTEMNAME
|
|
|
|
[ -z "$SYSTEMNAME" ] && SYSTEMNAME=$(hostname)
|
|
|
|
|
|
|
|
PKTMP=$(mktemp /var/run/packagekit-cron.XXXXXX)
|
|
|
|
|
2008-03-04 08:42:34 -08:00
|
|
|
# wait a random amount of time to avoid hammering the servers
|
|
|
|
sleep $RANDOM
|
|
|
|
|
2008-03-04 03:08:16 -08:00
|
|
|
# do action
|
2009-06-05 03:56:42 -07:00
|
|
|
if [ "$CHECK_ONLY" = "yes" ]; then
|
2008-10-05 10:35:21 -07:00
|
|
|
pkcon get-updates > $PKTMP
|
2008-03-04 03:08:16 -08:00
|
|
|
else
|
2008-10-05 10:35:21 -07:00
|
|
|
pkcon update > $PKTMP
|
2008-03-04 03:08:16 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# send email
|
|
|
|
if [ -n "$MAILTO" ]; then
|
|
|
|
mail -s "System updates available: $SYSTEMNAME" $MAILTO < $PKTMP
|
|
|
|
else
|
|
|
|
# default behavior is to use cron's internal mailing of output from cron-script
|
|
|
|
cat $PKTMP
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -f $PKTMP
|
|
|
|
|