]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.daily
[rmurray] debian/cron.daily: various cleanups and improvements.
[dak.git] / config / debian / cron.daily
1 #! /bin/sh
2 #
3 # Executed daily via cron, out of dak's crontab.
4
5 set -e
6 export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars
7 . $SCRIPTVARS
8
9 ################################################################################
10
11 echo Archive maintenance started at $(date +%X)
12 TS=0
13
14 NOTICE="$ftpdir/Archive_Maintenance_In_Progress"
15 LOCKCU="$lockdir/daily.lock"
16 LOCKAC="$lockdir/unchecked.lock"
17 lockac=0
18
19 cleanup() {
20   rm -f "$NOTICE"
21   rm -f "$LOCKCU"
22   if [ "$lockac" -eq "1" ]; then
23     rm -f "$LOCKAC"
24   fi
25 }
26 lockfile -l 3600 $LOCKCU
27 trap cleanup 0
28
29 rm -f "$NOTICE"
30 cat > "$NOTICE" <<EOF
31 Packages are currently being installed and indices rebuilt.
32 Maintenance is automatic, starting at 13:52 US Central time, and
33 ending at about 15:30.  This file is then removed.
34
35 You should not mirror the archive during this period.
36 EOF
37
38 ################################################################################
39
40 echo "Creating pre-daily-cron-job backup of projectb database..."
41 pg_dump projectb > $base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
42
43 ################################################################################
44
45 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
46 cd $configdir
47 $scriptsdir/update-bugdoctxt
48 $scriptsdir/update-mirrorlists
49 $scriptsdir/update-mailingliststxt
50
51 ################################################################################
52
53 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
54 lockfile $LOCKAC
55 lockac=1
56 cd $accepted
57 rm -f REPORT
58 dak process-accepted -pa *.changes | tee REPORT | \
59      mail -s "Install for $(date +%D)" ftpmaster@ftp-master.debian.org
60 chgrp debadmin REPORT
61 chmod 664 REPORT
62
63 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
64
65 dak check-overrides
66 rm -f $LOCKAC
67 lockac=0
68
69 symlinks -d -r $ftpdir
70
71 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
72
73 dak make-suite-file-list
74
75 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
76
77 # Update fingerprints
78 # [JT - disabled, dak import-ldap-fingerprints currently can ask questions]
79 #dak import-ldap-fingerprints
80
81 # Generate override files
82 cd $overridedir
83 dak make-overrides
84
85 # Update task overrides for testing and unstable
86 # [JT 2004-02-04 disabled; copying in by hand for now]
87 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sarge.extra.main
88 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sid.extra.main
89
90 # FIXME
91 rm -f override.sid.all3
92 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
93
94 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
95
96 # Generate Packages and Sources files
97 cd $configdir
98 apt-ftparchive generate apt.conf
99 # Generate *.diff/ incremental updates
100 dak generate-index-diffs
101 # Generate Release files
102 dak generate-releases
103
104 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
105
106 # Clean out old packages
107 dak clean-suites
108 dak clean-queues
109
110 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
111
112 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
113 # update this before wanna-build is updated.
114 psql projectb -A -t -q -c "SELECT filename FROM queue_build WHERE suite = 5 AND queue = 0 AND in_queue = true AND filename ~ 'd(sc|eb)$'" > $dbdir/dists/unstable_accepted.list
115 symlinks -d /srv/incoming.debian.org/buildd > /dev/null
116 apt-ftparchive generate apt.conf.buildd
117
118 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
119
120 cd $scriptsdir
121 ./mkmaintainers
122 ./copyoverrides
123 ./mklslar
124 ./mkfilesindices
125 ./mkchecksums
126 #
127 # Fetch bugs information before unchecked processing is allowed again.
128 $base/testing/britney allowdaklock bugs || true
129 rm -f $NOTICE
130 ssh buildd@buildd /org/wanna-build/trigger.daily
131
132 rm -f $LOCKCU
133 echo Archive maintenance finished at $(date +%X)
134
135 ################################################################################
136
137 echo "Creating post-daily-cron-job backup of projectb database..."
138 POSTDUMP=$base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
139 pg_dump projectb > $POSTDUMP
140 (cd $base/backup; ln -sf $POSTDUMP current)
141
142 ################################################################################
143
144 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
145
146 # Vacuum the database
147 echo "VACUUM; VACUUM ANALYZE;" | psql projectb 2>&1 | grep -v "^NOTICE:  Skipping.*only table owner can VACUUM it$"
148
149 ################################################################################
150
151 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
152
153 # Send a report on NEW/BYHAND packages
154 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
155 # and one on crufty packages
156 dak cruft-report | tee $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
157
158 ################################################################################
159
160 # Run mirror-split
161
162 #time dak mirror-split
163
164 ################################################################################
165
166 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
167
168 ulimit -m 90000 -d 90000 -s 10000 -v 90000
169
170 run-parts --report $base/scripts/distmnt
171
172 echo Daily cron scripts successful.
173
174 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
175
176 # Stats pr0n
177 cd $configdir
178 $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
179 R --slave --vanilla < $base/misc/ftpstats.R
180
181 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
182
183 # Clean up apt-ftparchive's databases
184
185 cd $configdir
186 apt-ftparchive -q clean apt.conf
187
188 ################################################################################