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