Archived
1
0

Compare commits

..

No commits in common. "412744520eee8018a2b2b2d496c993fc5b5dbd5a" and "4ae4fc5e078f72c55e0e8b6cff2cf3e5c96ad153" have entirely different histories.

2 changed files with 9 additions and 27 deletions

View File

@ -1,15 +1,14 @@
#!/bin/bash
function showHelp() {
echo "ssh-proxy [args] command cmd_args"
echo "ssh-proxy [args] command proxy"
echo ""
echo "args :"
echo " --help Show help"
echo "command :"
echo " status"
echo "command;"
echo " start profile|port target"
echo " stop port"
echo "cmd_args :"
echo "proxy:"
echo " profile Name of the profile (~/.config/ssh-proxy/*)"
echo " port Proxy local port (1024-65535)"
echo " target Proxy target [user@]server[:port]"
@ -24,28 +23,16 @@ case ${1} in
showHelp
exit 0
;;
"status");;
"start" | "stop")
if [ "${2}" == "" ] || [[ "${2}" == */* ]]; then
showHelp
exit 1
fi
;;
"start" | "stop");;
*)
showHelp
exit 1
;;
esac
function showProxyStatus() {
echo -e "Port\tProxy"
echo ""
for FILE in /tmp/ssh-proxy-"${USER}"/*; do
PORT=$(basename "${FILE}")
PROXY=$(grep 'PROXY=' "${FILE}" | sed 's/PROXY=//')
echo -e "${PORT}\t${PROXY}"
done
}
if [ "${2}" == "" ] || [[ "${2}" == */* ]]; then
showHelp
exit 1
fi
function startProxy() {
LOCAL_PORT=0
@ -130,7 +117,6 @@ function startProxy() {
#echo "PROXY_USER=${PROXY_USER}"
#echo "PROXY_SERVER=${PROXY_SERVER}"
#echo "PROXY_SERVER_PORT=${PROXY_SERVER_PORT}"
echo "PROXY=${PROXY_ADDRESS}"
echo "PID=${PID}"
} > "${TMP_FILE}"
}
@ -149,7 +135,6 @@ function stopProxy() {
}
case ${1} in
"status") showProxyStatus;;
"start") startProxy "${2}" "${3}";;
"stop") stopProxy "${2}";;
*) exit 1;;

View File

@ -5,7 +5,7 @@ _ssh-proxy() {
local cur prev words cword args
_init_completion || return
local -r cmdargs="status start stop"
local -r cmdargs="start stop"
local -r cnfargs="--help"
local profiledir=~/.config/ssh-proxy
local tempdir="/tmp/ssh-proxy-${USER}"
@ -30,9 +30,6 @@ _ssh-proxy() {
--help)
return
;;
status)
return
;;
start)
local -r PROFILELIST=$(\ls ${profiledir})
# shellcheck disable=SC2207