mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 01:07:41 +08:00
saving netclient changes
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"io"
|
||||
"strings"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -20,6 +21,27 @@ func FileExists(f string) bool {
|
||||
return !info.IsDir()
|
||||
}
|
||||
|
||||
func SetDNS(nameserver string) error {
|
||||
bytes, err := ioutil.ReadFile("/etc/resolv.conf")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resolvstring := string(bytes)
|
||||
// //check whether s contains substring text
|
||||
hasdns := strings.Contains(resolvstring, nameserver)
|
||||
if hasdns {
|
||||
return nil
|
||||
}
|
||||
resolv, err := os.OpenFile("/etc/resolv.conf",os.O_APPEND|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resolv.Close()
|
||||
_, err = resolv.WriteString("nameserver " + nameserver + "\n")
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func ConfigureSystemD(network string) error {
|
||||
/*
|
||||
path, err := os.Getwd()
|
||||
|
Reference in New Issue
Block a user