File: packagekit-background.cron

package info (click to toggle)
packagekit 1.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,824 kB
  • sloc: ansic: 56,491; cpp: 15,652; xml: 5,532; python: 4,932; sh: 316; perl: 60; makefile: 56
file content (54 lines) | stat: -rwxr-xr-x 1,544 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
# 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 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