]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.daily
Remove britney call
[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 # Push merkels qa user, so the qa pages can show "dinstall is running" information
39 ssh -2 -i ~dak/.ssh/push_merkel_qa  -o BatchMode=yes -o SetupTimeOut=30 -o ConnectTimeout=30 qa@merkel.debian.org sleep 1
40
41 ################################################################################
42
43 echo "Creating pre-daily-cron-job backup of projectb database..."
44 pg_dump projectb > $base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
45
46 ################################################################################
47
48 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
49 cd $configdir
50 $scriptsdir/update-bugdoctxt
51 $scriptsdir/update-mirrorlists
52 $scriptsdir/update-mailingliststxt
53
54 ################################################################################
55
56 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
57 cd $queuedir/p-u-new
58 date -u -R >> REPORT
59 dak process-new -a -C COMMENTS >> REPORT
60 echo >> REPORT
61
62 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
63 cd $queuedir/o-p-u-new
64 date -u -R >> REPORT
65 dak process-new -a -C COMMENTS >> REPORT
66 echo >> REPORT
67
68 ################################################################################
69
70 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
71 lockfile $LOCKAC
72 lockac=1
73 cd $accepted
74 rm -f REPORT
75 dak process-accepted -pa *.changes | tee REPORT | \
76      mail -s "Install for $(date +%D)" ftpmaster@ftp-master.debian.org
77 chgrp debadmin REPORT
78 chmod 664 REPORT
79
80 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
81
82 dak check-overrides
83 rm -f $LOCKAC
84 lockac=0
85
86 symlinks -d -r $ftpdir
87
88 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
89
90 dak make-suite-file-list
91
92 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
93
94 # Update fingerprints
95 dak import-keyring -L /srv/keyring.debian.org/keyrings/debian-keyring.gpg
96
97 # Generate override files
98 cd $overridedir
99 dak make-overrides
100
101 # Update task overrides for testing and unstable
102 # [JT 2004-02-04 disabled; copying in by hand for now]
103 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sarge.extra.main
104 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sid.extra.main
105
106 # FIXME
107 rm -f override.sid.all3
108 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
109
110 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
111
112 # Generate Packages and Sources files
113 cd $configdir
114 apt-ftparchive generate apt.conf
115 # Generate *.diff/ incremental updates
116 dak generate-index-diffs
117 # Generate Release files
118 dak generate-releases
119
120 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
121
122 # Clean out old packages
123 dak clean-suites
124 dak clean-queues
125
126 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
127
128 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
129 # update this before wanna-build is updated.
130 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
131 symlinks -d /srv/incoming.debian.org/buildd > /dev/null
132 apt-ftparchive generate apt.conf.buildd
133
134 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
135
136 cd $scriptsdir
137 ./mkmaintainers
138 ./copyoverrides
139 ./mklslar
140 ./mkfilesindices
141 ./mkchecksums
142 #
143 rm -f $NOTICE
144 ssh buildd@buildd /org/wanna-build/trigger.daily
145
146 rm -f $LOCKCU
147 echo Archive maintenance finished at $(date +%X)
148
149 ################################################################################
150
151 echo "Creating post-daily-cron-job backup of projectb database..."
152 POSTDUMP=$base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
153 pg_dump projectb > $POSTDUMP
154 (cd $base/backup; ln -sf $POSTDUMP current)
155
156 ################################################################################
157
158 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
159
160 # Vacuum the database
161 # (JJ, 20-04-2008) disabled, as we have autovacuum set to on in postgres.
162 # refer to http://www.postgresql.org/docs/current/static/routine-vacuuming.html#AUTOVACUUM
163 # which says "Beginning in PostgreSQL 8.1, there is an optional feature called autovacuum,
164 # whose purpose is to automate the execution of VACUUM and ANALYZE  commands."
165 # echo "VACUUM; VACUUM ANALYZE;" | psql projectb 2>&1 | grep -v "^NOTICE:  Skipping.*only table owner can VACUUM it$"
166
167 echo "Expiring old database dumps..."
168 (cd $base/backup; $scriptsdir/expire_dumps -d . -p -f "dump_*")
169
170 ################################################################################
171
172 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
173
174 # Send a report on NEW/BYHAND packages
175 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
176 # and one on crufty packages
177 dak cruft-report > $webdir/cruft-report-daily.txt
178 dak cruft-report -s experimental >> $webdir/cruft-report-daily.txt
179 cat $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
180
181 $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
182
183 ################################################################################
184
185 # Push katie@merkel so it syncs the projectb there. Returns immediately, the sync runs detached
186 ssh -2 -i ~/.ssh/push_merkel_projectb katie@merkel.debian.org sleep 1
187
188 # Run mirror-split
189
190 #time dak mirror-split
191
192 ################################################################################
193
194 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
195
196 ulimit -m 90000 -d 90000 -s 10000 -v 200000
197
198 run-parts --report $base/scripts/distmnt
199
200 echo Daily cron scripts successful.
201
202 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
203
204 # Stats pr0n
205 cd $configdir
206 $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
207 R --slave --vanilla < $base/misc/ftpstats.R
208
209 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
210
211 # Clean up apt-ftparchive's databases
212
213 cd $configdir
214 apt-ftparchive -q clean apt.conf
215
216 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
217
218 # Compress psql backups older than a week, but no more than 20 of them
219
220 (cd $base/backup/
221  find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +7 | 
222    sort | head -n20 | while read dumpname; do
223      echo "Compressing $dumpname"
224      bzip2 -9 "$dumpname"
225    done
226 )
227
228 ################################################################################