Add status command
This commit is contained in:
parent
b95b557fc1
commit
412744520e
@ -24,16 +24,28 @@ case ${1} in
|
|||||||
showHelp
|
showHelp
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"start" | "stop");;
|
"status");;
|
||||||
|
"start" | "stop")
|
||||||
|
if [ "${2}" == "" ] || [[ "${2}" == */* ]]; then
|
||||||
|
showHelp
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
showHelp
|
showHelp
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
if [ "${2}" == "" ] || [[ "${2}" == */* ]]; then
|
|
||||||
showHelp
|
function showProxyStatus() {
|
||||||
exit 1
|
echo -e "Port\tProxy"
|
||||||
fi
|
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
|
||||||
|
}
|
||||||
|
|
||||||
function startProxy() {
|
function startProxy() {
|
||||||
LOCAL_PORT=0
|
LOCAL_PORT=0
|
||||||
@ -118,6 +130,7 @@ function startProxy() {
|
|||||||
#echo "PROXY_USER=${PROXY_USER}"
|
#echo "PROXY_USER=${PROXY_USER}"
|
||||||
#echo "PROXY_SERVER=${PROXY_SERVER}"
|
#echo "PROXY_SERVER=${PROXY_SERVER}"
|
||||||
#echo "PROXY_SERVER_PORT=${PROXY_SERVER_PORT}"
|
#echo "PROXY_SERVER_PORT=${PROXY_SERVER_PORT}"
|
||||||
|
echo "PROXY=${PROXY_ADDRESS}"
|
||||||
echo "PID=${PID}"
|
echo "PID=${PID}"
|
||||||
} > "${TMP_FILE}"
|
} > "${TMP_FILE}"
|
||||||
}
|
}
|
||||||
@ -136,6 +149,7 @@ function stopProxy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
|
"status") showProxyStatus;;
|
||||||
"start") startProxy "${2}" "${3}";;
|
"start") startProxy "${2}" "${3}";;
|
||||||
"stop") stopProxy "${2}";;
|
"stop") stopProxy "${2}";;
|
||||||
*) exit 1;;
|
*) exit 1;;
|
||||||
|
@ -5,7 +5,7 @@ _ssh-proxy() {
|
|||||||
local cur prev words cword args
|
local cur prev words cword args
|
||||||
_init_completion || return
|
_init_completion || return
|
||||||
|
|
||||||
local -r cmdargs="start stop"
|
local -r cmdargs="status start stop"
|
||||||
local -r cnfargs="--help"
|
local -r cnfargs="--help"
|
||||||
local profiledir=~/.config/ssh-proxy
|
local profiledir=~/.config/ssh-proxy
|
||||||
local tempdir="/tmp/ssh-proxy-${USER}"
|
local tempdir="/tmp/ssh-proxy-${USER}"
|
||||||
@ -30,6 +30,9 @@ _ssh-proxy() {
|
|||||||
--help)
|
--help)
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
|
status)
|
||||||
|
return
|
||||||
|
;;
|
||||||
start)
|
start)
|
||||||
local -r PROFILELIST=$(\ls ${profiledir})
|
local -r PROFILELIST=$(\ls ${profiledir})
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
|
Reference in New Issue
Block a user