Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/update-gpg-keys
blob: 5a37e78d8ca717dc47f1288fe4f3fab699935bed (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
#!/bin/sh

# shellcheck source=../lib/load-configuration
. "${0%/*}/../lib/load-configuration"

if [ $# -ne 0 ]; then
  >&2 echo 'error: No arguments expected, but some were given.'
  exit 1
fi

# shellcheck disable=SC2016
{
  printf 'SELECT'
  printf ' `gpg_keys`.`fingerprint`,'
  printf 'replace(to_base64(`gpg_keys`.`public_key`),"\\n","")'
  printf ' FROM `gpg_keys`'
} \
| mysql_run_query \
| while read -r fingerprint public_key; do
  printf '%s\n' "${public_key}" \
  | base64 -d \
  | gpg --import \
  >/dev/null 2>&1
  gpg --quiet --locate-keys "${fingerprint}" \
  >/dev/null 2>&1 \
  || true
  curl -Ss 'https://archlinux32.org/keys.php?k='"${fingerprint}" \
  | gpg --import --quiet \
  >/dev/null 2>&1 \
  || true
  gpg -a --export "${fingerprint}" \
  | curl -T - 'https://archlinux32.org/keys.php' \
  >/dev/null 2>&1
  printf 'UPDATE `gpg_keys`'
  printf ' SET `gpg_keys`.`public_key`=from_base64("%s")' \
    "$(
      gpg -a --export "${fingerprint}" \
      | base64 -w0
    )"
  printf ' WHERE `gpg_keys`.`fingerprint`="%s";\n' \
    "${fingerprint}"
done \
| mysql_run_query