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