-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetproxy.sh
executable file
·64 lines (60 loc) · 1.76 KB
/
setproxy.sh
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
#!/bin/bash
echo "1 - Set proxy"
echo "2 - Remove proxy"
echo -e "Option: \c "
read choice
if [ $choice -eq 1 ] ; then
echo "Set proxy"
read -p "Username:" username
echo "Password for $username:"
#
# Password Read Source: mklement0 - Stackoverflow
# http://stackoverflow.com/a/22940001
#
# Begin
password=''
while IFS= read -r -s -n1 char; do
[[ -z $char ]] && { printf '\n'; break; } # ENTER pressed; output \n and break.
if [[ $char == $'\x7f' ]]; then # backspace was pressed
# Remove last char from output variable.
[[ -n $password ]] && password=${password%?}
# Erase '*' to the left.
printf '\b \b'
else
# Add typed char to output variable.
password+=$char
# Print '*' in its stead.
printf '*'
fi
done
# End
echo
git config --global http.proxy http://'students\'$username:[email protected]:80
git config --global https.proxy http://'students\'$username:[email protected]:80
export http_proxy=http://'students\'$username:[email protected]:80
export HTTP_PROXY=$http_proxy
export no_proxy=localhost,127.0.0.1,.wits.ac.za
export NO_PROXY=$no_proxy
export https_proxy=$http_proxy
export HTTPS_PROXY=$http_proxy
export ftp_proxy=$http_proxy
export FTP_PROXY=$http_proxy
export all_proxy=$http_proxy
export ALL_PROXY=$http_proxy
echo "Proxy configured"
echo
else
echo "Remove proxy"
git config --global --unset http.proxy
git config --global --unset https.proxy
unset http_proxy
unset HTTP_PROXY
unset https_proxy
unset HTTPS_PROXY
unset ftp_proxy
unset FTP_PROXY
unset all_proxy
unset ALL_PROXY
unset NO_PROXY
unset no_proxy
fi