File tree Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Expand file tree Collapse file tree 1 file changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -121,9 +121,26 @@ http {
121
121
alias /ca/ca.crt;
122
122
}
123
123
124
- location /setup {
124
+ location /setup/systemd {
125
125
add_header "Content-type" "text/plain" always;
126
126
return 200 '
127
+ set -e
128
+
129
+ if [ ! -d /etc/systemd ]; then
130
+ echo "Not a systemd system"
131
+ exit 1
132
+ fi
133
+
134
+ if [[ $EUID -ne 0 ]]; then
135
+ echo "Must be root to change system files"
136
+ exit 1
137
+ fi
138
+
139
+ if [[ $(systemctl is-active --quiet docker.service) -ne 0 ]]; then
140
+ echo "Docker service missing"
141
+ exit 1
142
+ fi
143
+
127
144
mkdir -p /etc/systemd/system/docker.service.d
128
145
cat << EOD > /etc/systemd/system/docker.service.d/http-proxy.conf
129
146
[Service]
@@ -132,19 +149,23 @@ EOD
132
149
133
150
# Get the CA certificate from the proxy and make it a trusted root.
134
151
curl $scheme ://$http_host /ca.crt > /usr/share/ca-certificates/docker_registry_proxy.crt
135
- echo "docker_registry_proxy.crt" >> /etc/ca-certificates.conf
152
+ if fgrep -q "docker_registry_proxy.crt" /etc/ca-certificates.conf ; then
153
+ echo "certificate refreshed"
154
+ else
155
+ echo "docker_registry_proxy.crt" >> /etc/ca-certificates.conf
156
+ fi
157
+
136
158
update-ca-certificates --fresh
137
159
138
160
# Reload systemd
139
161
systemctl daemon-reload
140
162
141
163
# Restart dockerd
142
164
systemctl restart docker.service
165
+ echo "Docker configured with HTTPS_PROXY=$scheme ://$http_host /"
143
166
' ;
144
- }
145
-
146
- # @TODO: add a dynamic root path that generates instructions for usage on docker clients
147
- }
167
+ } # end location /setup/systemd
168
+ } # end server
148
169
149
170
150
171
# The caching layer
You can’t perform that action at this time.
0 commit comments