summaryrefslogtreecommitdiffstats
path: root/tests/openpgp/mkdemodirs
blob: 217908078b8985dee27d7bb76ace2924d5fd5ab9 (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
#!/bin/sh

set -e

GPG="../g10/gpg2 --batch --quiet --no-secmem-warning --allow-secret-key-import"
NAMES='Alpha Bravo Charlie Delta Echo Foxtrot Golf Hotel India
       Juliet Kilo Lima Mike November Oscar Papa Quebec Romeo
       Sierra Tango Uniform Victor Whisky XRay Yankee Zulu'

if [ "$1" = "--clean" ]; then
    (for i in $NAMES; do
	[ -d $i ] && rm -r $i
    done) || true
    exit 0
fi

$GPG --dearmor -o secdemo.gpg --yes ../checks/secdemo.asc
$GPG --dearmor -o pubdemo.gpg --yes ../checks/pubdemo.asc
[ -f ./tdb.tmp ] && rm ./tdb.tmp
GPGDEMO="$GPG --homedir . --trustdb-name ./tdb.tmp --no-default-keyring
	 --keyring pubdemo.gpg --secret-keyring secdemo.gpg"
echo -n "Creating:"
for name in $NAMES; do
    echo -n " $name"
    [ -d $name ] && rm -r $name
    mkdir $name
    $GPGDEMO --export-secret-key -o - $name > $name/Secret.gpg
    $GPG --homedir $name --import $name/Secret.gpg
    $GPGDEMO --export -o - $name > $name/Public.gpg
    $GPG --homedir $name --import $name/Public.gpg
    [ -f $name/pubring.gpg~ ] && rm $name/pubring.gpg~
done
echo "."
[ -f ./tdb.tmp ] && rm ./tdb.tmp
rm pubdemo.gpg secdemo.gpg