]> git.decadent.org.uk Git - dak.git/blob - config/debian/cron.daily
Make contributor submissions work again
[dak.git] / config / debian / cron.daily
1 #! /bin/bash
2 #
3 # Run daily via cron, out of dak's crontab.
4
5 set -e
6 set -o pipefail
7 set -u
8 export SCRIPTVARS=/srv/ftp-master.debian.org/dak/config/debian/vars
9 . $SCRIPTVARS
10
11 # common functions are "outsourced"
12 . "${configdir}/common"
13
14 ################################################################################
15
16 TMPFILE=$( mktemp -p ${TMPDIR} )
17 TMPCNTB=$( mktemp -p ${TMPDIR} )
18
19 function cleanup {
20     ERRVAL=$?
21     rm -f ${TMPFILE} ${TMPCNTB}
22     exit ${ERRVAL}
23 }
24 trap cleanup SIGHUP SIGINT SIGPIPE SIGTERM EXIT ERR
25
26 # log to dinstall's logfile instead of sending email
27 PROGRAM="cron.daily"
28 # Start logging
29 NOW=`date "+%Y.%m.%d-%H:%M:%S"`
30 LOGFILE="$logdir/daily_${NOW}.log"
31 exec >> "$LOGFILE" 2>&1
32
33 # get the latest list of wnpp bugs and their source packages
34 wget -q -O${TMPFILE} --ca-directory=/etc/ssl/ca-debian https://qa.debian.org/data/bts/wnpp_rm
35 chmod go+r ${TMPFILE}
36 mv ${TMPFILE} /srv/ftp-master.debian.org/scripts/masterfiles/wnpp_rm
37
38 # Push files over to security
39 # The key over there should have the following set for the ssh key:
40 #  command="/usr/bin/xzcat | /usr/bin/psql -1 -c 'DELETE FROM external_files; COPY external_files (id, filename, size, md5sum, last_used, sha1sum, sha256sum, created, modified) FROM STDIN' obscurity"
41 psql -c 'COPY files (id, filename, size, md5sum, last_used, sha1sum, sha256sum, created, modified) TO STDOUT' projectb | \
42             xz -3 | \
43             ssh -o BatchMode=yes -o ConnectTimeout=30 -o SetupTimeout=30 -2 \
44                 -i ${base}/s3kr1t/push_external_files dak@security-master.debian.org sync
45
46 # Update wanna-build dump
47 log "Update wanna-build database dump"
48 $base/dak/scripts/nfu/get-w-b-db
49
50 reports
51
52 clean_debbugs
53
54 # Generate list of override disparities
55 dak override-disparity | gzip -9 > ${webdir}/override-disparity.gz
56
57 # Generate stats about the new queue
58 dak stats new ${webdir}/NEW-stats.yaml 2> /dev/null
59
60 # Generate the contributor data
61 # FIXME: In a day or three, when this worked from cron without
62 # failure, redirect its output to dev/null. Alternatively until then
63 # enrico added a --quiet and we use that.
64 log "Submitting data to contributors"
65 REQUESTS_CA_BUNDLE=/etc/ssl/ca-debian/ca-certificates.crt dc-tool --mine="${configdir}/contributor.source" --auth-token @"${base}/s3kr1t/contributor.auth" --source ftp.debian.org --json > ${TMPCNTB}
66
67 # Post with curl as a workaround for #801506
68 # See https://wiki.debian.org/ServicesSSL#curl
69 dir=/etc/ssl/ca-debian
70 test -d $dir && capath="--capath $dir"
71 curl -s $capath https://contributors.debian.org/contributors/post \
72     -F source=ftp.debian.org \
73     -F auth_token="$(cat ${base}/s3kr1t/contributor.auth)" \
74     -F data=@${TMPCNTB} > ${TMPCNTB}.result
75 cat ${TMPCNTB}.result
76 rm -f ${TMPCNTB}.result
77
78
79 ${scriptsdir}/link_morgue.sh
80
81 ################################################################################
82
83 log "Finally, all is done, compressing logfile"
84 exec > /dev/null 2>&1
85
86 bzip2 -9 "$LOGFILE"