]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.daily
changes for DM support
[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 # [JT - disabled, dak import-ldap-fingerprints currently can ask questions]
93 #dak import-ldap-fingerprints
94
95 # Generate override files
96 cd $overridedir
97 dak make-overrides
98
99 # Update task overrides for testing and unstable
100 # [JT 2004-02-04 disabled; copying in by hand for now]
101 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sarge.extra.main
102 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sid.extra.main
103
104 # FIXME
105 rm -f override.sid.all3
106 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
107
108 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
109
110 # Generate Packages and Sources files
111 cd $configdir
112 apt-ftparchive generate apt.conf
113 # Generate *.diff/ incremental updates
114 dak generate-index-diffs
115 # Generate Release files
116 dak generate-releases
117
118 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
119
120 # Clean out old packages
121 dak clean-suites
122 dak clean-queues
123
124 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
125
126 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
127 # update this before wanna-build is updated.
128 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
129 symlinks -d /srv/incoming.debian.org/buildd > /dev/null
130 apt-ftparchive generate apt.conf.buildd
131
132 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
133
134 cd $scriptsdir
135 ./mkmaintainers
136 ./copyoverrides
137 ./mklslar
138 ./mkfilesindices
139 ./mkchecksums
140 #
141 # Fetch bugs information before unchecked processing is allowed again.
142 $base/testing/britney allowdaklock bugs || true
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 echo "VACUUM; VACUUM ANALYZE;" | psql projectb 2>&1 | grep -v "^NOTICE:  Skipping.*only table owner can VACUUM it$"
162
163 ################################################################################
164
165 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
166
167 # Send a report on NEW/BYHAND packages
168 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
169 # and one on crufty packages
170 dak cruft-report | tee $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
171
172 $scriptsdir/dm-monitor >$webdir/dm-uploaders.html
173
174 ################################################################################
175
176 # Run mirror-split
177
178 #time dak mirror-split
179
180 ################################################################################
181
182 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
183
184 ulimit -m 90000 -d 90000 -s 10000 -v 200000
185
186 run-parts --report $base/scripts/distmnt
187
188 echo Daily cron scripts successful.
189
190 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
191
192 # Stats pr0n
193 cd $configdir
194 $scriptsdir/update-ftpstats $base/log/* > $base/misc/ftpstats.data
195 R --slave --vanilla < $base/misc/ftpstats.R
196
197 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
198
199 # Clean up apt-ftparchive's databases
200
201 cd $configdir
202 apt-ftparchive -q clean apt.conf
203
204 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
205
206 # Compress psql backups older than a month, but no more than 20 of them
207
208 (cd $base/backup/
209  find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +30 | 
210    sort | head -n20 | while read dumpname; do
211      echo "Compressing $dumpname"
212      bzip2 -9 "$dumpname"
213    done
214 )
215
216 ################################################################################