4 STATUS=/var/cache/dsa/nagios/apt
10 [ -e "$STATUS" ] || return $run
11 [ /var/lib/dpkg/status -nt "$STATUS" ] && return $run
12 [ /var/cache/apt/pkgcache.bin -nt "$STATUS" ] && return $run
13 grep "apt-get update failed" "$STATUS" > /dev/null && return $run
18 if [ "$1" == "hourly" ] ; then
19 # on the hourly run, only update when the system changed since the last run
24 # sleep if called non-interactively
25 if [ -z "$TERM" -o "$TERM" = "dumb" ]; then
26 sleep $(( $RANDOM % $sleep_max ))
29 # run apt-get update, retry a few times if it fails
31 while [ "$count" -lt "$UPDATE_RUNS" ]; do
33 if [ "$?" = "0" ]; then break; fi
34 sleep $(( $RANDOM % 600 ))
35 count="$(( $count + 1 ))"
37 if [ "$count" -ge "$UPDATE_RUNS" ]; then
39 echo "apt-get update failed") > "$STATUS"
43 # run the apt check itself
45 trap "rm -f '$tmp'" exit
46 /usr/share/dsa/apt-status-check --noupdate --timeout=600 > "$tmp"
62 (echo "$st"; cat "$tmp") > "$STATUS"