diff --git a/bin/ssh-proxy b/bin/ssh-proxy index 56c1b74..1ee632a 100755 --- a/bin/ssh-proxy +++ b/bin/ssh-proxy @@ -9,6 +9,8 @@ function showHelp() { echo " status" echo " start profile|port target" echo " stop port" + echo " startall" + echo " stopall" echo "cmd_args :" echo " profile Name of the profile (~/.config/ssh-proxy/*)" echo " port Proxy local port (1024-65535)" @@ -151,9 +153,25 @@ function stopProxy() { rm "${TMP_FILE}" } +function startAll() { + for FILE in ~/.config/ssh-proxy/*; do + PROFILE=$(basename "${FILE}") + startProxy "${PROFILE}" + done +} + +function stopAll() { + for FILE in /tmp/ssh-proxy-"${USER}"/*; do + PORT=$(basename "${FILE}") + stopProxy "${PORT}" + done +} + case ${1} in "status") showProxyStatus;; "start") startProxy "${2}" "${3}";; "stop") stopProxy "${2}";; + "startall") startAll;; + "stopall") stopAll;; *) exit 1;; esac diff --git a/completion/bash/ssh-proxy b/completion/bash/ssh-proxy index 4f4ab5b..babb9db 100644 --- a/completion/bash/ssh-proxy +++ b/completion/bash/ssh-proxy @@ -5,7 +5,7 @@ _ssh-proxy() { local cur prev words cword args _init_completion || return - local -r cmdargs="status start stop" + local -r cmdargs="status start stop startall stopall" local -r cnfargs="--help" local profiledir=~/.config/ssh-proxy local tempdir="/tmp/ssh-proxy-${USER}" @@ -30,7 +30,7 @@ _ssh-proxy() { --help) return ;; - status) + status | startall | stopall) return ;; start)