Update changelog
[ntk/apt.git] / debian / apt.cron.daily
CommitLineData
0c132682
MZ
1#!/bin/sh
2#
3# cron job for apt-get update
4#
5# Update-Package-Intervall is in days
6#
7STAMP=/var/lib/apt/update-stamp
8
9#set -e
10
11do_update()
12{
13 touch $STAMP.new
14 if apt-get update -qq; then
15 if [ -x /usr/bin/dbus-send ]; then
16 dbus-send --system / app.apt.dbus.updated boolean:true
17 fi
18 mv $STAMP.new $STAMP
19 fi
20 rm -f $STAMP.new
21}
22
23UpdateInterval=0
24RES=`apt-config shell UpdateInterval APT::Periodic::Update-Package-Lists`
25eval $RES
26
27if [ $UpdateInterval -eq 0 ]; then
28 exit 0
29fi
30
31# laptop check, on_ac_power returns:
32# 0 (true) System is on mains power
33# 1 (false) System is not on mains power
34# 255 (false) Power status could not be determined
35# Desktop systems always return 255 it seems
2288cf77
MZ
36if which on_ac_power >/dev/null; then
37 on_ac_power
0c132682
MZ
38 if [ $? -eq 1 ]; then
39 exit 0
40 fi
41fi
42
43if [ ! -f $STAMP ]; then
44 do_update
45 exit 0
46fi
47
48LastUpdate=`stat -c "%Y" $STAMP 2>/dev/null`
49Now=`date +%s`
50
51NeedUpdate=$(($LastUpdate+$UpdateInterval*3600*24))
52if [ $NeedUpdate -le $Now ]; then
53 do_update
54fi