added manual ssh input; improved fusermount strategy
This commit is contained in:
38
mnt-sftp.sh
38
mnt-sftp.sh
@@ -18,7 +18,7 @@ function mount {
|
|||||||
--text="Please choose. Cancel to unmount drives." \
|
--text="Please choose. Cancel to unmount drives." \
|
||||||
--title="Choose SSH server" \
|
--title="Choose SSH server" \
|
||||||
--column "Preconfigured SSH servers" \
|
--column "Preconfigured SSH servers" \
|
||||||
${PRESSH[*]}); then
|
"<manual input>" ${PRESSH[*]}); then
|
||||||
unmountquestion # If you press cancel, it should ask you to unmount all drives
|
unmountquestion # If you press cancel, it should ask you to unmount all drives
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -26,13 +26,34 @@ function mount {
|
|||||||
# This command cuts of everything after |
|
# This command cuts of everything after |
|
||||||
SSH=$(echo $SSH | awk -F\| '{ print $1 }')
|
SSH=$(echo $SSH | awk -F\| '{ print $1 }')
|
||||||
|
|
||||||
|
if [ "$SSH" == "<manual input>" ]; then
|
||||||
|
MAN=1
|
||||||
|
SSHUSER=$(zenity --entry --text "SSH user" --title "Enter SSH user")
|
||||||
|
SSHPASS=$(zenity --entry --hide-text --text "SSH password" --title "Enter SSH password")
|
||||||
|
SSHHOST=$(zenity --entry --text "SSH host" --title "Enter SSH host")
|
||||||
|
SSHPORT=$(zenity --entry --text "SSH port (default 22)" --title "Enter SSH port")
|
||||||
|
SSHPATH=$(zenity --entry --text "Desired root directory (default /)" --title "Enter SSH root directory")
|
||||||
|
if [ "$SSHPORT" == "" ]; then
|
||||||
|
SSHPORT=22
|
||||||
|
fi
|
||||||
|
if [ "$SSHPATH" == "" ]; then
|
||||||
|
SSHPATH="/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SSH="$SSHUSER-$RANDOM"
|
||||||
|
fi
|
||||||
|
|
||||||
# Make a local directory if not available
|
# Make a local directory if not available
|
||||||
if [ ! -e "$LOCALMOUNTDIR"/"$SSH" ]; then
|
if [ ! -e "$LOCALMOUNTDIR"/"$SSH" ]; then
|
||||||
mkdir -p "$LOCALMOUNTDIR"/"$SSH"
|
mkdir -p "$LOCALMOUNTDIR"/"$SSH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Command to mount actually
|
# Command to mount actually
|
||||||
|
if [ $MAN = 0 ]; then
|
||||||
sshfs "$SSH": "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks &
|
sshfs "$SSH": "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks &
|
||||||
|
else
|
||||||
|
echo "$SSHPASS" | sshfs -o password_stdin -p "$SSHPORT" "$SSHUSER"@"$SSHHOST":"$SSHPATH" "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks &
|
||||||
|
fi
|
||||||
|
|
||||||
quitquestion # one more ssh server or quit?
|
quitquestion # one more ssh server or quit?
|
||||||
|
|
||||||
@@ -50,11 +71,20 @@ function unmountquestion {
|
|||||||
|
|
||||||
# Procedure to unmount all preconfigured SSHFS drives and exit program afterwards
|
# Procedure to unmount all preconfigured SSHFS drives and exit program afterwards
|
||||||
function unmount {
|
function unmount {
|
||||||
for ((i = 0; i < ${#PRESSH[*]}; i++))
|
#for ((i = 0; i < ${#PRESSH[*]}; i++))
|
||||||
|
#do
|
||||||
|
#fusermount -u "$LOCALMOUNTDIR"/"${PRESSH[$i]}"
|
||||||
|
#echo ""${PRESSH[$i]}" unmounted."
|
||||||
|
#done
|
||||||
|
|
||||||
|
for FILE in "$LOCALMOUNTDIR"/*;
|
||||||
do
|
do
|
||||||
fusermount -u "$LOCALMOUNTDIR"/"${PRESSH[$i]}"
|
if [ "$(cat /etc/mtab | grep -q "$FILE"; echo $?)" == "0" ]; then
|
||||||
echo ""${PRESSH[$i]}" unmounted."
|
fusermount -u "$FILE"
|
||||||
|
echo "$FILE unmounted."
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user