aboutsummaryrefslogtreecommitdiffstats
path: root/modules/gnupg/templates/create_gnupg_keys.sh
blob: a2caba2d037182987c494fd7efd173a0ddc39971 (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
#!/bin/bash

BATCHFILE="$1"
HOMEDIR="$2"
LOCK="$3"

test $# -eq 3 || exit 1

if [ -e "$LOCK" ]
then
    echo "Lock file already exist." 1>&2
    echo "Remove $LOCK if you want to regenerate key." 1>&2
    exit 2
fi

touch "$LOCK"

/sbin/rngd -f -r /dev/urandom &
RAND=$!
cd $HOMEDIR
gpg --homedir $HOMEDIR --batch --gen-key $BATCHFILE
EXIT=$?

kill $RAND

exit $EXIT