From 4dfe68a54bfbbcbc68ea964178faf07868634444 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 5 Apr 2024 15:07:25 +1300 Subject: [PATCH] add mount-sftp script --- scripts/mount-sftp.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/mount-sftp.sh diff --git a/scripts/mount-sftp.sh b/scripts/mount-sftp.sh new file mode 100755 index 0000000..ddebf55 --- /dev/null +++ b/scripts/mount-sftp.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +LOCAL_USER=$(id -un) +MOUNT_PATH="/home/$LOCAL_USER/sftp" + +if [ ! -d "$MOUNT_PATH" ]; then + mkdir -p "$MOUNT_PATH" +fi + +CREDS=$(cat "/home/$LOCAL_USER/.sftp.json") +USER=$(echo $CREDS | jq -r '.user') +PASS=$(echo $CREDS | jq -r '.pass') +HOST=$(echo $CREDS | jq -r '.host') + +echo "Mounting SFTP server..." + +echo $PASS | sshfs "$USER@$HOST:/" "$MOUNT_PATH" \ + -o password_stdin \ + -o reconnect \ + -o compression=yes