Przeglądaj źródła

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

Bob Mottram 10 lat temu
rodzic
commit
5833778775
1 zmienionych plików z 25 dodań i 14 usunięć
  1. 25
    14
      install-freedombone.sh

+ 25
- 14
install-freedombone.sh Wyświetl plik

@@ -189,6 +189,9 @@ WIKI_SQLITE_ADDON_HASH="930335e647c7e62f3068689c256ee169fad2426b64f8360685d391ec
189 189
 
190 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 195
 # optionally you can provide your exported GPG key pair here
193 196
 # Note that the private key file will be deleted after use
194 197
 # If these are unspecified then a new GPG key will be created
@@ -384,6 +387,7 @@ function search_for_attached_usb_drive {
384 387
               echo 'Importing GPG keyring'
385 388
               cp -r $USB_MOUNT/.gnupg /home/$MY_USERNAME
386 389
               chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
390
+              GPG_KEYS_IMPORTED="yes"
387 391
               if [ -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then
388 392
                   shred -zu $USB_MOUNT/.gnupg/secring.gpg
389 393
                   shred -zu $USB_MOUNT/.gnupg/random_seed
@@ -434,18 +438,18 @@ function search_for_attached_usb_drive {
434 438
           cp -r $USB_MOUNT/ssl/* /etc/ssl
435 439
           chmod 640 /etc/ssl/certs/*
436 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 453
       fi
450 454
       if [ -d $USB_MOUNT/personal ]; then
451 455
           echo 'Importing personal directory'
@@ -1081,7 +1085,7 @@ function configure_email {
1081 1085
 
1082 1086
   # make a tls certificate for email
1083 1087
   if [ ! -f /etc/ssl/private/exim.key ]; then
1084
-	  makecert exim
1088
+      makecert exim
1085 1089
   fi
1086 1090
   cp /etc/ssl/private/exim.key /etc/exim4
1087 1091
   cp /etc/ssl/certs/exim.crt /etc/exim4
@@ -1250,7 +1254,7 @@ function configure_imap {
1250 1254
   fi
1251 1255
   apt-get -y --force-yes install dovecot-common dovecot-imapd
1252 1256
   if [ ! -f /etc/ssl/private/dovecot.key ]; then
1253
-	  makecert dovecot
1257
+      makecert dovecot
1254 1258
   fi
1255 1259
   chown root:dovecot /etc/ssl/certs/dovecot.*
1256 1260
   chown root:dovecot /etc/ssl/private/dovecot.*
@@ -1279,6 +1283,13 @@ function configure_gpg {
1279 1283
   fi
1280 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 1293
   if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
1283 1294
       mkdir /home/$MY_USERNAME/.gnupg
1284 1295
       echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf