diff options
author | David Runge <dave@sleepmap.de> | 2015-12-30 13:44:55 +0100 |
---|---|---|
committer | David Runge <dave@sleepmap.de> | 2015-12-30 13:44:55 +0100 |
commit | 4d44fe7caab6815dbaecb0e62b66668747f3a857 (patch) | |
tree | 58dfa7306252c1c95d87623106b5e2fc81815e07 | |
parent | 10e67d644c07dc59fbe680ec74685c8e9efcd69f (diff) | |
download | dotfiles-4d44fe7caab6815dbaecb0e62b66668747f3a857.tar.gz dotfiles-4d44fe7caab6815dbaecb0e62b66668747f3a857.tar.bz2 dotfiles-4d44fe7caab6815dbaecb0e62b66668747f3a857.tar.xz dotfiles-4d44fe7caab6815dbaecb0e62b66668747f3a857.zip |
.zsh.after/functions.zsh: Updating lopen to do bind mounts when using newer devices.
-rw-r--r-- | .zsh.after/functions.zsh | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/.zsh.after/functions.zsh b/.zsh.after/functions.zsh index a0042c2..99b3486 100644 --- a/.zsh.after/functions.zsh +++ b/.zsh.after/functions.zsh @@ -247,22 +247,22 @@ lopen() { "homey") case $1 in "video-backup") - sudo cryptsetup luksOpen /dev/disk/by-id/ata-SAMSUNG_HD153WI_S1UVJ1VZ400797 $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD153WI_S1UVJ1VZ400797" $1 ;; "video") - sudo cryptsetup luksOpen /dev/disk/by-id/ata-SAMSUNG_HD153WI_S1UVJ1VZ400798 $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD153WI_S1UVJ1VZ400798" $1 ;; "photos") - sudo cryptsetup luksOpen /dev/disk/by-id/ata-SAMSUNG_HD501LJ_S0MUJ1FQ104574 $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD501LJ_S0MUJ1FQ104574" $1 ;; "music") - sudo cryptsetup luksOpen /dev/disk/by-id/ata-SAMSUNG_HD501LJ_S0MUJ1FPB87663 $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-SAMSUNG_HD501LJ_S0MUJ1FPB87663" $1 ;; "music-external") - sudo cryptsetup luksOpen /dev/disk/by-id/ata-ST9500325AS_6VE152RS $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE152RS" $1 ;; "photos-external") - sudo cryptsetup luksOpen /dev/disk/by-id/ata-ST9500325AS_6VE457TN $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE457TN" $1 ;; esac ;; @@ -270,46 +270,54 @@ lopen() { case $1 in "music") if [ -L "/dev/disk/by-uuid/e0b19c7d-9e90-4117-aea1-7e4b321d9d5a" ]; then - sudo cryptsetup luksOpen /dev/disk/by-uuid/e0b19c7d-9e90-4117-aea1-7e4b321d9d5a $1 + sudo cryptsetup luksOpen "/dev/disk/by-uuid/e0b19c7d-9e90-4117-aea1-7e4b321d9d5a" $1 elif [ -L "/dev/disk/by-id/ata-ST9500325AS_6VE152RS" ]; then - sudo cryptsetup luksOpen /dev/disk/by-id/ata-ST9500325AS_6VE152RS $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE152RS" $1 elif [ -L "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE36KXD-0:0" ]; then sudo cryptsetup luksOpen "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE36KXD-0:0" $1 else - echo "Error! Disk not available" + echo "Error! Device $1 is not available" exit 1 fi ;; "photos") if [ -L "/dev/disk/by-uuid/b3c5a842-474b-4c2f-a246-abebe1da3450" ]; then - sudo cryptsetup luksOpen /dev/disk/by-uuid/b3c5a842-474b-4c2f-a246-abebe1da3450 $1 + sudo cryptsetup luksOpen "/dev/disk/by-uuid/b3c5a842-474b-4c2f-a246-abebe1da3450" $1 elif [ -L "/dev/disk/by-id/ata-ST9500325AS_6VE457TN " ]; then - sudo cryptsetup luksOpen /dev/disk/by-id/ata-ST9500325AS_6VE457TN $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST9500325AS_6VE457TN" $1 elif [ -L "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE4LCR0-0:0" ]; then sudo cryptsetup luksOpen "/dev/disk/by-id/usb-Seagate_FreeAgent_Go_2GE4LCR0-0:0" $1 else - echo "Error! Disk not available" + echo "Error! Device $1 is not available" exit 1 fi - if [ ! -h ~/.cache/shotwell ]; then - ln -s /mnt/photos/shotwell/ ~/.cache/shotwell - fi ;; "backup-audio") if [ -L "/dev/disk/by-id/usb-HGST_HTS_725050A7E630_801130168383-0:0" ]; then - sudo cryptsetup luksOpen /dev/disk/by-id/usb-HGST_HTS_725050A7E630_801130168383-0:0 $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/usb-HGST_HTS_725050A7E630_801130168383-0:0" $1 elif [ -L "/dev/disk/by-id/ata-HGST_HTS725050A7E630_TF755AWHHS9S1M" ]; then - sudo cryptsetup luksOpen /dev/disk/by-id/ata-HGST_HTS725050A7E630_TF755AWHHS9S1M $1 + sudo cryptsetup luksOpen "/dev/disk/by-id/ata-HGST_HTS725050A7E630_TF755AWHHS9S1M" $1 + else + echo "Error! Device $1 is not available" + exit 1 fi ;; "backup") - sudo cryptsetup luksOpen "/dev/disk/by-id/usb-ST950042_0ASG_55DFFFFFFFFF-0:0" $1 + if [ -L "/dev/disk/by-id/usb-ST950042_0ASG_55DFFFFFFFFF-0:0" ]; then + sudo cryptsetup luksOpen "/dev/disk/by-id/usb-ST950042_0ASG_55DFFFFFFFFF-0:0" $1 + else + echo "Error! Device $1 is not available" + exit 1 + fi ;; "media") if [ -L "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80088G0" ]; then sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80088G0" $1 elif [ -L "/dev/disk/by-uuid/e5adbc14-732e-43e8-b6e1-febdfe6d1d3c" ]; then sudo cryptsetup luksOpen "/dev/disk/by-uuid/e5adbc14-732e-43e8-b6e1-febdfe6d1d3c" $1 + else + echo "Error! Device $1 is not available" + exit 1 fi ;; "video") @@ -317,13 +325,29 @@ lopen() { sudo cryptsetup luksOpen "/dev/disk/by-id/ata-ST4000LM016-1N2170_W80092WW" $1 elif [ -L "/dev/disk/by-uuid/5ac700be-e168-495b-b133-42064fa101e4" ]; then sudo cryptsetup luksOpen "/dev/disk/by-uuid/5ac700be-e168-495b-b133-42064fa101e4" $1 + else + echo "Error! Device $1 is not available" + exit 1 fi + ;; + *) + echo "Error! Device $1 is not available" + exit 1 + ;; esac esac if [[ -e "/dev/mapper/$1" ]]; then 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 + fi else - echo "Device is not available." + echo "Error: Device /dev/mapper/$1 is not available." + exit 1 fi } |