aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.config/cs/config (renamed from .config/cs.conf)0
-rwxr-xr-xbin/cs25
2 files changed, 14 insertions, 11 deletions
diff --git a/.config/cs.conf b/.config/cs/config
index 6542ade..6542ade 100644
--- a/.config/cs.conf
+++ b/.config/cs/config
diff --git a/bin/cs b/bin/cs
index 0eb3693..363ba12 100755
--- a/bin/cs
+++ b/bin/cs
@@ -7,13 +7,20 @@ valid_name=0
command_name=${1:-}
device_name=${2:-}
-. ~/.config/cs.conf
+if [ -r "$HOME/.config/cs/config" ]; then
+ . "$HOME/.config/cs/config"
+fi
#TODO: do sanity checks on mountpoints and (dm) devices
#TODO: display list of devices available, if no argument given
function open_cryptdevice() {
if [ -L "/dev/disk/by-uuid/$1" ]; then
- /usr/bin/sudo /usr/bin/cryptsetup luksOpen "/dev/disk/by-uuid/$1" $2
+ if [ -L "/dev/mapper/$2" ]; then
+ echo "Crypt device has already been opened: /dev/mapper/$2"
+ echo "Continuing..."
+ else
+ /usr/bin/sudo /usr/bin/cryptsetup luksOpen "/dev/disk/by-uuid/$1" $2
+ fi
else
echo "Error: Device $2 (UUID=$1) is not available."
return 1
@@ -27,15 +34,11 @@ function close_cryptdevice() {
function mount_cryptdevice() {
if [[ -e "/dev/mapper/$1" ]]; then
if [[ ! -d "/mnt/$1" ]]; then
- sudo mkdir "/mnt/$1"
+ sudo mkdir -p "/mnt/$1"
fi
sudo mount "/dev/mapper/$1" "/mnt/$1"
- if [ $1 = "media" ]; then
- sudo mount --bind /mnt/media/music /mnt/music
- sudo mount --bind /mnt/media/photos /mnt/photos
- if [ ! -h ~/.cache/shotwell ]; then
- ln -s /mnt/photos/shotwell/ ~/.cache/shotwell
- fi
+ if [ -x "$HOME/.config/cs/post_mount/$1" ]; then
+ "$HOME/.config/cs/post_mount/$1"
fi
else
echo "Error: Device /dev/mapper/$1 is not available."
@@ -44,8 +47,8 @@ function mount_cryptdevice() {
}
function unmount_cryptdevice() {
- if [ $1 = "media" ]; then
- /usr/bin/sudo /usr/bin/umount /mnt/{music,photos}
+ if [ -x "$HOME/.config/cs/pre_umount/$1" ]; then
+ "$HOME/.config/cs/pre_umount/$1"
fi
/usr/bin/sudo /usr/bin/umount /mnt/$1
}