]> git.deb.at Git - deb/packages.git/blob - cron.d/050checkinst
The Big, the Fat and the Ugly commit ;)
[deb/packages.git] / cron.d / 050checkinst
1 #! /bin/sh
2
3 # Test whether all required packages are installed and generate a mail
4 # if they aren't, so that the admin is informed.
5
6 required="subversion gettext locales rsync dpkg-dev procmail"
7 required="$required libcompress-zlib-perl"
8 required="$required libhtml-parser-perl libio-stringy-perl"
9 required="$required liblocale-gettext-perl libmldbm-perl"
10 required="$required libtext-iconv-perl libhtml-template-perl"
11 required="$required libclass-accessor-perl"
12 required="$required liburi-perl libxml-rss-perl"
13 required="$required libtemplate-perl libi18n-acceptlanguage-perl"
14
15 locales="de_DE.UTF-8 en_US.UTF-8 nl_NL fr_FR.UTF-8"
16
17 packages=`tempfile`
18 locs=`tempfile`
19 cache=`tempfile`
20 trap "rm -f $packages $locs" INT EXIT
21
22 for p in $required
23 do
24     if [ -z "$(dpkg -l $p|grep ^ii)" ]
25     then
26         echo "Package $p missing." >> $packages
27         echo >> $packages
28     fi
29 done
30
31 for l in $locales
32 do
33     if ! grep -q "^$l" /etc/locale.gen
34     then
35         echo "Locale $l missing." >> $locs
36         echo >> $locs
37     fi
38 done
39
40 if [ -n "$cachedir" ]
41 then
42     if [ ! -d "$cachedir" ]
43     then
44         echo "cachedir missing." >> $cache
45     else
46         perm=$(ls -ld "$cachedir" | perl -ne 'print "ok" if /^drwxrws--- \d+ www-data/')
47         if [ -z "$perm" ]
48         then
49             echo "cachedir has wrong permissions." >> $cache
50             echo "make sure it is writable by the web server." >> $cache
51         fi
52     fi
53 fi
54
55 if [ -s $packages -o -s $locs -o -s $cache ]
56 then
57     (
58         echo "Subject: Problem packages.debian.org on `hostname -s`"
59         echo "To: ${admin_email}"
60         echo
61         echo "On host `hostname -f`"
62         echo
63         if [ -s $packages ]
64         then
65             echo "Missing packages:"
66             echo
67             cat $packages
68         fi
69         if [ -s $locs ]
70         then
71             echo "Missing locales:"
72             echo
73             cat $locs
74         fi
75         if [ -s $cache ]
76         then
77             echo "Problems with cachedir:"
78             echo
79             cat $cache
80         fi
81     ) | /usr/sbin/sendmail -t
82 fi
83