aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2018-03-12 16:39:12 +0100
committerDavid Runge <dave@sleepmap.de>2018-03-12 16:39:12 +0100
commit0e2d2425b3ccc1dd75c03c6922627bf709e165ba (patch)
treea2d2ef59ed81513f4f4e65cf2ceef6c2b1ca3e72 /bin
parent530c68d749692627632ba1b13ce390b80aed2911 (diff)
downloaddotfiles-0e2d2425b3ccc1dd75c03c6922627bf709e165ba.tar.gz
dotfiles-0e2d2425b3ccc1dd75c03c6922627bf709e165ba.tar.bz2
dotfiles-0e2d2425b3ccc1dd75c03c6922627bf709e165ba.tar.xz
dotfiles-0e2d2425b3ccc1dd75c03c6922627bf709e165ba.zip
bin/cs: Introducing named scripts for post_mount and pre_umount to deal with device specific tasks. Moving configuration according to new folder structure (all below ~/.config/cs now).
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cs25
1 files changed, 14 insertions, 11 deletions
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
}