sshfs-mount/sshfs-mount

45 lines
842 B
Plaintext
Raw Normal View History

2024-03-16 22:46:35 +00:00
#!/bin/bash
declare TARGET=""
declare MOUNTBASEDIR=""
declare MOUNTDIR=""
declare BASTION=""
showHelp() {
echo "${0}"
echo ""
echo "usage :"
echo "${0} [options] target dirname"
echo "options :"
echo " -b|--bastion ip|dnsname"
echo " -d|--mountbase ~/Remotes"
}
main() {
if [ ! -d "${MOUNTDIR}" ]; then
mkdir -p "${MOUNTDIR}"
fi
if [ "${BASTION}" == "" ]; then
sshfs -o reconnect "${TARGET}" "${MOUNTDIR}"
else
sshfs -o reconnect -o ssh_command="ssh -t ${BASTION} ssh" "${TARGET}" "${MOUNTDIR}"
fi
}
MOUNTBASEDIR=$(realpath ~/Remotes)
while [ ${#} -gt 0 ]; do
case ${1} in
--help) showHelp; exit 0;;
-b | --bastion) BASTION="${2}"; shift; shift;;
-d | --mountbase) MOUNTBASEDIR=$(realpath "${2}"); shift; shift;;
2024-03-16 23:02:25 +00:00
*)
TARGET=${1};
MOUNTDIR="${MOUNTBASEDIR}/${2}";
shift
shift
;;
2024-03-16 22:46:35 +00:00
esac
done
main