]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.dinstall
Seems more correct to use the start time we saved in for the cron mail
[dak.git] / config / debian / cron.dinstall
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 # Start logging
12 NOW=`date "+%Y.%m.%d-%H:%M:%S"`
13 LOGFILE="$logdir/dinstall_${NOW}.log"
14 exec > "$LOGFILE" 2>&1
15
16 echo Archive maintenance started at $(date +%X)
17 TS=0
18
19 NOTICE="$ftpdir/Archive_Maintenance_In_Progress"
20 LOCKCU="$lockdir/daily.lock"
21 LOCKAC="$lockdir/unchecked.lock"
22 lockac=0
23
24 cleanup() {
25   rm -f "$NOTICE"
26   rm -f "$LOCKCU"
27   if [ "$lockac" -eq "1" ]; then
28     rm -f "$LOCKAC"
29   fi
30   echo "Cleanup"
31   rm -f "$LOGFILE"
32 }
33 lockfile -l 3600 $LOCKCU
34 trap cleanup 0
35
36 rm -f "$NOTICE"
37 cat > "$NOTICE" <<EOF
38 Packages are currently being installed and indices rebuilt.
39 Maintenance is automatic, starting at 13:52 US Central time, and
40 ending at about 15:30.  This file is then removed.
41
42 You should not mirror the archive during this period.
43 EOF
44
45 # Push merkels qa user, so the qa pages can show "dinstall is running" information
46 echo "Telling merkels QA user that we start dinstall"
47 ssh -2 -i ~dak/.ssh/push_merkel_qa  -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 qa@merkel.debian.org sleep 1
48
49 ################################################################################
50
51 echo "Creating pre-daily-cron-job backup of projectb database..."
52 pg_dump projectb > $base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
53
54 ################################################################################
55
56 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
57 echo "Updating Bugs docu, Mirror list and mailing-lists.txt"
58 cd $configdir
59 $scriptsdir/update-bugdoctxt
60 $scriptsdir/update-mirrorlists
61 $scriptsdir/update-mailingliststxt
62
63 ################################################################################
64
65 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
66 echo "Doing automated p-u-new processing"
67 cd $queuedir/p-u-new
68 date -u -R >> REPORT
69 dak process-new -a -C COMMENTS >> REPORT
70 echo >> REPORT
71
72 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
73 echo "Doing automated o-p-u-new processing"
74 cd $queuedir/o-p-u-new
75 date -u -R >> REPORT
76 dak process-new -a -C COMMENTS >> REPORT
77 echo >> REPORT
78
79 ################################################################################
80
81 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
82 lockfile $LOCKAC
83 lockac=1
84 echo "Processing queue/accepted"
85 cd $accepted
86 rm -f REPORT
87 dak process-accepted -pa *.changes | tee REPORT | \
88      mail -s "Install for $(date +%D)" ftpmaster@ftp-master.debian.org
89 chgrp debadmin REPORT
90 chmod 664 REPORT
91
92 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
93 echo "Checking for cruft in overrides"
94 dak check-overrides
95 rm -f $LOCKAC
96 lockac=0
97
98 echo "Fixing symlinks in $ftpdir"
99 symlinks -d -r $ftpdir
100
101 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
102
103 echo "Generating suite file lists for apt-ftparchive"
104 dak make-suite-file-list
105
106 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
107
108 echo "Updating fingerprints"
109 # Update fingerprints
110 dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
111
112 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
113
114 # Generate override files
115 echo "Writing overrides into text files"
116 cd $overridedir
117 dak make-overrides
118
119 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
120
121 # FIXME
122 rm -f override.sid.all3
123 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
124
125 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
126
127 # Generate Packages and Sources files
128 echo "Generating Packages and Sources files"
129 cd $configdir
130 apt-ftparchive generate apt.conf
131 # Generate *.diff/ incremental updates
132
133 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
134
135 echo "Generating pdiff files"
136 dak generate-index-diffs
137
138 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
139
140 # Generate Release files
141 echo "Generating Release files"
142 dak generate-releases
143
144 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
145
146 # Clean out old packages
147 echo "Cleanup old packages/files"
148 dak clean-suites
149 dak clean-queues
150
151 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
152
153 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
154 # update this before wanna-build is updated.
155 echo "Regenerating wanna-build/buildd information"
156 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
157 symlinks -d /srv/incoming.debian.org/buildd > /dev/null
158 apt-ftparchive generate apt.conf.buildd
159
160 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
161
162 echo "Running various scripts from $scriptsdir"
163 cd $scriptsdir
164 ./mkmaintainers
165 ./copyoverrides
166 ./mklslar
167 ./mkfilesindices
168 ./mkchecksums
169 #
170 rm -f $NOTICE
171
172 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
173
174 echo "Trigger daily wanna-build run"
175 ssh buildd@buildd /org/wanna-build/trigger.daily
176
177 rm -f $LOCKCU
178 echo Archive maintenance finished at $(date +%X)
179
180 ################################################################################
181
182 echo "Creating post-daily-cron-job backup of projectb database..."
183 POSTDUMP=$base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
184 pg_dump projectb > $POSTDUMP
185 (cd $base/backup; ln -sf $POSTDUMP current)
186
187 ################################################################################
188
189 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
190
191 echo "Expiring old database dumps..."
192 (cd $base/backup; $scriptsdir/expire_dumps -d . -p -f "dump_*")
193
194 ################################################################################
195
196 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
197
198 # Send a report on NEW/BYHAND packages
199 echo "Nagging ftpteam about NEW/BYHAND packages"
200 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
201 # and one on crufty packages
202 echo "Sending information about crufty packages"
203 dak cruft-report > $webdir/cruft-report-daily.txt
204 dak cruft-report -s experimental >> $webdir/cruft-report-daily.txt
205 cat $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
206
207 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
208
209 echo "Updating DM html page"
210 $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
211
212 ################################################################################
213
214 # Push katie@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
215 echo "Trigger merkels projectb sync"
216 ssh -2 -i ~/.ssh/push_merkel_projectb katie@merkel.debian.org sleep 1
217
218 ################################################################################
219
220 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
221
222 ulimit -m 90000 -d 90000 -s 10000 -v 200000
223
224 echo "Using run-parts to run scripts in $base/scripts/distmnt"
225 run-parts --report $base/scripts/distmnt
226
227 echo "Daily cron scripts successful."
228
229 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
230
231 # Stats pr0n
232 echo "Updating stats data"
233 cd $configdir
234 $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
235 R --slave --vanilla < $base/misc/ftpstats.R
236
237 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
238
239 # Clean up apt-ftparchive's databases
240 echo "Clean up apt-ftparchive's databases"
241 cd $configdir
242 apt-ftparchive -q clean apt.conf
243
244 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
245
246 # Compress psql backups older than a week, but no more than 20 of them
247 echo "Compress old psql backups"
248 (cd $base/backup/
249  find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +7 | 
250    sort | head -n20 | while read dumpname; do
251      echo "Compressing $dumpname"
252      bzip2 -9 "$dumpname"
253    done
254 )
255
256 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
257
258 echo "Finally, all is done, sending mail and compressing logfile"
259 exec > /dev/null 2>&1
260
261 cat "$LOGFILE" | mail -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org
262 bzip2 -9 "$LOGFILE"
263
264 ################################################################################