Finish the logic

This commit is contained in:
leafee98 2023-09-14 11:47:43 +08:00
commit dcf261e622
2 changed files with 44 additions and 0 deletions

37
proxyenv Executable file
View file

@ -0,0 +1,37 @@
#!/usr/bin/env bash
if [[ -z "$PROXYENV_CONFPATH" ]] ; then
if [[ -e "/etc/proxyenv.conf" ]] ; then
source "/etc/proxyenv.conf"
else
echo "custom configuration location '/etc/proxyenv.conf' not exists" >&2
echo "exiting...'
exit 1
fi
else
if [[ -e "$PROXYENV_CONFPATH" ]] ; then
source "$PROXYENV_CONFPATH"
else
echo "custom configuration location '$PROXYENV_CONFPATH' not exists" >&2
echo "exiting...'
exit 1
fi
fi
if [[ -z "$PROXYENV_TARGET_PROXY" ]] ; then
echo "cannot find PROXYENV_TARGET_PROXY" >&2
echo "exiting...'
exit 1
fi
export PROXY="$PROXYENV_TARGET_PROXY"
export HTTP_PROXY="$PROXYENV_TARGET_PROXY"
export HTTPS_PROXY="$PROXYENV_TARGET_PROXY"
export proxy="$PROXYENV_TARGET_PROXY"
export http_proxy="$PROXYENV_TARGET_PROXY"
export https_proxy="$PROXYENV_TARGET_PROXY"
export NOPROXY="$PROXYENV_NOPROXY"
exec "$@"

7
proxyenv.conf Normal file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# the HTTP_PROXY and other environments variable's final value
PROXYENV_TARGET_PROXY="http://localhost:8888"
# the NOPROXY variable's final value
PROXYENV_NOPROXY="localhost,127.0.0.1,192.168.0.0/16,10.0.0.0/8"