]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.daily
Fix up usage in cron scripts by adding new variable.
[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=/org/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
18 cleanup() {
19   rm -f "$NOTICE"
20   rm -f "$LOCKCU"
21 }
22 trap cleanup 0
23
24 rm -f "$NOTICE"
25 lockfile -l 3600 $LOCKCU
26 cat > "$NOTICE" <<EOF
27 Packages are currently being installed and indices rebuilt.
28 Maintenance is automatic, starting at 13:52 US Central time, and
29 ending at about 15:30.  This file is then removed.
30
31 You should not mirror the archive during this period.
32 EOF
33
34 ################################################################################
35
36 echo "Creating pre-daily-cron-job backup of projectb database..."
37 pg_dump projectb > /org/ftp.debian.org/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
38
39 ################################################################################
40
41 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
42 update-bugdoctxt
43 update-mirrorlists
44 update-mailingliststxt
45
46 ################################################################################
47
48 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
49 lockfile $LOCKAC
50 cd $accepted
51 rm -f REPORT
52 dak process-unchecked -pa *.changes | tee REPORT | \
53      mail -s "Install for $(date +%D)" ftpmaster@ftp-master.debian.org
54 chgrp debadmin REPORT
55 chmod 664 REPORT
56
57 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
58
59 dak check-overrides
60 rm -f $LOCKAC
61
62 symlinks -d -r $ftpdir
63
64 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
65
66 dak make-suite-file-list
67
68 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
69
70 # Update fingerprints
71 # [JT - disabled, dak import-ldap-fingerprints currently can ask questions]
72 #dak import-ldap-fingerprints
73
74 # Generate override files
75 cd $overridedir
76 dak make-overrides
77
78 # Update task overrides for testing and unstable
79 # [JT 2004-02-04 disabled; copying in by hand for now]
80 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sarge.extra.main
81 #cat $extoverridedir/task | perl -ne 'print if /^\S+\sTask\s\S+(,\s*\S+)*$/;' > override.sid.extra.main
82
83 # FIXME
84 rm -f override.potato.all3 override.sid.all3
85 for i in main contrib non-free; do cat override.potato.$i >> override.potato.all3; done
86 for i in main contrib non-free main.debian-installer; do cat override.sid.$i >> override.sid.all3; done
87
88 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
89
90 # Generate Packages and Sources files
91 cd $configdir
92 apt-ftparchive generate apt.conf
93 # Generate *.diff/ incremental updates
94 dak generate-index-diffs
95 # Generate Release files
96 dak generate-releases
97
98 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
99
100 # Clean out old packages
101 dak clean-suites
102 dak clean-queues
103
104 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
105
106 # Needs to be rebuilt, as files have moved.  Due to unaccepts, we need to
107 # update this before wanna-build is updated.
108 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
109 apt-ftparchive generate apt.conf.buildd
110
111 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
112
113 mkmaintainers
114 copyoverrides
115 mklslar
116 mkfilesindices
117 mkchecksums
118 #
119 # Fetch bugs information before unchecked processing is allowed again.
120 /org/ftp.debian.org/testing/britney bugs
121 rm -f $NOTICE
122 ssh buildd@buildd /org/wanna-build/trigger.daily
123
124 rm -f $LOCKCU
125 echo Archive maintenance finished at $(date +%X)
126
127 ################################################################################
128
129 echo "Creating post-daily-cron-job backup of projectb database..."
130 POSTDUMP=/org/ftp.debian.org/backup/dump_$(date +%Y.%m.%d-%H:%M:%S)
131 pg_dump projectb > $POSTDUMP
132 (cd /org/ftp.debian.org/backup; ln -sf $POSTDUMP current)
133
134 ################################################################################
135
136 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
137
138 # Vacuum the database
139 echo "VACUUM; VACUUM ANALYZE;" | psql projectb 2>&1 | grep -v "^NOTICE:  Skipping.*only table owner can VACUUM it$"
140
141 ################################################################################
142
143 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
144
145 # Send a report on NEW/BYHAND packages
146 dak queue-report | mail -e -s "NEW and BYHAND on $(date +%D)" ftpmaster@ftp-master.debian.org
147 # and one on crufty packages
148 dak cruft-report | tee $webdir/cruft-report-daily.txt | mail -e -s "Debian archive cruft report for $(date +%D)" ftpmaster@ftp-master.debian.org
149
150 ################################################################################
151
152 # Run mirror-split
153
154 #time dak mirror-split
155
156 ################################################################################
157
158 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
159
160 ulimit -m 90000 -d 90000 -s 10000 -v 90000
161
162 run-parts --report /org/ftp.debian.org/scripts/distmnt
163
164 echo Daily cron scripts successful.
165
166 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)
167
168 # Stats pr0n
169 update-ftpstats $base/log/* > $base/misc/ftpstats.data
170 R --slave --vanilla < $base/misc/ftpstats.R
171
172 TS=$(($TS+1)); echo Archive maintenance timestamp $TS: $(date +%X)