From 9635590322ef5586dd411407f0ae786f505912b4 Mon Sep 17 00:00:00 2001 From: worker-9 Date: Wed, 28 Jul 2021 16:40:13 -0400 Subject: [PATCH] moved db call and removed grpc stuff --- config/dnsconfig/Corefile | 2 +- config/dnsconfig/netmaker.hosts | 5 ----- main.go | 19 ++++++------------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/config/dnsconfig/Corefile b/config/dnsconfig/Corefile index 26260078..5602d141 100644 --- a/config/dnsconfig/Corefile +++ b/config/dnsconfig/Corefile @@ -1,4 +1,4 @@ -pissant comms { +example.com { reload 15s hosts /root/dnsconfig/netmaker.hosts { fallthrough diff --git a/config/dnsconfig/netmaker.hosts b/config/dnsconfig/netmaker.hosts index ff8c81ef..e69de29b 100644 --- a/config/dnsconfig/netmaker.hosts +++ b/config/dnsconfig/netmaker.hosts @@ -1,5 +0,0 @@ -11.22.44.1 netmaker.pissant -11.22.44.3 node-mtxy5.pissant -11.22.44.5 node-vnqlu.pissant -11.22.44.4 ubuntu-do.pissant ubuntu.pissant -11.22.44.2 alex-laptop.pissant porngood.pissant diff --git a/main.go b/main.go index 0d70239f..df9792b6 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,6 @@ import ( "github.com/gravitl/netmaker/functions" nodepb "github.com/gravitl/netmaker/grpc" "github.com/gravitl/netmaker/servercfg" - "github.com/gravitl/netmaker/serverctl" "google.golang.org/grpc" ) @@ -28,8 +27,13 @@ func main() { startControllers() // start the grpc or rest endpoints } -func checkModes() { // Client Mode Prereq Check +func initialize() { // Client Mode Prereq Check var err error + if err = database.InitializeDatabase(); err != nil { + log.Println("Error connecting to database.") + log.Fatal(err) + } + log.Println("database successfully connected.") cmd := exec.Command("id", "-u") output, err := cmd.Output() @@ -45,7 +49,6 @@ func checkModes() { // Client Mode Prereq Check if uid != 0 { log.Fatal("To run in client mode requires root privileges. Either disable client mode or run with sudo.") } - database.InitializeDatabase() if servercfg.IsDNSMode() { err := functions.SetDNSDir() @@ -56,16 +59,6 @@ func checkModes() { // Client Mode Prereq Check } -func initialize() { - checkModes() // check which flags are set and if root or not - if servercfg.IsGRPCWireGuard() { - if err := serverctl.InitServerWireGuard(); err != nil { - log.Fatal(err) - } - } - functions.PrintUserLog("netmaker", "successfully created db tables if not present", 1) -} - func startControllers() { var waitnetwork sync.WaitGroup //Run Agent Server