7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
10 # $Id: gpg,v 1.6 2006/05/18 17:34:10 mlhuang Exp $
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
22 if [ ! -f $PLC_ROOT_GPG_KEY_PUB -o ! -f $PLC_ROOT_GPG_KEY ] ; then
23 # Generate new GPG keyring
24 MESSAGE=$"Generating GPG keys"
27 mkdir -p $(dirname $PLC_ROOT_GPG_KEY_PUB)
28 mkdir -p $(dirname $PLC_ROOT_GPG_KEY)
30 # Temporarily replace /dev/random with /dev/urandom to
31 # avoid running out of entropy.
33 mknod /dev/random c 1 9
34 gpg --homedir=/root --no-tty --yes \
35 --batch --gen-key <<EOF
40 Name-Real: $PLC_NAME Central
41 Name-Comment: http://$PLC_WWW_HOST/
42 Name-Email: $PLC_MAIL_SUPPORT_ADDRESS
44 %pubring $PLC_ROOT_GPG_KEY_PUB
45 %secring $PLC_ROOT_GPG_KEY
50 mknod /dev/random c 1 8
51 chmod 644 $PLC_ROOT_GPG_KEY_PUB
52 chmod 600 $PLC_ROOT_GPG_KEY
55 MESSAGE=$"Updating GPG keys"
58 # Get the current GPG fingerprint and comment
61 while read -a fields ; do
62 if [ "${fields[0]}" = "pub" ] ; then
63 fingerprint=${fields[4]}
67 gpg --homedir=/etc/planetlab --no-permission-warning --no-tty --yes \
68 --list-public-keys --with-colons
73 # Add a new UID if appropriate. GPG will detect and merge duplicates.
74 gpg --homedir=/etc/planetlab --no-permission-warning --no-tty --yes \
75 --command-fd 0 --status-fd 1 --edit-key $fingerprint <<EOF
78 $PLC_MAIL_SUPPORT_ADDRESS
85 # Install the key in the RPM database
86 mkdir -p /etc/pki/rpm-gpg
87 gpg --homedir=/etc/planetlab --no-permission-warning --no-tty --yes \
88 --export --armor >"/etc/pki/rpm-gpg/RPM-GPG-KEY-$PLC_NAME"
90 if rpm -q gpg-pubkey ; then
91 rpm --allmatches -e gpg-pubkey
94 rpm --import /etc/pki/rpm-gpg/*