2020-01-11 12:49:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
source "${HOME}/bin/script_framework.sh"
|
|
|
|
|
2020-01-11 13:31:31 +00:00
|
|
|
function usage() {
|
2024-09-27 12:47:39 +00:00
|
|
|
echo "Usage: $0 [-h] [-k key] [-p prefix] <port>" >&2
|
2020-01-11 13:31:31 +00:00
|
|
|
}
|
2020-01-11 12:49:05 +00:00
|
|
|
|
2024-09-27 12:47:39 +00:00
|
|
|
args=(-p 31088 master.k8s.kserver.biz)
|
2020-04-06 22:01:29 +00:00
|
|
|
host=localhost
|
2024-09-27 12:47:39 +00:00
|
|
|
key=loki
|
|
|
|
remote="80"
|
2020-01-11 13:31:31 +00:00
|
|
|
|
|
|
|
# Parse options
|
2020-04-06 22:01:29 +00:00
|
|
|
while getopts ":hi:p:v" o; do
|
2020-01-11 13:31:31 +00:00
|
|
|
case "${o}" in
|
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2024-09-27 12:47:39 +00:00
|
|
|
k)
|
|
|
|
key="${OPTARG}"
|
2020-04-06 22:01:29 +00:00
|
|
|
;;
|
2020-01-11 13:31:31 +00:00
|
|
|
p)
|
2024-09-27 12:47:39 +00:00
|
|
|
remote="${OPTARG}:80"
|
2020-01-11 13:31:31 +00:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
fatal "Invalid option -- ${OPTARG}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
|
|
|
|
# Add port
|
|
|
|
port="${1:-}"
|
|
|
|
[[ -n $port ]] || fatal "Missing local port as first argument"
|
2020-01-11 12:49:05 +00:00
|
|
|
|
2024-09-27 12:47:39 +00:00
|
|
|
step "Starting port-forward..."
|
|
|
|
vault-sshadd ${key}
|
2024-09-27 13:00:30 +00:00
|
|
|
exec /usr/bin/ssh -o ControlPath=/tmp/shareport-${port} -R "${remote}:${host}:${port}" "${args[@]}"
|