Hello,
Here is an excerpt of my bash script
Code:
#!/bin/bash
# Workout the inserted usb stick - for this example assume it is /dev/sdc1 and mounted to /mnt/usb
# Now unlock the encrypted partition and mount
cryptsetup luksOpen --key-file /mnt/usb/mykey /dev/sda7 my_map
mount /dev/mapper/my_map /the/place/to/mount
I have set this script to be invoked automatically through the udev rules, which is as follows:
Code:
ACTION=="add", SUBSYSTEMS=="usb", KERNEL=="sd[a-z]1", RUN+="/usr/local/bin/theabovescript"
When I inserted the USB stick, the above
script gets triggered. But, on the
cryptsetup line, it fails to unlock the partition. But at the same time, when I open a terminal and execute the script manually, it works without a problem.
I can see a huge difference in the environment in which the script runs when triggered automatically and manually. But I can't figure out how to solve this.
Can somebody please throw some light on this? A solution with an explanation will be very much appreciated.
Thanks