Tidying backup key creation
This commit is contained in:
parent
b198c6312f
commit
9cbf25aec9
|
@ -6328,11 +6328,13 @@ function configure_backup_key {
|
||||||
apt-get -y install gnupg
|
apt-get -y install gnupg
|
||||||
|
|
||||||
BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")
|
BACKUP_KEY_EXISTS=$(gpg --list-keys "$MY_NAME (backup key)")
|
||||||
if [ "$?" = "0" ]; then
|
if [ $BACKUP_KEY_EXISTS != *"error"* ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate a GPG key for backups
|
# Generate a GPG key for backups
|
||||||
|
BACKUP_KEY_EXISTS=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\"" - $MY_USERNAME)
|
||||||
|
if [ $BACKUP_KEY_EXISTS == *"error"* ]; then
|
||||||
echo 'Key-Type: 1' > /home/$MY_USERNAME/gpg-genkey.conf
|
echo 'Key-Type: 1' > /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
echo 'Key-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
|
echo 'Key-Length: 4096' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
echo 'Subkey-Type: 1' >> /home/$MY_USERNAME/gpg-genkey.conf
|
echo 'Subkey-Type: 1' >> /home/$MY_USERNAME/gpg-genkey.conf
|
||||||
|
@ -6349,6 +6351,7 @@ function configure_backup_key {
|
||||||
echo 'Backup key could not be created'
|
echo 'Backup key could not be created'
|
||||||
exit 43382
|
exit 43382
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
MY_BACKUP_KEY_ID=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\" | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
MY_BACKUP_KEY_ID=$(su -c "gpg --list-keys \"$MY_NAME (backup key)\" | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
||||||
echo "Backup key: $MY_BACKUP_KEY_ID"
|
echo "Backup key: $MY_BACKUP_KEY_ID"
|
||||||
MY_BACKUP_KEY=/home/$MY_USERNAME/backup_key
|
MY_BACKUP_KEY=/home/$MY_USERNAME/backup_key
|
||||||
|
|
Loading…
Reference in New Issue