浏览代码

Publish gpg key from user control panel

Bob Mottram 9 年前
父节点
当前提交
166e7c28ba
共有 1 个文件被更改,包括 21 次插入12 次删除
  1. 21
    12
      src/freedombone-controlpanel-user

+ 21
- 12
src/freedombone-controlpanel-user 查看文件

@@ -34,6 +34,7 @@ export TEXTDOMAIN=${PROJECT_NAME}-controlpanel-user
34 34
 export TEXTDOMAINDIR="/usr/share/locale"
35 35
 
36 36
 MY_EMAIL_ADDRESS=$USER@$HOSTNAME
37
+GPG_ID=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
37 38
 
38 39
 function any_key {
39 40
     echo ' '
@@ -347,7 +348,6 @@ function block_unblock_subject {
347 348
 }
348 349
 
349 350
 function show_gpg_key {
350
-    GPG_ID=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
351 351
     GPG_FINGERPRINT=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "key fingerprint" | head -n 1 | awk -F '= ' '{print $2}')
352 352
     GPG_DATE=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F '/' '{print $2}' | awk -F ' ' '{print $2}')
353 353
     dialog --title $"Your PGP/GPG Key" \
@@ -355,6 +355,13 @@ function show_gpg_key {
355 355
            --msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70
356 356
 }
357 357
 
358
+function publish_gpg_key {
359
+    gpg --send-key $GPG_ID
360
+    any_key
361
+    dialog --title $"Publish your PGP/GPG key" \
362
+           --msgbox $"Your key has now been published" 6 40
363
+}
364
+
358 365
 function add_gpg_key {
359 366
     data=$(tempfile 2>/dev/null)
360 367
     trap "rm -f $data" 0 1 2 5 15
@@ -476,13 +483,14 @@ function menu_encryption_keys {
476 483
         trap "rm -f $data" 0 1 2 5 15
477 484
         dialog --backtitle $"Freedombone User Control Panel" \
478 485
                --title $"Your Encryption Keys" \
479
-               --radiolist $"Choose an operation:" 14 70 6 \
486
+               --radiolist $"Choose an operation:" 15 70 7 \
480 487
                1 $"Show your PGP/GPG key" off \
481
-               2 $"Add someone's PGP/GPG key" off \
482
-               3 $"Remove someone's PGP/GPG key" off \
483
-               4 $"Add an ssh key for logging in" off \
484
-               5 $"Remove an ssh key for logging in" off \
485
-               6 $"Back to main menu" on 2> $data
488
+               2 $"Publish your PGP/GPG key so that others can find it" off \
489
+               3 $"Add someone's PGP/GPG key" off \
490
+               4 $"Remove someone's PGP/GPG key" off \
491
+               5 $"Add an ssh key for logging in" off \
492
+               6 $"Remove an ssh key for logging in" off \
493
+               7 $"Back to main menu" on 2> $data
486 494
         sel=$?
487 495
         case $sel in
488 496
             1) break;;
@@ -490,11 +498,12 @@ function menu_encryption_keys {
490 498
         esac
491 499
         case $(cat $data) in
492 500
             1) show_gpg_key;;
493
-            2) add_gpg_key;;
494
-            3) remove_gpg_key;;
495
-            4) add_ssh_key;;
496
-            5) remove_ssh_key;;
497
-            6) break;;
501
+            2) publish_gpg_key;;
502
+            3) add_gpg_key;;
503
+            4) remove_gpg_key;;
504
+            5) add_ssh_key;;
505
+            6) remove_ssh_key;;
506
+            7) break;;
498 507
         esac
499 508
     done
500 509
 }