darkrc/bin/secmount

30 lines
842 B
Text
Raw Normal View History

2023-04-03 13:48:46 +00:00
#!/bin/sh
title="SecMount"
2023-04-03 13:48:46 +00:00
target=$(realpath "$1")
if ! [ -d "$target" ]
then
2023-05-13 08:33:49 +00:00
echo "Directory '$(basename "$target")' does not exist!"
exit 1
2023-04-03 13:48:46 +00:00
fi
back="$(dirname "$target")/.$(basename "$target")"
if ! [ -d "$back" ]
then
2023-05-13 08:33:49 +00:00
mkdir -p "$back"
passwd=$(zenity --password --title $title)
if zenity --question --title $title --text "Save password in login keyring?"
then
echo 'echo -n $passwd | secret-tool store --label "SecureFS $target" application securefs directory "$target"'
echo -n $passwd | secret-tool store --label "SecureFS $target" application securefs directory "$target"
fi
echo -n $passwd | securefs c "$back"
2023-04-03 13:48:46 +00:00
else
2023-05-13 08:33:49 +00:00
passwd=$(secret-tool lookup application securefs directory "$target")
if [ -z "$passwd" ]
then passwd=$(zenity --password --title $title)
fi
2023-04-03 13:48:46 +00:00
fi
exec echo -n $passwd | securefs mount "$back" "$target"