65 lines
1.4 KiB
Bash
65 lines
1.4 KiB
Bash
#!/bin/bash
|
|
KEY_LOCATION="/tmp/key"
|
|
VERACRYPT_KEY="$KEY_LOCATION/veracrypt"
|
|
USB_KEY_LABEL="veracrypt"
|
|
COMPTUER_USER="verita84"
|
|
VERACRYPT_MOUNT_DIR="/home"
|
|
VERACRYPT_VOLUME="/dev/nvme0n1p4"
|
|
|
|
mkdir $KEY_LOCATION
|
|
|
|
stop-Everything() {
|
|
killall -9 -u $COMPTUER_USER
|
|
systemctl stop gdm
|
|
veracrypt --dismount $VERACRYPT_VOLUME
|
|
umount $VERACRYPT_MOUNT_DIR
|
|
umount $KEY_LOCATION
|
|
}
|
|
|
|
start-Everything() {
|
|
veracrypt --mount $VERACRYPT_VOLUME $VERACRYPT_MOUNT_DIR --pim 0 --password="" --keyfiles $VERACRYPT_KEY --protect-hidden no --slot 1
|
|
systemctl start gdm
|
|
}
|
|
|
|
while :; do
|
|
USB_CHECK=$(blkid | grep $USB_KEY_LABEL)
|
|
if [[ $USB_CHECK = *$USB_KEY_LABEL* ]]; then
|
|
echo
|
|
echo "USB Key plugged in."
|
|
echo
|
|
MOUNT_CHECK=$(mount | grep $KEY_LOCATION)
|
|
if [[ $MOUNT_CHECK = *$KEY_LOCATION* ]]; then
|
|
echo
|
|
echo "USB Key Mounted"
|
|
echo
|
|
if [ -f "$VERACRYPT_KEY" ]; then
|
|
MOUNT_CHECK=$(mount | grep $VERACRYPT_MOUNT_DIR)
|
|
if [[ $MOUNT_CHECK = *$VERACRYPT_MOUNT_DIR* ]]; then
|
|
echo
|
|
echo "VeraCrypt already mounted."
|
|
echo
|
|
else
|
|
echo
|
|
echo "Mounting Veracrypt Volume........."
|
|
start-Everything
|
|
fi
|
|
else
|
|
echo
|
|
echo "Error: Veracrypt Key not found!"
|
|
echo
|
|
stop-Everything
|
|
fi
|
|
else
|
|
echo
|
|
echo "VeraCrypt Volume not mounted yet. Mounting now....."
|
|
echo
|
|
mount -L $USB_KEY_LABEL $KEY_LOCATION
|
|
fi
|
|
else
|
|
echo
|
|
echo "VeraCrypt USB Key not found! Killing Everything!"
|
|
echo
|
|
stop-Everything
|
|
fi
|
|
sleep 15
|
|
done |