Created
December 22, 2011 06:24
-
-
Save golgote/1509226 to your computer and use it in GitHub Desktop.
Shell script for mounting sshfs volumes found on Crunchbanglinux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# A bash script for muotning remote systems using sshfs | |
#------------------------------------------------------------ | |
clear | |
echo "This script will help you mount a remote system using sshfs." | |
echo "" | |
echo -n "Continue? (Y|n) > " | |
read a | |
if [ "$a" = "y" ] || [ "$a" = "Y" ] || \ | |
[ "$a" = "" ]; then | |
type="" | |
until [ "$type" = "1" ] || [ "$type" = "2" ] || \ | |
[ "$type" = "0" ]; do | |
clear | |
echo "Would you like to mount or unmount?" | |
echo "" | |
echo "1. Mount" | |
echo "2. UnMount" | |
echo "" | |
echo "0. Cancel" | |
echo "" | |
echo -n ":> " | |
read type | |
done | |
case $type in | |
1 ) mode=yes | |
;; | |
2 ) mode=no | |
;; | |
0 ) clear && echo "Program cancelled. \n" && exit 0 | |
esac | |
if [ "$mode" = "yes" ]; then | |
# Choose remote host to mount | |
selection="" | |
until [ "$selection" = "1" ] || [ "$selection" = "2" ] || \ | |
[ "$selection" = "3" ] || [ "$selection" = "0" ]; do | |
clear | |
echo "Choose which host to mount. Select 1, 2 or 3:" | |
echo "" | |
echo "1. Example1" | |
echo "2. Example2" | |
echo "3. Example3" | |
echo "" | |
echo "0. Cancel installation" | |
echo "" | |
echo -n ":> " | |
read selection | |
done | |
case $selection in | |
# If no user is specified, it will use your local username | |
1 ) WHERE_TO_MOUNT="ex1" | |
;; | |
2 ) WHERE_TO_MOUNT="ex2" | |
;; | |
3 ) WHERE_TO_MOUNT="ex3" | |
;; | |
0 ) clear && echo "Program cancelled. \n" && exit 0 | |
esac | |
echo "" | |
sleep 1s | |
clear | |
if [ "$WHERE_TO_MOUNT" = "ex1" ]; then | |
clear | |
echo "You will be prompted for your password." | |
echo "" | |
sleep 1s | |
sshfs [email protected]: ~/ex1 | |
echo "" | |
echo "Remote system should now be mounted." | |
echo "" | |
sleep 1s | |
elif [ "$WHERE_TO_MOUNT" = "ex2" ]; then | |
clear | |
echo "You will be prompted for your password." | |
echo "" | |
sleep 1s | |
sshfs shell.example2.org: ~/ex2 | |
echo "" | |
echo "Remote system should now be mounted." | |
echo "" | |
sleep 1s | |
elif [ "$WHERE_TO_MOUNT" = "ex3" ]; then | |
clear | |
echo "You will be prompted for your password." | |
echo "" | |
sleep 1s | |
sshfs ssh.example3.com: ~/ex3 | |
echo "" | |
echo "Remote system should now be mounted." | |
echo "" | |
sleep 1s | |
fi | |
elif [ "$mode" = "no" ]; then | |
# Choose remote host to unmount | |
selection="" | |
until [ "$selection" = "1" ] || [ "$selection" = "2" ] || \ | |
[ "$selection" = "3" ] || [ "$selection" = "0" ]; do | |
clear | |
echo "Choose which host to mount. Select 1, 2 or 3:" | |
echo "" | |
echo "1. Example 1" | |
echo "2. Example 2" | |
echo "3. Example3" | |
echo "" | |
echo "0. Cancel" | |
echo "" | |
echo -n ":> " | |
read selection | |
done | |
case $selection in | |
1 ) WHERE_TO_MOUNT="ex1" | |
;; | |
2 ) WHERE_TO_MOUNT="ex2" | |
;; | |
3 ) WHERE_TO_MOUNT="ex3" | |
;; | |
0 ) clear && echo "Program cancelled. \n" && exit 0 | |
esac | |
echo "" | |
sleep 1s | |
clear | |
if [ "$WHERE_TO_MOUNT" = "ex1" ]; then | |
clear | |
echo "Remote system will now be unmounted." | |
echo "" | |
sleep 1s | |
fusermount -u ~/ex1 | |
echo "" | |
echo "Remote system should now be unmounted." | |
echo "" | |
sleep 1s | |
elif [ "$WHERE_TO_MOUNT" = "ex2" ]; then | |
clear | |
echo "Remote system will now be unmounted." | |
echo "" | |
sleep 1s | |
fusermount -u ~/ex2 | |
echo "" | |
echo "Remote system should now be unmounted." | |
echo "" | |
sleep 1s | |
elif [ "$WHERE_TO_MOUNT" = "ex3" ]; then | |
clear | |
echo "Remote system will now be unmounted." | |
echo "" | |
sleep 1s | |
fusermount -u ~/ex3 | |
echo "" | |
echo "Remote system should now be unmounted." | |
echo "" | |
sleep 1s | |
fi | |
fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment