-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathdetect-proxy.sh
More file actions
executable file
·35 lines (29 loc) · 903 Bytes
/
detect-proxy.sh
File metadata and controls
executable file
·35 lines (29 loc) · 903 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
35
#!/bin/bash
function download-cert() {
# The proxy server hosts the root certificate over HTTP, on a port that is
# published on the host.
AWK_SPLIT='
!fout && /^\r?$/ { fout="docker-proxy.pem"; next }
fout { print > fout }
!fout { print }
'
HOST_IP=$(route -n | awk '/^0.0.0.0/ {print $2}')
echo -e 'GET /squid-internal-static/icons/ca.pem\r\n' \
| nc -q -1 "$HOST_IP" 3128 \
| awk "$AWK_SPLIT" \
| grep -q 'Server: squid'
}
download-cert
if [ $? -ne 0 ]; then
echo "No proxy server detected"
exit 0
fi
grep -q '\-----BEGIN CERTIFICATE-----' docker-proxy.pem
if [ $? -ne 0 ]; then
echo "Proxy detected"
exit 0
fi
echo "SSL-caching proxy server detected. Installing certificate."
# Install CA cert into OS key store
cp docker-proxy.pem /usr/local/share/ca-certificates/docker-proxy.crt
update-ca-certificates