mirror of
https://github.com/zerotier/edge.git
synced 2026-05-22 16:25:05 -07:00
71 lines
1.2 KiB
Bash
Executable File
71 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
PREFIX=
|
|
for i in ./libalpine.sh $PREFIX/lib/libalpine.sh; do
|
|
[ -e $i ] && . $i && break
|
|
done
|
|
|
|
usage() {
|
|
cat <<-__EOF__
|
|
usage: setup-proxy [-hq] [PROXYURL]
|
|
|
|
Setup http proxy
|
|
|
|
options:
|
|
-h Show this help
|
|
-q Quiet mode
|
|
|
|
If PROXYURL is not specified user will be prompted.
|
|
__EOF__
|
|
exit 1
|
|
}
|
|
|
|
|
|
|
|
while getopts "hp:q" opt; do
|
|
case "$opt" in
|
|
q) quiet=1;;
|
|
h) usage;;
|
|
p) ROOT=$OPTARG;;
|
|
esac
|
|
done
|
|
|
|
shift $(( $OPTIND - 1))
|
|
|
|
proxyurl="$1"
|
|
|
|
PROFILE="$ROOT/etc/profile.d/proxy.sh"
|
|
|
|
if [ -f "$PROFILE" ] ; then
|
|
. $PROFILE
|
|
fi
|
|
|
|
suggest=${http_proxy:-none}
|
|
while true; do
|
|
case "$proxyurl" in
|
|
http://*) break;;
|
|
none) proxyurl= ; break;;
|
|
esac
|
|
ask "HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none')" $suggest
|
|
proxyurl=$resp
|
|
done
|
|
|
|
if [ -z "$proxyurl" ]; then
|
|
rm -f "$PROFILE"
|
|
else
|
|
mkdir -p "${PROFILE%/*}"
|
|
cat >"$PROFILE" <<-__EOF__
|
|
# this file was generated with and might get overwritten by setup-proxy
|
|
|
|
export http_proxy=$proxyurl
|
|
export https_proxy=$proxyurl
|
|
export ftp_proxy=$proxyurl
|
|
__EOF__
|
|
fi
|
|
|
|
[ -e "$PROFILE" ] || exit 1
|
|
|
|
if [ -z "$quiet" ]; then
|
|
echo -e "\nTo make changes active please do login again or source $PROFILE\nwith \". $PROFILE\""
|
|
fi
|