-
Notifications
You must be signed in to change notification settings - Fork 1
/
chtproxy-010-160-128-028.bash
48 lines (40 loc) · 1.37 KB
/
chtproxy-010-160-128-028.bash
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
#!/bin/bash
# CHT Proxy Server IP
CHT_PROXY_IP="10.160.128.28"
# CHT Proxy Server Port
CHT_PROXY_PORT="8080"
# CHT Proxy
CHT_PROXY="http://${CHT_PROXY_IP}:${CHT_PROXY_PORT}/"
if [ ! -f "/etc/systemd/system/docker.service.d/http-proxy.conf" ]; then
# Set /etc/apt/apt.conf
echo "Acquire::http::Proxy \"${CHT_PROXY}\";" >> "/etc/apt/apt.conf" 2>&1
# Set /etc/default/docker
echo "export http_proxy=\"${CHT_PROXY}\"" >> "/etc/default/docker" 2>&1
# Set /etc/systemd/system/docker.service.d/http-proxy.conf
mkdir –p '/etc/systemd/system/docker.service.d'
echo "[Service]" >> "/etc/systemd/system/docker.service.d/http-proxy.conf" 2>&1
echo "Environment=\"HTTP_PROXY=${CHT_PROXY}\"" >> "/etc/systemd/system/docker.service.d/http-proxy.conf" 2>&1
# Set ~/.bashrc
echo "export http_proxy=\"${CHT_PROXY}\"" >> "${HOME}/.bashrc" 2>&1
echo "export https_proxy=\"${CHT_PROXY}\"" >> "${HOME}/.bashrc" 2>&1
echo "export HTTP_PROXY=\"${CHT_PROXY}\"" >> "${HOME}/.bashrc" 2>&1
echo "export HTTPS_PROXY=\"${CHT_PROXY}\"" >> "${HOME}/.bashrc" 2>&1
sudo service docker restart
sudo systemctl daemon-reload
sudo systemctl restart docker
# for docker build and docker run
mkdir -p ~/.docker
cat << END > ~/.docker/config.json
{
"proxies":
{
"default":
{
"httpProxy": "${CHT_PROXY}",
"httpsProxy": "${CHT_PROXY}",
"noProxy": "localhost,127.0.0.1"
}
}
}
END
fi