-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgproxy
More file actions
executable file
·57 lines (48 loc) · 1.17 KB
/
gproxy
File metadata and controls
executable file
·57 lines (48 loc) · 1.17 KB
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
#!/bin/bash
# toggles proxy for git
function help {
echo "Another way of changing proxy settings for git"
echo "Usage:"
echo " $(basename $0) - toggle proxy"
echo " $(basename $0) status - checks current proxy status"
echo " $(basename $0) [disable/enable] - disables/enables proxy"
echo " $(basename $0) add -g group -n name -h hostname [-u username] [-p port] [-P params] [-f filename]"
echo;
echo "Sample configuration file: .gproxy.cfg.sample"
exit 1
}
function enable_proxy {
if [ -z "$PADDR" ]; then
echo "PADDR variable is not set! Check .gproxy.cfg file!"
help;
fi
git config --global http.proxy $PADDR
}
function disable_proxy {
git config --global --unset http.proxy
}
# sets PADDR variable
source ".gproxy.cfg"
PROXY=$(git config --global -l | grep http.proxy)
if [ "$1" = "status" ]; then
if [ -z "$PROXY" ]; then
echo "Proxy is disabled"
else
echo "Proxy is enabled"
fi
exit
fi
if [ "$1" = "help" ]; then
help;
elif [ "$1" = "enable" -o "$1" = "on" ]; then
enable_proxy
elif [ "$1" = "disable" -o "$1" = "off" ]; then
disable_proxy
else
if [ -z "$PROXY" ]; then
enable_proxy
else
disable_proxy
fi
fi
$0 status