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