diff --git a/netclient/config/config.go b/netclient/config/config.go index 4487b54f..90820e86 100644 --- a/netclient/config/config.go +++ b/netclient/config/config.go @@ -203,7 +203,6 @@ func readConfig() *ClientConfig { f, err := os.Open(file) if err != nil { nofile = true - fmt.Println("Could not access " + home + "/.netconfig, proceeding...") } defer f.Close() diff --git a/netclient/functions/.local.go.swp b/netclient/functions/.local.go.swp new file mode 100644 index 00000000..0d5dfa1e Binary files /dev/null and b/netclient/functions/.local.go.swp differ diff --git a/netclient/main.go b/netclient/main.go index dbfe8ea7..7a17ccbe 100644 --- a/netclient/main.go +++ b/netclient/main.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "strconv" + "strings" "log" ) @@ -36,7 +37,8 @@ func main() { taccesskey := flag.String("k", "badkey", "an access key generated by the server and used for one-time access (install only)") tserver := flag.String("s", "localhost:50051", "The location (including port) of the remote gRPC server.") tgroup := flag.String("g", "badgroup", "The node group you are attempting to join.") - tnoauto := flag.Bool("na", false, "No auto mode. If true, netmaker will not be installed as a system service and you will have to retrieve updates manually via checkin command.") + tnoauto := flag.Bool("na", false, "No auto mode. If true, netmclient will not be installed as a system service and you will have to retrieve updates manually via checkin command.") + tnoforward := flag.Bool("nf", false, "No Forward mode. If true, netclient will not check for IP forwarding. This may break functionality") command := flag.String("c", "required", "The command to run") @@ -61,12 +63,35 @@ func main() { } + _, err = exec.LookPath("wg") + if err != nil { + log.Println(err) + log.Fatal("WireGuard not installed. Please install WireGuard (wireguard-tools) and try again.") + } + switch *command { case "required": fmt.Println("command flag 'c' is required. Pick one of |install|checkin|update|remove|") os.Exit(1) log.Fatal("Exiting") case "install": + if !*tnoforward { + forward := exec.Command("sysctl", "net.ipv4.ip_forward") + out, err := forward.Output() + + if err != nil { + log.Fatal(err) + } + //s := strings.Split(string(out), " ", "\n") + s := strings.Fields(string(out)) + if err != nil { + log.Fatal(err) + } + if s[2] != "1" { + log.Fatal("It is recommended to enable IP Forwarding. Current status is: " + s[2] + ", but should be 1. if you would like to run without IP Forwarding, re-run with flag '-nf true'") + } + } + fmt.Println("Beginning agent installation.") err := functions.Install(*taccesskey, *tpassword, *tserver, *tgroup, *tnoauto) if err != nil {