-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmount-sshfs
More file actions
executable file
·38 lines (30 loc) · 1.14 KB
/
mount-sshfs
File metadata and controls
executable file
·38 lines (30 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#Check that the user passed in the mount point
if [ -z $1 ] ; then
echo "usage: $0 mount-dir"
exit 1
#Check that the mount point is in /etc/fstab
elif ! cat /etc/fstab | grep 'sshfs.*sun0' > /dev/null ; then
zenity --error --title='Mount sshfs Script' --text "$1 is not a valid sshfs mount point"
exit 1
fi
#See if the passed in mount point is already mounted.
if cat /etc/mtab | grep "$1" > /dev/null ; then
#It is alraedy mounted, so the user must want us to unmount it.
if ! umount -v $1 &> /tmp/mount-sshfs.log ; then
#Umount failed, get the error message
EMSG=`cat /tmp/mount-sshfs.log`
#Display and error dialog
zenity --error --title='Mount sshfs Script' --text="Failed to unmount!\n\n$EMSG"
exit 1
fi
else
#It is not mounted, so the user wants us to mount it.
if ! mount -v $1 &> /tmp/mount-sshfs.log ; then
#Mount failed, get the error message
EMSG=`cat /tmp/mount-sshfs.log`
#Display and error dialog
zenity --error --title='Mount sshfs Script' --text="Failed to mount!\n\n$EMSG"
exit 1
fi
fi