forked from utmstack/UTMStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.go
More file actions
38 lines (31 loc) · 762 Bytes
/
system.go
File metadata and controls
38 lines (31 loc) · 762 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
36
37
38
package main
import (
"errors"
"os"
"github.com/AtlasInsideCorp/UTMStackInstaller/utils"
)
func PrepareSystem() error {
sysctl := []string{
"vm.max_map_count=262144",
"net.ipv6.conf.all.disable_ipv6=1",
"net.ipv6.conf.default.disable_ipv6=1",
"net.ipv4.tcp_keepalive_time=600",
"net.ipv4.tcp_keepalive_intvl=60",
"net.ipv4.tcp_keepalive_probes=3",
}
f, err := os.OpenFile("/etc/sysctl.conf", os.O_APPEND|os.O_CREATE|os.O_WRONLY, os.ModePerm)
if err != nil {
return err
}
defer f.Close()
for _, config := range sysctl {
if err := utils.RunCmd("sysctl", "-w", config); err != nil {
return errors.New("failed to set sysctl config")
}
_, err = f.WriteString(config + "\n")
if err != nil {
return err
}
}
return nil
}