Created
April 10, 2016 09:26
-
-
Save deitch/08ed12d868cc0fe03323b4ebc53bfe2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ask_for_password () { | |
cryptkey="Unlocking the disk $cryptsource ($crypttarget)\nEnter passphrase: " | |
if [ -x /bin/plymouth ] && plymouth --ping; then | |
cryptkeyscript="plymouth ask-for-password --prompt" | |
cryptkey=$(printf "$cryptkey") | |
else | |
cryptkeyscript="/lib/cryptsetup/askpass" | |
fi | |
$cryptkeyscript "$cryptkey" | |
} | |
device=$(echo $1 | cut -d: -f1) | |
filepath=$(echo $1 | cut -d: -f2) | |
# Ask for password if device doesn't exist | |
if [ ! -b $device ]; then | |
ask_for_password | |
exit | |
fi | |
mkdir /tmp/auto_unlocker | |
mount $device /tmp/auto_unlocker | |
# Again ask for password if device exist but file doesn't exist | |
if [ ! -e /tmp/auto_unlocker$filepath ]; then | |
ask_for_password | |
else | |
cat /tmp/auto_unlocker$filepath | |
fi | |
umount /tmp/auto_unlocker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment