diff options
Diffstat (limited to '.local/bin/sshfs-mount')
-rwxr-xr-x | .local/bin/sshfs-mount | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/.local/bin/sshfs-mount b/.local/bin/sshfs-mount new file mode 100755 index 0000000..0e2352c --- /dev/null +++ b/.local/bin/sshfs-mount @@ -0,0 +1,19 @@ +#!/bin/sh -eu + +input="$1" +server="${input#*@}" +folder="${input%@*}" +mount_path="$HOME/Shares/SSHFS/$folder" + +[ "${2:-}" = 'stop' ] && { fusermount -u "$mount_path" || true; }; +[ "${2:-}" = 'stop' ] && exit; + +# evaulate the keychain +pidof ssh-agent || { printf "No ssh-agent available.\n"; exit 1; }; +eval "$(keychain --dir "$HOME"/.cache/keychain --eval --agents ssh -Q --quiet "$HOME"/.ssh/mobile)"; + +# mount the directory +mkdir -p "$mount_path"; +fusermount -u "$mount_path" || true; +# TODO: Add setting remote server path with argument +sshfs -f -o follow_symlinks,idmap=user,identityfile="$HOME"/.ssh/mobile,identityfile="$HOME"/.ssh/ansible root@"$server":/ "$mount_path"; |