瀏覽代碼

Don't generate gpg keys if they were imported from usb

Bob Mottram 10 年之前
父節點
當前提交
5833778775
共有 1 個檔案被更改,包括 25 行新增14 行删除
  1. 25
    14
      install-freedombone.sh

+ 25
- 14
install-freedombone.sh 查看文件

189
 
189
 
190
 GPG_KEYSERVER="hkp://keys.gnupg.net"
190
 GPG_KEYSERVER="hkp://keys.gnupg.net"
191
 
191
 
192
+# gets set to yes if gpg keys are imported from usb
193
+GPG_KEYS_IMPORTED="no"
194
+
192
 # optionally you can provide your exported GPG key pair here
195
 # optionally you can provide your exported GPG key pair here
193
 # Note that the private key file will be deleted after use
196
 # Note that the private key file will be deleted after use
194
 # If these are unspecified then a new GPG key will be created
197
 # If these are unspecified then a new GPG key will be created
384
               echo 'Importing GPG keyring'
387
               echo 'Importing GPG keyring'
385
               cp -r $USB_MOUNT/.gnupg /home/$MY_USERNAME
388
               cp -r $USB_MOUNT/.gnupg /home/$MY_USERNAME
386
               chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
389
               chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
390
+              GPG_KEYS_IMPORTED="yes"
387
               if [ -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then
391
               if [ -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then
388
                   shred -zu $USB_MOUNT/.gnupg/secring.gpg
392
                   shred -zu $USB_MOUNT/.gnupg/secring.gpg
389
                   shred -zu $USB_MOUNT/.gnupg/random_seed
393
                   shred -zu $USB_MOUNT/.gnupg/random_seed
434
           cp -r $USB_MOUNT/ssl/* /etc/ssl
438
           cp -r $USB_MOUNT/ssl/* /etc/ssl
435
           chmod 640 /etc/ssl/certs/*
439
           chmod 640 /etc/ssl/certs/*
436
           chmod 400 /etc/ssl/private/*
440
           chmod 400 /etc/ssl/private/*
437
-		  # change ownership of some certificates
438
-		  if [ -f /etc/ssl/private/xmpp.key ]; then
439
-			  chown prosody:prosody /etc/ssl/private/xmpp.*
440
-			  chown prosody:prosody /etc/ssl/certs/xmpp.*
441
-		  fi
442
-		  if [ -f /etc/ssl/private/dovecot.key ]; then
443
-			  chown root:dovecot /etc/ssl/certs/dovecot.*
444
-			  chown root:dovecot /etc/ssl/private/dovecot.*
445
-		  fi
446
-		  if [ -f /etc/ssl/private/exim.key ]; then
447
-			  chown root:Debian-exim /etc/ssl/private/exim.key /etc/ssl/certs/exim.crt /etc/ssl/certs/exim.dhparam
448
-		  fi
441
+          # change ownership of some certificates
442
+          if [ -f /etc/ssl/private/xmpp.key ]; then
443
+              chown prosody:prosody /etc/ssl/private/xmpp.*
444
+              chown prosody:prosody /etc/ssl/certs/xmpp.*
445
+          fi
446
+          if [ -f /etc/ssl/private/dovecot.key ]; then
447
+              chown root:dovecot /etc/ssl/certs/dovecot.*
448
+              chown root:dovecot /etc/ssl/private/dovecot.*
449
+          fi
450
+          if [ -f /etc/ssl/private/exim.key ]; then
451
+              chown root:Debian-exim /etc/ssl/private/exim.key /etc/ssl/certs/exim.crt /etc/ssl/certs/exim.dhparam
452
+          fi
449
       fi
453
       fi
450
       if [ -d $USB_MOUNT/personal ]; then
454
       if [ -d $USB_MOUNT/personal ]; then
451
           echo 'Importing personal directory'
455
           echo 'Importing personal directory'
1081
 
1085
 
1082
   # make a tls certificate for email
1086
   # make a tls certificate for email
1083
   if [ ! -f /etc/ssl/private/exim.key ]; then
1087
   if [ ! -f /etc/ssl/private/exim.key ]; then
1084
-	  makecert exim
1088
+      makecert exim
1085
   fi
1089
   fi
1086
   cp /etc/ssl/private/exim.key /etc/exim4
1090
   cp /etc/ssl/private/exim.key /etc/exim4
1087
   cp /etc/ssl/certs/exim.crt /etc/exim4
1091
   cp /etc/ssl/certs/exim.crt /etc/exim4
1250
   fi
1254
   fi
1251
   apt-get -y --force-yes install dovecot-common dovecot-imapd
1255
   apt-get -y --force-yes install dovecot-common dovecot-imapd
1252
   if [ ! -f /etc/ssl/private/dovecot.key ]; then
1256
   if [ ! -f /etc/ssl/private/dovecot.key ]; then
1253
-	  makecert dovecot
1257
+      makecert dovecot
1254
   fi
1258
   fi
1255
   chown root:dovecot /etc/ssl/certs/dovecot.*
1259
   chown root:dovecot /etc/ssl/certs/dovecot.*
1256
   chown root:dovecot /etc/ssl/private/dovecot.*
1260
   chown root:dovecot /etc/ssl/private/dovecot.*
1279
   fi
1283
   fi
1280
   apt-get -y --force-yes install gnupg
1284
   apt-get -y --force-yes install gnupg
1281
 
1285
 
1286
+  # if gpg keys directory was previously imported from usb
1287
+  if [[ $GPG_KEYS_IMPORTED == "yes" && -d /home/$MY_USERNAME/.gnupg ]]; then
1288
+      sed -i "s|keyserver hkp://keys.gnupg.net|keyserver $GPG_KEYSERVER|g" /home/$MY_USERNAME/.gnupg/gpg.conf
1289
+      echo 'configure_gpg' >> $COMPLETION_FILE
1290
+      return
1291
+  fi
1292
+
1282
   if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
1293
   if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
1283
       mkdir /home/$MY_USERNAME/.gnupg
1294
       mkdir /home/$MY_USERNAME/.gnupg
1284
       echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf
1295
       echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf