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