blob: 8829ac8c98e0f6a7dd284e9f15a5281da84394dc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#!/bin/sh
PREFIX=@PREFIX@
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"
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 0;;
p) ROOT=$OPTARG;;
'?') usage "1" >&2;;
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
export no_proxy=localhost
__EOF__
# busybox wget does not handle http proxies well
apk add --quiet --no-progress wget
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
|