ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
#! / bin / bash
#sudo rule to rule users
LINE_SUDOERS = "ALL ALL = NOPASSWD: /opt/dislocker-gui/util-root.sh"
mkdir -p / opt / dislocker-gui
cp -r app / * / opt / dislocker-gui /
cp shortcut / dislocker-gui.desktop / usr / share / applications /
#check if the line already exists in the / etc / sudoers file
LINE_SUDOERS_EXISTS = $ (cat / etc / sudoers | grep -q "$ LINE_SUDOERS"; echo $?)
#if line doesn’t exist yet ...
if [$ LINE_SUDOERS_EXISTS]
then
echo $ LINE_SUDOERS >> / etc / sudoers fi
2. util-root.sh
Code:
#! / bin / bash
# dislocker-gui-zenity
#This util-root.sh script contains the commands used by the dislocker-gui.sh
#that need to be run as root user
DFILE_LOCATION = "/ tmp / DFILE"
ACTION = $ 1
case $ ACTION in
"clearTMP")
rm -f /tmp/fdisk.txt
rm -f /tmp/drive_selection_list.txt
;;
"checkBitLockerDriveMounted")
DRIVE_MOUNTPOINT = $ 2
echo $ (mount | grep -q "$ DRIVE_MOUNTPOINT \ | $ DFILE_LOCATION"; echo $?)
;;
"isBitlockerDrive")
DRIVE = $ 2
echo $ (dislocker-fuse -r -V "/ dev / $ DRIVE" | grep -q "None of the decryption mean is decrypting the keys."; echo $?)
;;
"createMountDir")
DRIVE_MOUNTPOINT = $ 2
mkdir -p $ DRIVE_MOUNTPOINT
mkdir -p $ DFILE_LOCATION
;;
"decrypt")
DRIVE_SELECTED = $ 2
DRIVE_PASSWORD = $ 3
DRIVE_UID = $ 4
DRIVE_GID = $ 5
#if the output contains the string "Can't decrypt correctly the VMK." it means the password comes is wrong
echo $ (dislocker-fuse -v -V / dev / "$ DRIVE_SELECTED" -u $ DRIVE_PASSWORD - $ DFILE_LOCATION -o uid = $ DRIVE_UID, gid = $ DRIVE_GID | grep -q "Can't decrypt correctly the VMK." ; echo $?)
;;
"mount")
DRIVE_MOUNTPOINT = $ 2
DRIVE_UID = $ 3
DRIVE_GID = $ 4
if [-f $ DFILE_LOCATION / dislocker-file];
then
mount -o loop, rw, uid = $ DRIVE_UID, gid = $ DRIVE_GID $ DFILE_LOCATION / dislocker-file $ DRIVE_MOUNTPOINT
else
zenity --error --title = "Error" --no-wrap --text = "bitLock mount error"
umount $ DRIVE_MOUNTPOINT 2> / dev / null
umount $ DFILE_LOCATION 2> / dev / null
exit 1
fi
;;
"umount")
DRIVE_MOUNTPOINT = $ 2
umount $ DRIVE_MOUNTPOINT
umount $ DFILE_LOCATION
;;
"getListNTFSDrives")
#get list of NTFS / exFAT / HPFS drives
# fdisk -l | grep NTFS | cut -c6-9> /tmp/fdisk.txt
lsblk -l -n> /tmp/fdisk.txt
;;
esac
3. dislocker-gui.sh
Code:
#! / bin / bash
DRIVE_MOUNTPOINT = "/ media / BitLockerDrive"
d_uid = `id -u`
d_gid = `id -g`
function openFileBrowser
{
if type nautilus 2> / dev / null
then
FILE_BROWSER = "nautilus"
elif type dolphin 2> / dev / null
then
FILE_BROWSER = "dolphin"
elif type thunar 2> / dev / null
then
FILE_BROWSER = "thunar"
else
zenity --info --title = "File Browser Not Found"
--text = "Nautilus / Dolphin / Thunar not found \ n \ nOpen your file browser at $ DRIVE_MOUNTPOINT"
exit
fi
$ ($ FILE_BROWSER $ DRIVE_MOUNTPOINT)
}
function checkDependencies
{
if! type zenity> / dev / null
then
echo "Missing dependency 'Zenity'. Please install it before using this script.
\ n \ nFor Ubuntu: sudo apt install zenity
\ n \ nFor Fedora: sudo dnf install zenity ";
exit;
fi
if! type dislocker-fuse> / dev / null
then
zenity --error --title = "Dislocker Not Found" --no-wrap --text = "Missing dependency 'Dislocker'. Please install it before using this script.
\ n \ nFor Ubuntu: sudo apt install dislocker
\ n \ nFor Fedora: sudo dnf install fuse-dislocker "
exit;
fi
}
function clearTMPFiles
{
sudo /opt/dislocker-gui/util-root.sh "clearTMP"
}
function errorMessage
{
MESSAGE = $ 1
zenity --error --title = "Error" --no-wrap --text = "$ 1"
}
function getListNTFSDrives
{
sudo /opt/dislocker-gui/util-root.sh "getListNTFSDrives"
}
function getSelectionListBitlockerDrive
{
#get list of NTFS / exFAT / HPFS drives
getListNTFSDrives
#if there are any ntfs / exFAT / HPFS drives attached
if [-f "/tmp/fdisk.txt"]
then
#for each candidate drive if it is a bitlocker drive
for drive in $ (cat /tmp/fdisk.txt)
do
#if it is a valid bitlocker drive
if [$ (isBitlockerDrive $ drive) = "0"]
then
size = $ (getDiskSizeGB $ drive)
brandNModel = $ (getDiskBrandNModel $ drive)
#creates a table for the drive selection interface. FALSE indicates that the option is not selected.
echo "FALSE $ drive $ brandNModel $ size" >> /tmp/drive_selection_list.txt
fi
done
else
errorBitlockerDriveNotFound
exit 1
fi
}
function errorBitlockerDriveNotFound
{
errorMessage "No Bitlocker drives found!"
}
function getDiskFromPartition
{
PARTITION = $ 1
echo $ (echo $ PARTITION | cut -c1-3)
}
function getDiskSizeGB
{
PARTITION = $ 1
lsblk / dev / $ PARTITION -n -o SIZE
}
function getDiskBrandNModel
{
PARTITION = $ 1
DISK = $ (getDiskFromPartition $ PARTITION)
#the disk vendor of the command line
#sed command replace spaces with underscores
# echo $ (lsblk -o NAME, VENDOR, MODEL --nodeps | grep $ DISK | grep -v $ PARTITION | cut -c8- | sed -e 's / / _ / g')
echo $ (lsblk -o NAME, VENDOR, MODEL --nodeps | grep $ DISK | grep -v $ PARTITION | cut-d '' -s -f 2- | sed -r 's / \ s {2,} / / g '| sed -e' s / / _ / g ')
}
function isBitlockerDrive
{
DRIVE = $ 1
#return 0 if true
#return 1 if false
echo $ (sudo /opt/dislocker-gui/util-root.sh "isBitlockerDrive" $ DRIVE)
}
function mountDrive
{
DRIVE = $ 1
sudo /opt/dislocker-gui/util-root.sh "createMountDir" $ DRIVE_MOUNTPOINT
#loop until the user supplies a valid password
PASSWORD_WRONG = 0
while ["$ PASSWORD_WRONG" = "0"]
do
DRIVE_PASSWORD = $ (zenity --password --title = "Locked Drive" --text = "Please type the password for the BitLocker drive")
#if the password field is not empty
if [-n "$ DRIVE_PASSWORD"]
then
#try to unlock the drive
PASSWORD_WRONG = $ (sudo /opt/dislocker-gui/util-root.sh "decrypt" $ DRIVE $ DRIVE_PASSWORD $ d_uid $ d_gid)
#if the output contains the string "Can't decrypt correctly the VMK." it means the password comes is wrong
if ["$ PASSWORD_WRONG" = "0"]
then
errorMessage "Wrong Bitlocker password! Please try again."
fi
else
errorMessage "No password supplied!"
fi
done
sudo /opt/dislocker-gui/util-root.sh "mount" $ DRIVE_MOUNTPOINT $ d_uid $ d_gid
#open the file directory
openFileBrowser
}
function actionMountDrive
{
clearTMPFiles
getSelectionListBitlockerDrive
#if there is any valid bitlocker drive
if [-f "/tmp/drive_selection_list.txt"]
then
DRIVE_SELECT_LIST = $ (cat /tmp/drive_selection_list.txt)
DRIVE_SELECTED = $ (zenity --list --title = "BitLocker Drive List" \
--text = "Select the Bitlocker drive to be mounted:" \
--radiolist --multiple \
--width = "450" \
--column '' --column 'Drive' --column 'Brand / Model' --column 'Size' \
$ DRIVE_SELECT_LIST)
#if a drive was selected
if [-n "$ DRIVE_SELECTED"]
then
mountDrive $ DRIVE_SELECTED
else
errorMessage "No Bitlocker drive selected!"
fi
clearTMPFiles
else
errorBitlockerDriveNotFound
fi
}
function actionUmountDrive
{
sudo /opt/dislocker-gui/util-root.sh "umount" $ DRIVE_MOUNTPOINT
}
function checkBitlockerDriveMounted
{
echo $ (sudo /opt/dislocker-gui/util-root.sh "checkBitLockerDriveMounted" $ DRIVE_MOUNTPOINT)
}
checkDependencies
#check if there is any bitlocker drive currently mounted
if ["$ (checkBitlockerDriveMounted)" = "0"]
then
zenity --question --title = "Bitlocker Drive already mounted" --no-wrap \
--text = "There is a Bitlocker drive currently mounted. \ n \ nWhat would you like to do?" \
--ok-label = "Remove it safely" --cancel-label = "Nothing"
#if the user clicked the ok button (Remove it Safely)
if ["$?" = "0"]
then
actionUmountDrive
fi
else
actionMountDrive
fi
Last edited by PROBLEMCHYLD; 04-05-2019 at 01:32 PM.
Great. Seems to be the last update to that site was back in 2016. I do not recommend you grab scripts if you cannot contend without seemingly reviewing them and debugging them on your own. I fully understand that you downloaded these, and there is some documentation about them along with links on that site, also speaking about an upgraded app. That's about as far as I went. The scripts are very involved. Unless you expect to become fully versed in what those scripts do, by your own efforts, then I'd highly recommend you avoid running them. Meanwhile, I do recommend using shellcheck to check the syntax, but I'd also recommend that if/when you do run them, that you limit what they do iteratively until you fully understand them.
I do not recommend you grab scripts if you cannot contend without seemingly reviewing them and debugging them on your own. I fully understand that you downloaded these, and there is some documentation about them along with links on that site, also speaking about an upgraded app. That's about as far as I went. The scripts are very involved. Unless you expect to become fully versed in what those scripts do, by your own efforts, then I'd highly recommend you avoid running them. Meanwhile, I do recommend using shellcheck to check the syntax, but I'd also recommend that if/when you do run them, that you limit what they do iteratively until you fully understand them.
That's like saying, everytime I have car trouble I should learn auto-mechanics. Not going to happen, I specialized in other fields and scripting isn't one of them. It might take some time whether I have to pay for a 3rd party app or someone savvy and skilled enough to fix it so others as well as I can benefit. Either way!!!
Last edited by PROBLEMCHYLD; 04-05-2019 at 01:58 PM.
Asking others to try to understand and debug scripts from other sources for you, with no useful debugging information or effort on your part is not a proper use of this forum.
Also, this would appear to be a sort of duplicate of your previous post on the same subject. Please do not post the same question multiple times in different forums.
Please review the Site FAQ for guidance in posting your questions and general forum usage.
Asking others to try to understand and debug scripts from other sources for you, with no useful debugging information or effort on your part is not a proper use of this forum.
Also, this would appear to be a sort of duplicate of your previous post on the same subject. Please do not post the same question multiple times in different forums.
Please review the Site FAQ for guidance in posting your questions and general forum usage.
How do you expect me to debug something when I don't know how? Sometimes people lack comprehension such as yourself. You can't expect someone to write scripts or debug when they don't have the skill. Just like the mechanic example. I'm NOT a mechanic, and when I have car troubles, I go to someone experienced. Can you comprehend that?
The only thing expected of any member is that they make effort to participate within the very simple guidelines posted in the Site FAQ and LQ Rules. I ask you again to please review the Site FAQ for guidance in posting your questions and general forum usage.
You have been a member here long enough to have learned how that works, please review and consider. Others here at LQ are always willing to help when asked respectfully, just as passing motorists are willing to stop and volunteer assistance when you have suffered a breakdown on the hiway. That is a much different case than towing someone else's broken down vehicle to the roadside and asking others to fix it for you.
Please be respectful of the time volunteered by others and help them to help you.
The only thing expected of any member is that they make effort to participate within the very simple guidelines posted in the Site FAQ and LQ Rules. I ask you again to please review the Site FAQ for guidance in posting your questions and general forum usage.
You have been a member here long enough to have learned how that works, please review and consider. Others here at LQ are always willing to help when asked respectfully, just as passing motorists are willing to stop and volunteer assistance when you have suffered a breakdown on the hiway. That is a much different case than towing someone else's broken down vehicle to the roadside and asking others to fix it for you.
Please be respectful of the time volunteered by others and help them to help you.
Again, the posts you're making isn't helping me or someone who might have the same issue in the future. I didn't ask you to hold my hand, I asked how to fixed a problem I don't know how. Some of you so-called Linux gung-ho users are quick to post anything but a solution. Thanks for nothing, people like you always assume no one has tried any methods. Only thing that beats failure is success," NOT " trying!!! I think its funny how some people that don't provide a solution are some of the same who wants a donation. FOH!!! I'll be moving along because you're getting on my last nerve and my Doctor said to not get upset and keep my blood pressure down. Thanks again for nothing.
Last edited by PROBLEMCHYLD; 04-05-2019 at 04:10 PM.
How do you expect me to debug something when I don't know how? Sometimes people lack comprehension such as yourself. You can't expect someone to write scripts or debug when they don't have the skill. Just like the mechanic example. I'm NOT a mechanic, and when I have car troubles, I go to someone experienced. Can you comprehend that?
On the other hand, can you comprehend that we're all volunteers, as you are, and are not particularly interested in volunteering to debug your scripts for you? Do you expect your mechanic to fix your car for free?
As has been said, we're here to help. You've been given some suggestions to try. If you're not willing to try and learn, there's not much we can do for you.
Quote:
Originally Posted by PROBLEMCHYLD
Again, the posts you're making isn't helping me or someone who might have the same issue in the future. I didn't ask you to hold my hand, I asked how to fixed a problem I don't know how. Some of you so-called Linux gung-ho users are quick to post anything but a solution. Thanks for nothing, people like you always assume no one has tried any methods. Only thing that beats failure is success," NOT " trying!!! I think its funny how some people that don't provide a solution are some of the same who wants a donation. FOH!!! I'll be moving along because you're getting on my last nerve and my Doctor said to not get upset and keep my blood pressure down. Thanks again for nothing.
I don't agree. You have been given several good and helpful suggestions...things which will provide a solution.
That said, as my Daddy used to say, "So long, C.A."
On the other hand, can you comprehend that we're all volunteers, as you are, and are not particularly interested in volunteering to debug your scripts for you? Do you expect your mechanic to fix your car for free?
As has been said, we're here to help. You've been given some suggestions to try. If you're not willing to try and learn, there's not much we can do for you.
I don't agree. You have been given several good and helpful suggestions...things which will provide a solution.
That said, as my Daddy used to say, "So long, C.A."
Wrong!!!
The original scripts doesn't have any spaces and it still doesn't work
Personal attacks, name calling and general rudeness are also not permitted at LQ. For the last time in this thread I urge you to please review the Site FAQ and LQ Rules for guidance in proper use of the forums.
If you have other questions not answered in those links please contact us through contact links available on any page.
As you have not made effort to interact with others in a respectful manner this thread is now being closed.
When posting your questions in future please make effort to communicate what problem you are trying to solve, what you have tried and include any error messages or examples which will help others understand your specific problem and respond accordingly.
And please make effort to be more respectful of others. Name calling and insulting other members is a no-go here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.