Browse Source

runs, but need to remove resolvectl command

afeiszli 3 years ago
parent
commit
5d786740d7

+ 22 - 0
docker/Dockerfile-netclient-slim-solo

@@ -0,0 +1,22 @@
+FROM gravitl/builder:latest as builder
+# add glib support daemon manager
+WORKDIR /app
+
+COPY . .
+
+ENV GO111MODULE=auto
+
+RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 /usr/local/go/bin/go build -ldflags="-w -s" -o netclient-app netclient/main.go
+
+FROM alpine:3.13.6
+
+RUN apk add gcompat iptables && mkdir -p /etc/netclient
+# set the working directory
+WORKDIR /root/
+
+COPY --from=builder /app/netclient-app /etc/netclient/netclient
+COPY --from=builder /app/scripts/netclient.sh .
+
+RUN chmod 0755 /etc/netclient/netclient && chmod 0755 netclient.sh
+
+ENTRYPOINT ["./netclient.sh"]

+ 17 - 2
netclient/daemon/macos.go

@@ -4,18 +4,33 @@ import (
 	"io/ioutil"
 	"log"
 	"os"
-
+	"path/filepath"
 	"github.com/gravitl/netmaker/netclient/ncutils"
 )
 
 const MAC_SERVICE_NAME = "com.gravitl.netclient"
 
 func SetupMacDaemon() error {
+
+	dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
+	if err != nil {
+		return err
+	}
+	binarypath := dir + "/netclient"
+
+	if !ncutils.FileExists("/etc/netclient/netclient") {
+		_, err = ncutils.Copy(binarypath, "/etc/netclient/netclient")
+		if err != nil {
+			log.Println(err)
+			return err
+		}
+	}
+
 	_, errN := os.Stat("~/Library/LaunchAgents")
 	if os.IsNotExist(errN) {
 		os.Mkdir("~/Library/LaunchAgents", 0755)
 	}
-	err := CreateMacService(MAC_SERVICE_NAME)
+	err = CreateMacService(MAC_SERVICE_NAME)
 	if err != nil {
 		return err
 	}

+ 0 - 1
netclient/functions/checkin.go

@@ -6,7 +6,6 @@ import (
 	"os"
 	"runtime"
 	"strings"
-
 	nodepb "github.com/gravitl/netmaker/grpc"
 	"github.com/gravitl/netmaker/models"
 	"github.com/gravitl/netmaker/netclient/auth"

+ 13 - 0
scripts/netclient.sh

@@ -0,0 +1,13 @@
+#!/bin/sh
+echo "[netclient] joining network"
+
+/etc/netclient/netclient join -t $NETCLIENT_ACCESSTOKEN -daemon off -dnson no
+
+echo "[netclient] Starting netclient checkin"
+# loop and call checkin -n all
+while [ 1 ]; do
+    # add logs to netclient.logs
+    /etc/netclient/netclient checkin -n all
+    sleep $SLEEP
+done
+echo "[netclient] exiting"