SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I've been trying to make a simple script to mount Windows® Bitlocker® locked partitions. (Because of my job, I have a few locked drives).
Hence, I ve been trying to make the mounting a bit easier.
I worte a simply (probably not very efficent) script, that once I attach I have to run manually, it has a couple lines and uses Zenity as GUI for passwords and selection.
#!/bin/bash
#requirementes: dislocker,zenity
DFILE_LOCATION="/tmp/DFILE"
DRIVE_MOUNTPOINT="/mnt/UnlockedDrive"
if ! type zenity > /dev/null; then
echo "Please install 'Zenity'";
exit;
fi
if ! type dislocker > /dev/null; then
zenity --error --tittle="Dislocker Not Found" --text="Dislocker has not been found on your system. Please install, and retry."
exit;
fi
#If everythng seems to be OK, continue.
SUPASSWORD=$(zenity --password --title="Authenticate" --text="In order to continue, SuperUser Passwrod is required")
#Check if exists, otherwise create a folder to mount dislocker-image
if [ ! -d $DFILE_LOCATION ]; then
# Control will enter here if $DIRECTORY doesn't exist.
echo $SUPASSWORD | sudo -S mkdir $DFILE_LOCATION
fi
if [ ! -d $DRIVE_MOUNTPOINT ]; then
# Control will enter here if $DIRECTORY doesn't exist.
echo $SUPASSWORD | sudo -S mkdir $DRIVE_MOUNTPOINT
fi
lockedDrive=$(find /dev -mindepth 1 -maxdepth 1 -name "*[sh]d[a-z][0-9]" | sort | awk '{ printf "FALSE""\0"$0"\0" }' | \
xargs -0 zenity --list --title="Root Partition" --text="Select the locked partition to unlock." \
--radiolist --multiple --column ' ' --column 'Partitions')
lockedDrivePSW=$(zenity --password --title="Locked Drive" --text="Please type Locked Drive Password")
if [ ! -f "$DFILE_LOCATION"/dislocker-file ]; then
# Control will enter here if file does not.
echo $SUPASSWORD | sudo -S dislocker -v -V $lockedDrive -u$lockedDrivePSW -- $DFILE_LOCATION
echo $SUPASSWORD | sudo -S mount -o loop $DFILE_LOCATION/dislocker-file $DRIVE_MOUNTPOINT
fi
The script works fine, it gets the job done.
But, Im looking for a way in wich the script will pop when I attach a locked drive.
Is that even possible?? Probably will pop every single time I attach a drive, but since I know it is or it i not locked, I will just cancel and keep going.
Anyways,
I was wondering if there is a way under udev rules to detect a drive has been attached, run the script, and would be a killer if once its detached destroys the dislocker-file.
But, Im looking for a way in wich the script will pop when I attach a locked drive.
Is that even possible?? Probably will pop every single time I attach a drive, but since I know it is or it i not locked, I will just cancel and keep going.
Anyways,
I was wondering if there is a way under udev rules to detect a drive has been attached, run the script, and would be a killer if once its detached destroys the dislocker-file.
I guess this post from Arch forum could help you on this.
Hi, I've been trying to make a simple script to mount Windows® Bitlocker® locked partitions. ...
The script works fine, it gets the job done.
Hi. When I run your script, I get the following error:
Code:
bash: ./dislocker_unlock_script.sh: /bin/bash^M: bad interpreter: No such file or directory
If I run it this way:
Code:
bash dislocker_unlock_script.sh
I get these errors:
Code:
dislocker_unlock_script.sh: line 5: $'\r': command not found
dislocker_unlock_script.sh: line 6: $'\r': command not found
dislocker_unlock_script.sh: line 46: syntax error near unexpected token `fi'
dislocker_unlock_script.sh: line 46: `fi'
Your script file is saved with the Windows style of end of line, which BASH does not like.
You should open it in a editor and save with the UNIX style of end of line.
Ah! But in fact I downloaded the script directly from Pastebin by clicking "download." If I copy it and paste it into the xed editor will that work better?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.