Guest User

Automatic mounting of a davfs virtual drive

a guest
May 15th, 2012
617
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.16 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. service=$1
  4. userdir=/home/ichbins
  5.  
  6. [ -z $service ] && {
  7.   notify-send -u low -i error "Service parameter is missing" "Please, specify a service name"
  8.   exit 1
  9. }
  10.  
  11. isdavmounted=$(mount | grep $service | grep davfs)
  12. isencmounted=$(mount | grep $service | grep encfs)
  13.  
  14. if [ -n "$isencmounted" -o -n "$isdavmounted" ]; then
  15.   #unmount
  16.   [ -n "$isencmounted" ] && {
  17.     fusermount -u "${userdir}/${service}.crypt" && msg="Encfs,"
  18.   }
  19.   [ -n "$isdavmounted" ] && {
  20.     umount "${userdir}/${service}" && msg="${msg}Davfs "
  21.   }
  22.   if [ -n "$msg" ]; then
  23.     notify-send -u low -i info "$service unmounting" "$msg unmouned successfuly!"
  24.   else
  25.     notify-send -u low -i error "$service unmounting" "Failed to unmount $service!"
  26.   fi
  27. else
  28.   #mount
  29.   mount ${userdir}/${service} && {
  30.     msg="Davfs,"
  31.     encfs --extpass="cat ~/.encfs/$service" ${userdir}/${service}/crypt ${userdir}/${service}.crypt/ && {
  32.       msg="${msg}Encfs "
  33.     }
  34.   }
  35.   if [ -n "$msg" ]; then
  36.     notify-send -u low -i info "$service mounting" "$msg mounted successfuly!"
  37.   else
  38.     notify-send -u low -i error "$service mounting" "Failed to mount $service!"
  39.   fi
  40. fi
Advertisement
Add Comment
Please, Sign In to add comment