summaryrefslogtreecommitdiff
path: root/gen-new-key
blob: f1268814c8ab16b4805ae00c92d558e906ce815c (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
#!/bin/bash

verwendung() {
  printf 'Verwendung:\n'
  printf '  gen-new-key packager\n'
  printf '    generiere neuen Packager-Schlüssel\n'
  printf '  gen-new-key repo\n'
  printf '    generiere neuen Repository-Schlüssel\n'
  exit 1
}

if [ $# -ne 1 ]; then
  verwendung
fi

if [ "$1" = 'packager' ]; then
  comment='just to sign arch packages'
elif [ "$1" = 'repo' ]; then
  comment='just to sign arch repos'
else
  verwendung
fi

if ! gpg --list-secret-keys "${comment}" >/dev/null 2>&1; then
  printf 'There is no secret key yet with comment "%s" - I guess, you are running this on the wrong box.\n' "${comment}"
  exit 1
fi

{
  printf '%s\n' \
    '%echo Generating a basic OpenPGP key' \
    'Key-Type: RSA' \
    'Key-Length: 4096' \
    'Key-Usage: sign' \
    'Subkey-Type: RSA' \
    'Subkey-Length: 4096' \
    'Subkey-Usage: sign' \
    'Name-Real: Erich Eckner'
  printf 'Name-Comment: %s\n' \
    "${comment}"
  printf '%s\n' \
    'Name-Email: arch@eckner.net' \
    'Expire-Date: 2y' \
    '%no-protection' \
    '%no-ask-passphrase' \
    '%commit' \
    '%echo done'
} | \
  gpg --gen-key --batch