if remote user is root, mount / instead of /home/max

This commit is contained in:
2018-10-02 11:44:14 +02:00
parent 4f3e2d14ee
commit 0079575de8

View File

@@ -128,9 +128,15 @@ function mount {
fi
# Command to mount actually
if [ "$MAN" = "0" ]; then
sshfs -C "$SSH": "$MOUNTDIR"/ -o follow_symlinks &
else
if [ "$MAN" = "0" ]; then # used for hosts in ssh config
# if user of SSH Host is root, use the root directory as SSHPATH instead of $HOME
if [[ $(ssh -G "$SSH" | awk '/^user / { print $2 }') == "root" ]]; then
SSHPATH="/"
else
SSHPATH=
fi
sshfs -C "$SSH":"$SSHPATH" "$MOUNTDIR"/ -o follow_symlinks &
else # used for manually entered or predefined hosts in app's config
echo "$SSHPASS" | sshfs -C -o password_stdin -p "$SSHPORT" "$SSHUSER"@"$SSHHOST":"$SSHPATH" "$MOUNTDIR"/ -o follow_symlinks &
fi