|
|
|
|
@@ -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)"
|
|
|
|
|
@@ -24,7 +26,7 @@ case ${1} in
|
|
|
|
|
showHelp
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
|
|
|
|
"status");;
|
|
|
|
|
"status" | "startall" | "stopall");;
|
|
|
|
|
"start" | "stop")
|
|
|
|
|
if [ "${2}" == "" ] || [[ "${2}" == */* ]]; then
|
|
|
|
|
showHelp
|
|
|
|
|
@@ -38,15 +40,15 @@ case ${1} in
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
function showProxyStatus() {
|
|
|
|
|
echo -e "Port\tProxy"
|
|
|
|
|
if [ -d /tmp/ssh-proxy-"${USER}" ]; then
|
|
|
|
|
if [ "$(find /tmp/ssh-proxy-"${USER}" -maxdepth 0 -empty -exec echo 1 \;)" == "" ]; then
|
|
|
|
|
for FILE in /tmp/ssh-proxy-"${USER}"/*; do
|
|
|
|
|
PORT=$(basename "${FILE}")
|
|
|
|
|
PROXY=$(grep 'PROXY=' "${FILE}" | sed 's/PROXY=//')
|
|
|
|
|
echo -e "${PORT}\t${PROXY}"
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
if [ -d /tmp/ssh-proxy-"${USER}" ] && [ "$(find /tmp/ssh-proxy-"${USER}" -maxdepth 0 -empty -exec echo 1 \;)" == "" ]; then
|
|
|
|
|
echo -e "Port\tProxy"
|
|
|
|
|
for FILE in /tmp/ssh-proxy-"${USER}"/*; do
|
|
|
|
|
PORT=$(basename "${FILE}")
|
|
|
|
|
PROXY=$(grep 'PROXY=' "${FILE}" | sed 's/PROXY=//')
|
|
|
|
|
echo -e "${PORT}\t${PROXY}"
|
|
|
|
|
done
|
|
|
|
|
else
|
|
|
|
|
echo "No open proxy"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -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
|
|
|
|
|
|