This commit is contained in:
Bob Mottram 2015-11-04 21:05:24 +00:00
parent b199fb98fd
commit 5039a5526e
1 changed files with 5 additions and 3 deletions

View File

@ -34,24 +34,26 @@ if [ ! $1 ]; then
exit 1
fi
USB_DRIVE=/dev/$1
USB_DRIVE=/dev/${1}
echo "Formatting $USB_DRIVE as LUKS"
cryptsetup -y -v luksFormat $USB_DRIVE
cryptsetup -y -v luksFormat ${USB_DRIVE}
if [ ! "$?" = "0" ]; then
echo "Failed to format $USB_DRIVE as LUKS"
exit 36823
fi
cryptsetup luksOpen $USB_DRIVE encrypted_usb
cryptsetup luksOpen ${USB_DRIVE} encrypted_usb
if [ ! "$?" = "0" ]; then
echo "Failed to open LUKS formatted drive $USB_DRIVE"
exit 37232
fi
mkfs.ext4 /dev/mapper/encrypted_usb
if [ ! "$?" = "0" ]; then
cryptsetup luksClose encrypted_usb
echo 'Format of drive $USB_DRIVE failed'
exit 73218
fi
sleep 2
cryptsetup luksClose encrypted_usb
if [ -f /dev/mapper/encrypted_usb ]; then
rm -rf /dev/mapper/encrypted_usb