change indent tabs -> spaces

This commit is contained in:
2017-04-05 16:11:10 +02:00
parent 7d4dd1f9e2
commit 43b176b79a

View File

@@ -36,7 +36,7 @@ source config.cfg
# Add SSH key to local keyring if not already happened # Add SSH key to local keyring if not already happened
function sshadd { function sshadd {
ssh-add -l >/dev/null || ssh-add ssh-add -l >/dev/null || ssh-add
} }
for ((i = 0; i < ${#PRESSH[*]}; i++)) for ((i = 0; i < ${#PRESSH[*]}; i++))
@@ -55,114 +55,114 @@ SSHLIST=$(grep -E "Host\s[[:alnum:]]" $SSHCONFIG | awk -F' ' '{ print $2 }')
# Choose preconfigured HOST to mount # Choose preconfigured HOST to mount
function mount { function mount {
if ! SSH=$(zenity --list \ if ! SSH=$(zenity --list \
--height=400 \ --height=400 \
--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 "Available SSH servers" \
"<manual input>" $SSHLIST ${PRESSHLIST[*]}); then "<manual input>" $SSHLIST ${PRESSHLIST[*]}); 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
# If you double click on an entry, it gives 'server1|server1' as result instead of 'server1' # If you double click on an entry, it gives 'server1|server1' as result instead of 'server1'
# 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 }')
## Recognize if the input was entered manually, by .ssh/config or by the predefined SSH list in config.cfg ## Recognize if the input was entered manually, by .ssh/config or by the predefined SSH list in config.cfg
ISPRE=$(echo ${PRESSHLIST[@]} | grep -q "$SSH" ; echo $?) ISPRE=$(echo ${PRESSHLIST[@]} | grep -q "$SSH" ; echo $?)
if [ "$SSH" == "<manual input>" ]; then if [ "$SSH" == "<manual input>" ]; then
MAN="1" MAN="1"
SSHUSER=$(zenity --entry --text "SSH user" --title "Enter SSH user") SSHUSER=$(zenity --entry --text "SSH user" --title "Enter SSH user")
SSHHOST=$(zenity --entry --text "SSH host" --title "Enter SSH host") SSHHOST=$(zenity --entry --text "SSH host" --title "Enter SSH host")
SSHPORT=$(zenity --entry --text "SSH port (default 22)" --title "Enter SSH port") SSHPORT=$(zenity --entry --text "SSH port (default 22)" --title "Enter SSH port")
SSHPASS=$(zenity --entry --hide-text --text "SSH password" --title "Enter SSH password") SSHPASS=$(zenity --entry --hide-text --text "SSH password" --title "Enter SSH password")
SSHPATH=$(zenity --entry --text "Desired root directory on server (default /)" --title "Enter SSH root directory") SSHPATH=$(zenity --entry --text "Desired root directory on server (default /)" --title "Enter SSH root directory")
if [ "$SSHPORT" == "" ]; then if [ "$SSHPORT" == "" ]; then
SSHPORT=22 SSHPORT=22
fi fi
if [ "$SSHPATH" == "" ]; then if [ "$SSHPATH" == "" ]; then
SSHPATH="/" SSHPATH="/"
fi fi
SSH="m-$SSHUSER-$RANDOM" SSH="m-$SSHUSER-$RANDOM"
elif [ "$ISPRE" == "0" ]; then elif [ "$ISPRE" == "0" ]; then
MAN="1" MAN="1"
# Detect which predefined host was chosen and set variables accordingly # Detect which predefined host was chosen and set variables accordingly
for ((i = 0; i < ${#PRESSHLIST[*]}; i++)) for ((i = 0; i < ${#PRESSHLIST[*]}; i++))
do do
if [ "$(echo ${PRESSHLIST[$i]} | grep -q "$SSH" ; echo $?)" == "0" ]; then if [ "$(echo ${PRESSHLIST[$i]} | grep -q "$SSH" ; echo $?)" == "0" ]; then
SSHUSER=${PREUSER[$i]} SSHUSER=${PREUSER[$i]}
SSHHOST=${PREHOST[$i]} SSHHOST=${PREHOST[$i]}
SSHPORT=${PREPORT[$i]} SSHPORT=${PREPORT[$i]}
SSHPASS=${PREPASS[$i]} SSHPASS=${PREPASS[$i]}
SSHPATH=${PREPATH[$i]} SSHPATH=${PREPATH[$i]}
fi fi
done done
SSH="p-$SSHUSER-$RANDOM" SSH="p-$SSHUSER-$RANDOM"
else else
MAN="0" MAN="0"
fi 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 if [ "$MAN" = "0" ]; then
sshfs -C "$SSH": "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks & sshfs -C "$SSH": "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks &
else else
echo "$SSHPASS" | sshfs -C -o password_stdin -p "$SSHPORT" "$SSHUSER"@"$SSHHOST":"$SSHPATH" "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks & echo "$SSHPASS" | sshfs -C -o password_stdin -p "$SSHPORT" "$SSHUSER"@"$SSHHOST":"$SSHPATH" "$LOCALMOUNTDIR"/"$SSH"/ -o follow_symlinks &
fi fi
quitquestion # one more ssh server or quit? quitquestion # one more ssh server or quit?
} }
# Ask if all preconfigured SSHFS drives should be unmounted # Ask if all preconfigured SSHFS drives should be unmounted
function unmountquestion { function unmountquestion {
zenity --question --text="Unmount all preconfigured\nSSHFS drives now?" zenity --question --text="Unmount all configured\nSSHFS drives now?"
if [ "$?" = "0" ]; then if [ "$?" = "0" ]; then
unmount # unmount function unmount # unmount function
else else
exit 0 exit 0
fi fi
} }
# 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 FILE in "$LOCALMOUNTDIR"/*; for FILE in "$LOCALMOUNTDIR"/*;
do do
if [ "$(cat /etc/mtab | grep -q "$FILE"; echo $?)" == "0" ]; then if [ "$(cat /etc/mtab | grep -q "$FILE"; echo $?)" == "0" ]; then
fusermount -u "$FILE" fusermount -u "$FILE"
echo "$FILE unmounted." echo "$FILE unmounted."
fi fi
done done
# Remove all empty directories which have been created by the manual/predefined mount process (m-XYZ-$RANDOM) # Remove all empty directories which have been created by the manual/predefined mount process (m-XYZ-$RANDOM)
find "$LOCALMOUNTDIR"/ -maxdepth 1 -type d -empty -regextype sed -regex ".*/[pm]-.\+\?-[0-9]\{2,6\}" -delete find "$LOCALMOUNTDIR"/ -maxdepth 1 -type d -empty -regextype sed -regex ".*/[pm]-.\+\?-[0-9]\{2,6\}" -delete
exit 0 exit 0
} }
# Should another SSHFS storage be mounted? # Should another SSHFS storage be mounted?
function quitquestion { function quitquestion {
zenity --question \ zenity --question \
--text="Mount another SSHFS storage?" --text="Mount another SSHFS storage?"
if [ "$?" = "1" ]; then if [ "$?" = "1" ]; then
exit 0 exit 0
fi fi
} }
sshadd # sshadd function sshadd # sshadd function
# Loop for endless mounts until stopped by unmount or unmountquestion # Loop for endless mounts until stopped by unmount or unmountquestion
while : while :
do do
mount # mount function mount # mount function
done done