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

This commit is contained in:
Bob Mottram 2014-09-29 10:40:42 +01:00
parent f0f52e3dca
commit 5833778775
1 changed files with 25 additions and 14 deletions

View File

@ -189,6 +189,9 @@ WIKI_SQLITE_ADDON_HASH="930335e647c7e62f3068689c256ee169fad2426b64f8360685d391ec
GPG_KEYSERVER="hkp://keys.gnupg.net" GPG_KEYSERVER="hkp://keys.gnupg.net"
# gets set to yes if gpg keys are imported from usb
GPG_KEYS_IMPORTED="no"
# optionally you can provide your exported GPG key pair here # optionally you can provide your exported GPG key pair here
# Note that the private key file will be deleted after use # Note that the private key file will be deleted after use
# If these are unspecified then a new GPG key will be created # If these are unspecified then a new GPG key will be created
@ -384,6 +387,7 @@ function search_for_attached_usb_drive {
echo 'Importing GPG keyring' echo 'Importing GPG keyring'
cp -r $USB_MOUNT/.gnupg /home/$MY_USERNAME cp -r $USB_MOUNT/.gnupg /home/$MY_USERNAME
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
GPG_KEYS_IMPORTED="yes"
if [ -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then if [ -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then
shred -zu $USB_MOUNT/.gnupg/secring.gpg shred -zu $USB_MOUNT/.gnupg/secring.gpg
shred -zu $USB_MOUNT/.gnupg/random_seed shred -zu $USB_MOUNT/.gnupg/random_seed
@ -434,18 +438,18 @@ function search_for_attached_usb_drive {
cp -r $USB_MOUNT/ssl/* /etc/ssl cp -r $USB_MOUNT/ssl/* /etc/ssl
chmod 640 /etc/ssl/certs/* chmod 640 /etc/ssl/certs/*
chmod 400 /etc/ssl/private/* chmod 400 /etc/ssl/private/*
# change ownership of some certificates # change ownership of some certificates
if [ -f /etc/ssl/private/xmpp.key ]; then if [ -f /etc/ssl/private/xmpp.key ]; then
chown prosody:prosody /etc/ssl/private/xmpp.* chown prosody:prosody /etc/ssl/private/xmpp.*
chown prosody:prosody /etc/ssl/certs/xmpp.* chown prosody:prosody /etc/ssl/certs/xmpp.*
fi fi
if [ -f /etc/ssl/private/dovecot.key ]; then if [ -f /etc/ssl/private/dovecot.key ]; then
chown root:dovecot /etc/ssl/certs/dovecot.* chown root:dovecot /etc/ssl/certs/dovecot.*
chown root:dovecot /etc/ssl/private/dovecot.* chown root:dovecot /etc/ssl/private/dovecot.*
fi fi
if [ -f /etc/ssl/private/exim.key ]; then if [ -f /etc/ssl/private/exim.key ]; then
chown root:Debian-exim /etc/ssl/private/exim.key /etc/ssl/certs/exim.crt /etc/ssl/certs/exim.dhparam chown root:Debian-exim /etc/ssl/private/exim.key /etc/ssl/certs/exim.crt /etc/ssl/certs/exim.dhparam
fi fi
fi fi
if [ -d $USB_MOUNT/personal ]; then if [ -d $USB_MOUNT/personal ]; then
echo 'Importing personal directory' echo 'Importing personal directory'
@ -1081,7 +1085,7 @@ function configure_email {
# make a tls certificate for email # make a tls certificate for email
if [ ! -f /etc/ssl/private/exim.key ]; then if [ ! -f /etc/ssl/private/exim.key ]; then
makecert exim makecert exim
fi fi
cp /etc/ssl/private/exim.key /etc/exim4 cp /etc/ssl/private/exim.key /etc/exim4
cp /etc/ssl/certs/exim.crt /etc/exim4 cp /etc/ssl/certs/exim.crt /etc/exim4
@ -1250,7 +1254,7 @@ function configure_imap {
fi fi
apt-get -y --force-yes install dovecot-common dovecot-imapd apt-get -y --force-yes install dovecot-common dovecot-imapd
if [ ! -f /etc/ssl/private/dovecot.key ]; then if [ ! -f /etc/ssl/private/dovecot.key ]; then
makecert dovecot makecert dovecot
fi fi
chown root:dovecot /etc/ssl/certs/dovecot.* chown root:dovecot /etc/ssl/certs/dovecot.*
chown root:dovecot /etc/ssl/private/dovecot.* chown root:dovecot /etc/ssl/private/dovecot.*
@ -1279,6 +1283,13 @@ function configure_gpg {
fi fi
apt-get -y --force-yes install gnupg apt-get -y --force-yes install gnupg
# if gpg keys directory was previously imported from usb
if [[ $GPG_KEYS_IMPORTED == "yes" && -d /home/$MY_USERNAME/.gnupg ]]; then
sed -i "s|keyserver hkp://keys.gnupg.net|keyserver $GPG_KEYSERVER|g" /home/$MY_USERNAME/.gnupg/gpg.conf
echo 'configure_gpg' >> $COMPLETION_FILE
return
fi
if [ ! -d /home/$MY_USERNAME/.gnupg ]; then if [ ! -d /home/$MY_USERNAME/.gnupg ]; then
mkdir /home/$MY_USERNAME/.gnupg mkdir /home/$MY_USERNAME/.gnupg
echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf echo 'keyserver hkp://keys.gnupg.net' >> /home/$MY_USERNAME/.gnupg/gpg.conf