11 if [ $interval -eq 0 ]; then
15 if [ ! -f $stamp ]; then
19 # compare midnight today to midnight the day the stamp was updated
20 stamp
=$
(date --date=$
(date -r $stamp --iso-8601) +%s
)
21 now
=$
(date --date=$
(date --iso-8601) +%s
)
22 delta
=$
(($now-$stamp))
24 if [ $delta -ge $interval ]; then
40 # we check here if autoclean was enough sizewise
41 check_size_constrains
()
46 CacheDir
="var/cache/apt"
47 CacheArchive
="archives/"
48 eval $
(apt-config shell MaxAge APT
::Archives
::MaxAge
)
49 eval $
(apt-config shell MaxSize APT
::Archives
::MaxSize
)
50 eval $
(apt-config shell CacheDir Dir
::Cache
)
51 eval $
(apt-config shell CacheArchive Dir
::Cache
::archives
)
54 if [ -z "$CacheDir" -o -z "$CacheArchive" ]; then
55 echo "empty Dir::Cache or Dir::Cache::archives, exiting"
58 Cache
="/"$CacheDir$CacheArchive
61 if [ ! $MaxAge -eq 0 ]; then
62 find $Cache -name "*.deb" -mtime +$MaxAge -exec rm -f {} \
;
66 if [ ! $MaxSize -eq 0 ]; then
67 # reverse-sort by mtime
68 for file in $
(ls -rt $Cache/*.deb
); do
71 # check if the cache is small enough
72 if [ $size -lt $MaxSize ]; then
84 DownloadUpgradeableInterval
=0
85 eval $
(apt-config shell UpdateInterval APT
::Periodic
::Update-Package-Lists DownloadUpgradeableInterval APT
::Periodic
::Download-Upgradeable-Packages
)
86 AutocleanInterval
=$DownloadUpgradeableInterval
87 eval $
(apt-config shell AutocleanInterval APT
::Periodic
::Autoclean
)
89 # laptop check, on_ac_power returns:
90 # 0 (true) System is on mains power
91 # 1 (false) System is not on mains power
92 # 255 (false) Power status could not be determined
93 # Desktop systems always return 255 it seems
94 if which on_ac_power
>/dev
/null
; then
101 UPDATE_STAMP
=/var
/lib
/apt
/periodic
/update-stamp
102 if check_stamp
$UPDATE_STAMP $UpdateInterval; then
103 if apt-get
-qq update
2>/dev
/null
; then
104 if which dbus-send
>/dev
/null
; then
105 dbus-send
--system / app.apt.dbus.updated boolean
:true
107 update_stamp
$UPDATE_STAMP
111 DOWNLOAD_UPGRADEABLE_STAMP
=/var
/lib
/apt
/periodic
/download-upgradeable-stamp
112 if check_stamp
$DOWNLOAD_UPGRADEABLE_STAMP $DownloadUpgradeableInterval; then
113 apt-get
-qq -d dist-upgrade
2>/dev
/null
114 update_stamp
$DOWNLOAD_UPGRADEABLE_STAMP
117 AUTOCLEAN_STAMP
=/var
/lib
/apt
/periodic
/autoclean-stamp
118 if check_stamp
$AUTOCLEAN_STAMP $AutocleanInterval; then
119 apt-get
-qq autoclean
121 update_stamp
$AUTOCLEAN_STAMP