45 lines
842 B
Bash
Executable File
45 lines
842 B
Bash
Executable File
#!/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;;
|
|
*)
|
|
TARGET=${1};
|
|
MOUNTDIR="${MOUNTBASEDIR}/${2}";
|
|
shift
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
main
|