File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,16 @@ var setupCmd = &cobra.Command{
205
205
}
206
206
}()
207
207
208
+ // Update docker daemon config
209
+ err = config .UpdateDockerDaemonConfig ()
210
+ if err != nil {
211
+ cmd .PrintErr (err .Error ())
212
+ return
213
+ }
214
+
215
+ // Restart docker
216
+ _ = RunCommandWithoutBuffer ("systemctl restart docker" )
217
+
208
218
// Get ip from wireguard address
209
219
ip , _ , err := net .ParseCIDR (config .WireguardConfig .Address )
210
220
if err != nil {
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "encoding/json"
5
+ "fmt"
6
+ "net"
7
+ "os"
8
+ )
9
+
10
+ func (c * AgentConfig ) UpdateDockerDaemonConfig () error {
11
+ // Get ip from wireguard address
12
+ ip , _ , err := net .SplitHostPort (c .SwiftwaveServiceAddress )
13
+ if err != nil {
14
+ return fmt .Errorf ("failed to parse wireguard address: %w" , err )
15
+ }
16
+ config := map [string ]interface {}{
17
+ "live-restore" : true ,
18
+ "iptables" : true ,
19
+ "insecure-registries" : []string {fmt .Sprintf ("%s:3331" , ip )},
20
+ }
21
+ jsonString , err := json .MarshalIndent (config , "" , " " )
22
+ if err != nil {
23
+ return fmt .Errorf ("failed to marshal docker daemon config: %w" , err )
24
+ }
25
+ // Write in /etc/docker/daemon.json
26
+ err = os .WriteFile ("/etc/docker/daemon.json" , []byte (jsonString ), 0644 )
27
+ if err != nil {
28
+ return fmt .Errorf ("failed to write docker daemon config: %w" , err )
29
+ }
30
+ return nil
31
+ }
You can’t perform that action at this time.
0 commit comments