-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreproxy.sh
More file actions
34 lines (30 loc) · 812 Bytes
/
preproxy.sh
File metadata and controls
34 lines (30 loc) · 812 Bytes
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
#!/bin/bash
install_path=$(dirname ${BASH_SOURCE[0]})
source $install_path/preexec/bash-preexec.sh
source $install_path/config.sh
preexec_proxy() {
if [[ -e /sys/class/net/$proxy_interface ]]; then
proxy
else
noproxy
fi
}
# You can call this function with arguments to execute the command
# or without arguments to just modify the current environment
noproxy() {
unset http_proxy https_proxy no_proxy
[ "$#" -eq 0 ] && return
"$@"
return $?
}
# You can call this function with arguments to execute the command
# or without arguments to just modify the current environment
proxy() {
export http_proxy=$proxy_url https_proxy=$proxy_url no_proxy=$proxy_noproxy
[ "$#" -eq 0 ] && return
"$@"
return $?
}
if [ "${proxy_mode}" = "auto" ]; then
preexec_functions+=(preexec_proxy)
fi