Option to format keydrive as LUKS
This commit is contained in:
parent
08c3b56758
commit
decee24c46
Binary file not shown.
|
@ -35,10 +35,11 @@ KEY_FRAGMENTS=3
|
||||||
FRAGMENTS_DIR=$USB_MOUNT/.gnupg_fragments
|
FRAGMENTS_DIR=$USB_MOUNT/.gnupg_fragments
|
||||||
MY_USERNAME=$USER
|
MY_USERNAME=$USER
|
||||||
MASTER_DRIVE="no"
|
MASTER_DRIVE="no"
|
||||||
|
FORMAT="no"
|
||||||
|
|
||||||
function show_help {
|
function show_help {
|
||||||
echo ''
|
echo ''
|
||||||
echo 'freedombone-keydrive -u [username] -d [device, eg. sdb] --master [yes/no] -n [no of fragments]'
|
echo 'freedombone-keydrive -u [username] -d [device, eg. sdb] --master [yes/no] -n [no of fragments] --format [yes/no]'
|
||||||
echo ''
|
echo ''
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
@ -67,6 +68,10 @@ case $key in
|
||||||
shift
|
shift
|
||||||
KEY_FRAGMENTS=$1
|
KEY_FRAGMENTS=$1
|
||||||
;;
|
;;
|
||||||
|
-f|--format)
|
||||||
|
shift
|
||||||
|
FORMAT="yes"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
# unknown option
|
# unknown option
|
||||||
;;
|
;;
|
||||||
|
@ -97,6 +102,29 @@ if [ -f /dev/mapper/encrypted_usb ]; then
|
||||||
rm -rf /dev/mapper/encrypted_usb
|
rm -rf /dev/mapper/encrypted_usb
|
||||||
fi
|
fi
|
||||||
cryptsetup luksClose encrypted_usb
|
cryptsetup luksClose encrypted_usb
|
||||||
|
|
||||||
|
# optionally format the drive
|
||||||
|
if [[ $FORMAT == "yes" ]]; then
|
||||||
|
echo "Formatting ${USB_DRIVE::-1} as LUKS"
|
||||||
|
cryptsetup -y -v luksFormat ${USB_DRIVE::-1}
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
exit 36823
|
||||||
|
fi
|
||||||
|
cryptsetup luksOpen ${USB_DRIVE::-1} encrypted_usb
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
exit 37232
|
||||||
|
fi
|
||||||
|
mkfs.ext4 /dev/mapper/encrypted_usb
|
||||||
|
if [ ! "$?" = "0" ]; then
|
||||||
|
exit 73218
|
||||||
|
fi
|
||||||
|
cryptsetup luksClose encrypted_usb
|
||||||
|
if [ -f /dev/mapper/encrypted_usb ]; then
|
||||||
|
rm -rf /dev/mapper/encrypted_usb
|
||||||
|
fi
|
||||||
|
echo 'Format completed'
|
||||||
|
fi
|
||||||
|
|
||||||
cryptsetup luksOpen $USB_DRIVE encrypted_usb
|
cryptsetup luksOpen $USB_DRIVE encrypted_usb
|
||||||
if [ "$?" = "0" ]; then
|
if [ "$?" = "0" ]; then
|
||||||
USB_DRIVE=/dev/mapper/encrypted_usb
|
USB_DRIVE=/dev/mapper/encrypted_usb
|
||||||
|
|
Loading…
Reference in New Issue