浏览代码

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
     fi
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
 function mesh_install_scuttlebot {
386
 function mesh_install_scuttlebot {
365
     SCUTTLEBOT_ONION_HOSTNAME=
387
     SCUTTLEBOT_ONION_HOSTNAME=
366
 
388
 
389
+    mesh_install_dat
390
+
367
     get_npm_arch
391
     get_npm_arch
368
 
392
 
369
     cat <<EOF > $rootdir/usr/bin/install_scuttlebot
393
     cat <<EOF > $rootdir/usr/bin/install_scuttlebot
370
 #!/bin/bash
394
 #!/bin/bash
371
 npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION}
395
 npm install --arch=$NPM_ARCH -g scuttlebot@${SCUTTLEBOT_VERSION}
372
-npm install --arch=$NPM_ARCH -g dat
373
 npm install --arch=$NPM_ARCH -g git-ssb
396
 npm install --arch=$NPM_ARCH -g git-ssb
374
 npm install --arch=$NPM_ARCH -g git-remote-ssb
397
 npm install --arch=$NPM_ARCH -g git-remote-ssb
375
 EOF
398
 EOF
420
         exit 528253
443
         exit 528253
421
     fi
444
     fi
422
 
445
 
423
-    npm install -g dat
446
+    install_dat
424
     npm install -g git-ssb
447
     npm install -g git-ssb
425
     npm install -g git-remote-ssb
448
     npm install -g git-remote-ssb
426
 
449
 

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

37
 GPG_ID=$(gpg --list-keys $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
37
 GPG_ID=$(gpg --list-keys $MY_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
38
 GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
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
 # Start including files
53
 # Start including files
41
 
54
 
42
 UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
55
 UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
402
 }
415
 }
403
 
416
 
404
 function show_gpg_key {
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
     dialog --title $"My PGP/GPG Key" \
420
     dialog --title $"My PGP/GPG Key" \
408
            --backtitle $"Freedombone User Control Panel" \
421
            --backtitle $"Freedombone User Control Panel" \
409
            --msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70
422
            --msgbox $"Email Address: $MY_EMAIL_ADDRESS\n\nKey ID: $GPG_ID\n\nFingerprint: $GPG_FINGERPRINT\n\nCreated: $GPG_DATE" 12 70
415
     echo ''
428
     echo ''
416
     echo ''
429
     echo ''
417
     gpg --armor --export $GPG_ID
430
     gpg --armor --export $GPG_ID
431
+    echo ''
432
+    echo ''
433
+    echo ''
418
     gpg --armor --export-secret-key $GPG_ID
434
     gpg --armor --export-secret-key $GPG_ID
419
     any_key
435
     any_key
420
 }
436
 }

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

38
     CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME
38
     CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME
39
     CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
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
     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
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
     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
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
     key_id=
262
     key_id=
250
     if [[ $key_owner_username != "root" ]]; then
263
     if [[ $key_owner_username != "root" ]]; then
251
         key_id=$(su -c "gpg --list-keys $key_email_address" - $key_owner_username | sed -n '2p' | sed 's/^[ \t]*//')
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
     else
278
     else
253
         key_id=$(gpg --list-keys $key_email_address | sed -n '2p' | sed 's/^[ \t]*//')
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
     fi
293
     fi
255
     echo $key_id
294
     echo $key_id
256
 }
295
 }

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

101
             CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
101
             CURR_GPG_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
102
             CURR_GPG_BACKUP_ID=$(gpg --homedir=$HOME_DIR/.gnupg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
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
             echo $'Making backup copy of existing gpg keys'
117
             echo $'Making backup copy of existing gpg keys'
105
             if [ -d $HOME_DIR/.gnupg ]; then
118
             if [ -d $HOME_DIR/.gnupg ]; then
106
                 if [ -d $HOME_DIR/.gnupg_old ]; then
119
                 if [ -d $HOME_DIR/.gnupg_old ]; then