瀏覽代碼

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 7 年之前
父節點
當前提交
e3deced621
共有 4 個檔案被更改,包括 95 行新增4 行删除
  1. 25
    2
      src/freedombone-app-scuttlebot
  2. 18
    2
      src/freedombone-controlpanel-user
  3. 39
    0
      src/freedombone-utils-gpg
  4. 13
    0
      src/freedombone-utils-keys

+ 25
- 2
src/freedombone-app-scuttlebot 查看文件

@@ -361,15 +361,38 @@ function scuttlebot_git_setup {
361 361
     fi
362 362
 }
363 363
 
364
+function mesh_install_dat {
365
+    get_npm_arch
366
+
367
+    cat <<EOF > $rootdir/usr/bin/install_dat
368
+#!/bin/bash
369
+npm install --arch=$NPM_ARCH -g dat
370
+npm install --arch=$NPM_ARCH -g @garbados/dat-boi
371
+npm install --arch=$NPM_ARCH -g add-to-systemd
372
+add-to-systemd dat-boi --user $(whoami) `which dat-boi`
373
+EOF
374
+    chroot "$rootdir" /bin/chmod +x /usr/bin/install_dat
375
+    chroot "$rootdir" /usr/bin/install_dat
376
+    rm $rootdir/usr/bin/install_dat
377
+}
378
+
379
+function install_dat {
380
+    npm install -g dat
381
+    npm install -g @garbados/dat-boi
382
+    npm install -g add-to-systemd
383
+    add-to-systemd dat-boi --user $(whoami) `which dat-boi`
384
+}
385
+
364 386
 function mesh_install_scuttlebot {
365 387
     SCUTTLEBOT_ONION_HOSTNAME=
366 388
 
389
+    mesh_install_dat
390
+
367 391
     get_npm_arch
368 392
 
369 393
     cat <<EOF > $rootdir/usr/bin/install_scuttlebot
370 394
 #!/bin/bash
371 395
 npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION}
372
-npm install --arch=$NPM_ARCH -g dat
373 396
 npm install --arch=$NPM_ARCH -g git-ssb
374 397
 npm install --arch=$NPM_ARCH -g git-remote-ssb
375 398
 EOF
@@ -420,7 +443,7 @@ function install_scuttlebot {
420 443
         exit 528253
421 444
     fi
422 445
 
423
-    npm install -g dat
446
+    install_dat
424 447
     npm install -g git-ssb
425 448
     npm install -g git-remote-ssb
426 449
 

+ 18
- 2
src/freedombone-controlpanel-user 查看文件

@@ -37,6 +37,19 @@ MY_EMAIL_ADDRESS=$USER@$HOSTNAME
37 37
 GPG_ID=$(gpg --list-keys $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
38 38
 GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
39 39
 
40
+# If the default key is specified within gpg.conf
41
+if [ -f ~/.gnupg/gpg.conf ]; then
42
+    if grep -q "default-key" ~/.gnupg/gpg.conf; then
43
+        default_gpg_key=$(cat ~/.gnupg/gpg.conf | grep "default-key")
44
+        if [[ "$default_gpg_key" != *'#'* ]]; then
45
+            default_gpg_key=$(cat ~/.gnupg/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
46
+            if [ ${#default_gpg_key} -gt 3 ]; then
47
+                GPG_ID=$(gpg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
48
+            fi
49
+        fi
50
+    fi
51
+fi
52
+
40 53
 # Start including files
41 54
 
42 55
 UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
@@ -402,8 +415,8 @@ function block_unblock_subject {
402 415
 }
403 416
 
404 417
 function show_gpg_key {
405
-    GPG_FINGERPRINT=$(gpg --fingerprint $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
406
-    GPG_DATE=$(gpg --fingerprint $MY_EMAIL_ADDRESS | grep -i "pub" | head -n 1 | awk -F ' ' '{print $3}')
418
+    GPG_FINGERPRINT=$(gpg --fingerprint $GPG_ID | sed -n '2p' | sed 's/^[ \t]*//')
419
+    GPG_DATE=$(gpg --fingerprint $GPG_ID | grep -i "pub" | head -n 1 | awk -F ' ' '{print $3}')
407 420
     dialog --title $"My PGP/GPG Key" \
408 421
            --backtitle $"Freedombone User Control Panel" \
409 422
            --msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70
@@ -415,6 +428,9 @@ function show_full_gpg_key {
415 428
     echo ''
416 429
     echo ''
417 430
     gpg --armor --export $GPG_ID
431
+    echo ''
432
+    echo ''
433
+    echo ''
418 434
     gpg --armor --export-secret-key $GPG_ID
419 435
     any_key
420 436
 }

+ 39
- 0
src/freedombone-utils-gpg 查看文件

@@ -38,6 +38,19 @@ function gpg_update_mutt {
38 38
     CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME
39 39
     CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
40 40
 
41
+    # If the default key is specified within gpg.conf
42
+    if [ -f /home/$key_username/gpg.conf ]; then
43
+        if grep -q "default-key" /home/$key_username/gpg.conf; then
44
+            default_gpg_key=$(cat /home/$key_username/gpg.conf | grep "default-key")
45
+            if [[ "$default_gpg_key" != *'#'* ]]; then
46
+                default_gpg_key=$(cat /home/$key_username/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
47
+                if [ ${#default_gpg_key} -gt 3 ]; then
48
+                    CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
49
+                fi
50
+            fi
51
+        fi
52
+    fi
53
+
41 54
     sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
42 55
     sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
43 56
 
@@ -249,8 +262,34 @@ function gpg_pubkey_from_email {
249 262
     key_id=
250 263
     if [[ $key_owner_username != "root" ]]; then
251 264
         key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
265
+
266
+        # If the default key is specified within gpg.conf
267
+        if [ -f /home/$key_owner_username/gpg.conf ]; then
268
+            if grep -q "default-key" /home/$key_owner_username/gpg.conf; then
269
+                default_gpg_key=$(cat /home/$key_owner_username/gpg.conf | grep "default-key")
270
+                if [[ "$default_gpg_key" != *'#'* ]]; then
271
+                    default_gpg_key=$(cat /home/$key_owner_username/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
272
+                    if [ ${#default_gpg_key} -gt 3 ]; then
273
+                        key_id=$(su -c "gpg --list-keys $default_gpg_key" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
274
+                    fi
275
+                fi
276
+            fi
277
+        fi
252 278
     else
253 279
         key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//')
280
+
281
+        # If the default key is specified within gpg.conf
282
+        if [ -f /root/gpg.conf ]; then
283
+            if grep -q "default-key" /root/gpg.conf; then
284
+                default_gpg_key=$(cat /root/gpg.conf | grep "default-key")
285
+                if [[ "$default_gpg_key" != *'#'* ]]; then
286
+                    default_gpg_key=$(cat /root/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
287
+                    if [ ${#default_gpg_key} -gt 3 ]; then
288
+                        key_id=$(gpg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
289
+                    fi
290
+                fi
291
+            fi
292
+        fi
254 293
     fi
255 294
     echo $key_id
256 295
 }

+ 13
- 0
src/freedombone-utils-keys 查看文件

@@ -101,6 +101,19 @@ function interactive_gpg_from_usb {
101 101
             CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
102 102
             CURR_GPG_BACKUP_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
103 103
 
104
+            # If the default key is specified within gpg.conf
105
+            if [ -f $HOME_DIR/gpg.conf ]; then
106
+                if grep -q "default-key" $HOME_DIR/gpg.conf; then
107
+                    default_gpg_key=$(cat $HOME_DIR/gpg.conf | grep "default-key")
108
+                    if [[ "$default_gpg_key" != *'#'* ]]; then
109
+                        default_gpg_key=$(cat $HOME_DIR/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
110
+                        if [ ${#default_gpg_key} -gt 3 ]; then
111
+                            CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
112
+                        fi
113
+                    fi
114
+                fi
115
+            fi
116
+
104 117
             echo $'Making backup copy of existing gpg keys'
105 118
             if [ -d $HOME_DIR/.gnupg ]; then
106 119
                 if [ -d $HOME_DIR/.gnupg_old ]; then