Publish gpg key from user control panel

This commit is contained in:
Bob Mottram 2016-02-27 12:33:46 +00:00
parent 8f02e9c434
commit 166e7c28ba
1 changed files with 21 additions and 12 deletions

View File

@ -34,6 +34,7 @@ export TEXTDOMAIN=${PROJECT_NAME}-controlpanel-user
export TEXTDOMAINDIR="/usr/share/locale"
MY_EMAIL_ADDRESS=$USER@$HOSTNAME
GPG_ID=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
function any_key {
echo ' '
@ -347,7 +348,6 @@ function block_unblock_subject {
}
function show_gpg_key {
GPG_ID=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
GPG_FINGERPRINT=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "key fingerprint" | head -n 1 | awk -F '= ' '{print $2}')
GPG_DATE=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $2}')
dialog --title $"Your PGP/GPG Key" \
@ -355,6 +355,13 @@ function show_gpg_key {
--msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70
}
function publish_gpg_key {
gpg --send-key $GPG_ID
any_key
dialog --title $"Publish your PGP/GPG key" \
--msgbox $"Your key has now been published" 6 40
}
function add_gpg_key {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
@ -476,13 +483,14 @@ function menu_encryption_keys {
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone User Control Panel" \
--title $"Your Encryption Keys" \
--radiolist $"Choose an operation:" 14 70 6 \
--radiolist $"Choose an operation:" 15 70 7 \
1 $"Show your PGP/GPG key" off \
2 $"Add someone's PGP/GPG key" off \
3 $"Remove someone's PGP/GPG key" off \
4 $"Add an ssh key for logging in" off \
5 $"Remove an ssh key for logging in" off \
6 $"Back to main menu" on 2> $data
2 $"Publish your PGP/GPG key so that others can find it" off \
3 $"Add someone's PGP/GPG key" off \
4 $"Remove someone's PGP/GPG key" off \
5 $"Add an ssh key for logging in" off \
6 $"Remove an ssh key for logging in" off \
7 $"Back to main menu" on 2> $data
sel=$?
case $sel in
1) break;;
@ -490,11 +498,12 @@ function menu_encryption_keys {
esac
case $(cat $data) in
1) show_gpg_key;;
2) add_gpg_key;;
3) remove_gpg_key;;
4) add_ssh_key;;
5) remove_ssh_key;;
6) break;;
2) publish_gpg_key;;
3) add_gpg_key;;
4) remove_gpg_key;;
5) add_ssh_key;;
6) remove_ssh_key;;
7) break;;
esac
done
}