Only remove files if they were coppied

This commit is contained in:
Bob Mottram 2014-09-23 21:56:28 +01:00
parent 1457d3c2fc
commit 22f8909b6e
1 changed files with 20 additions and 10 deletions

View File

@ -164,10 +164,15 @@ function search_for_attached_usb_drive {
echo 'Importing GPG keyring' echo 'Importing GPG keyring'
cp -r /media/usb/.gnupg /home/$MY_USERNAME cp -r /media/usb/.gnupg /home/$MY_USERNAME
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.gnupg
if [ -f /home/$MY_USERNAME/.gnupg/secring.gpg ]; then
shred -zu /media/usb/.gnupg/secring.gpg shred -zu /media/usb/.gnupg/secring.gpg
shred -zu /media/usb/.gnupg/random_seed shred -zu /media/usb/.gnupg/random_seed
shred -zu /media/usb/.gnupg/trustdb.gpg shred -zu /media/usb/.gnupg/trustdb.gpg
rm -rf /media/usb/.gnupg rm -rf /media/usb/.gnupg
else
echo 'GPG files did not copy'
exit
fi
fi fi
if [ -f /media/usb/private_key.gpg ]; then if [ -f /media/usb/private_key.gpg ]; then
echo 'GPG private key found on USB drive' echo 'GPG private key found on USB drive'
@ -182,10 +187,15 @@ function search_for_attached_usb_drive {
cp -r /media/usb/.ssh /home/$MY_USERNAME cp -r /media/usb/.ssh /home/$MY_USERNAME
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
# for security delete the ssh keys from the usb drive # for security delete the ssh keys from the usb drive
if [ -f /home/$MY_USERNAME/.ssh/id_rsa ]; then
shred -zu /media/usb/.ssh/id_rsa shred -zu /media/usb/.ssh/id_rsa
shred -zu /media/usb/.ssh/id_rsa.pub shred -zu /media/usb/.ssh/id_rsa.pub
shred -zu /media/usb/.ssh/known_hosts shred -zu /media/usb/.ssh/known_hosts
rm -rf /media/usb/.ssh rm -rf /media/usb/.ssh
else
echo 'ssh files did not copy'
exit
fi
fi fi
if [ -f /media/usb/.emacs ]; then if [ -f /media/usb/.emacs ]; then
echo 'Importing .emacs file' echo 'Importing .emacs file'