blob: 35c9959b134dde6a56d945996369c1094eed7d60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!/bin/bash
# Export keys to keyrings
#
# TODO:
# - only run the export if there was really a change
# - requires keeping state to detect changes in keys, there is no usable mtime data in a key itself
OUTPUT_DIR=${1:-.}
BASEDIR="$(dirname "$0")"
# shellcheck source=./keyrings.inc.bash
source "${BASEDIR}"/keyrings.inc.bash
set -e
export_ldap_data_to_env
export -a COMMITTING_DEVS=( $(grab_ldap_fingerprints -b "${DEV_BASE}" "${COMMIT_RULE}") )
export -a NONCOMMITTING_DEVS=( $(grab_ldap_fingerprints -b "${DEV_BASE}" "${NONCOMMIT_RULE}") )
export -a RETIRED_DEVS=( $(grab_ldap_fingerprints -b "${DEV_BASE}" "${RETIRED_RULE}") )
export -a SYSTEM_KEYS=( $(grab_ldap_fingerprints -b "${SYSTEM_BASE}" "${NONCOMMIT_RULE}") )
export -a INFRA_SYSTEM_KEYS=( $(grab_ldap_fingerprints -b "${SYSTEM_BASE}" "${INFRA_SYSTEM_RULE}") )
export_keys "${OUTPUT_DIR}"/keys/service-keys.gpg \
"${SYSTEM_KEYS[@]}"
export_keys "${OUTPUT_DIR}"/keys/infra-service-keys.gpg \
"${INFRA_SYSTEM_KEYS[@]}"
export_keys "${OUTPUT_DIR}"/keys/committing-devs.gpg \
"${COMMITTING_DEVS[@]}"
export_keys "${OUTPUT_DIR}"/keys/active-devs.gpg \
"${COMMITTING_DEVS[@]}" \
"${NONCOMMITTING_DEVS[@]}"
export_keys "${OUTPUT_DIR}"/keys/infra-devs.gpg \
"${INFRA_DEVS[@]}"
export_keys "${OUTPUT_DIR}"/keys/retired-devs.gpg \
"${RETIRED_DEVS[@]}"
# Everybody together now
export_keys "${OUTPUT_DIR}"/keys/all-devs.gpg \
"${SYSTEM_KEYS[@]}" \
"${COMMITTING_DEVS[@]}" \
"${NONCOMMITTING_DEVS[@]}" \
"${INFRA_DEVS[@]}" \
"${RETIRED_DEVS[@]}"
for key in service-keys committing-devs active-devs infra-devs retired-devs all-devs ; do
if [[ ! -L "${OUTPUT_DIR}"/${key}.gpg ]] ; then
# Compatibility symlink
ln -s "${OUTPUT_DIR}"/keys/${key}.gpg "${OUTPUT_DIR}"/${key}.gpg
fi
timestamp=$(date -u +%Y%m%d-%A -d "monday")
if [[ ${timestamp} != *-Monday ]] ; then
break
fi
timestamp=${timestamp/-Monday/}
# Don't clobber existing timestamped keys for this period (weekly)
# if we're running several times a day.
if [[ -f "${OUTPUT_DIR}"/keys/${key}-${timestamp}.gpg ]] ; then
continue
fi
mkdir -p "${OUTPUT_DIR}"/keys
cp "${OUTPUT_DIR}"/${key}.gpg "${OUTPUT_DIR}"/keys/${key}-${timestamp}.gpg
done
clean_tmp
|