Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 0eb65202588c7374648ba66be8573d9e > files > 1

packagekit-cron-0.5.2-2mdv2010.0.i586.rpm

#!/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

# are we disabled?
if [ "$ENABLED" = "no" ]; then
	exit 1
fi

# set default for SYSTEMNAME
[ -z "$SYSTEMNAME" ]  && SYSTEMNAME=$(hostname)

PKTMP=$(mktemp /var/run/packagekit-cron.XXXXXX)

# wait a random amount of time to avoid hammering the servers
sleep $RANDOM

# do action
if [ "$CHECK_ONLY" = "yes" ]; then
	pkcon get-updates > $PKTMP
else
	pkcon update > $PKTMP
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