Browse Source

Merge pull request #422 from SekoiaLab/fix/host-name-issue

Fix/host name issue
Alex 3 years ago
parent
commit
d3b1773da9
2 changed files with 5 additions and 2 deletions
  1. 2 0
      netclient/main.go
  2. 3 2
      scripts/netclient-install.sh

+ 2 - 0
netclient/main.go

@@ -10,6 +10,7 @@ import (
 	"os/signal"
 	"os/signal"
 	"runtime/debug"
 	"runtime/debug"
 	"strconv"
 	"strconv"
+	"strings"
 	"syscall"
 	"syscall"
 
 
 	"github.com/gravitl/netmaker/netclient/command"
 	"github.com/gravitl/netmaker/netclient/command"
@@ -30,6 +31,7 @@ func main() {
 	if err != nil {
 	if err != nil {
 		hostname = ""
 		hostname = ""
 	}
 	}
+	hostname = strings.Split(hostname, ".")[0]
 
 
 	cliFlags := []cli.Flag{
 	cliFlags := []cli.Flag{
 		&cli.StringFlag{
 		&cli.StringFlag{

+ 3 - 2
scripts/netclient-install.sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 #!/bin/sh
 
 
 if [ $(id -u) -ne 0 ]; then
 if [ $(id -u) -ne 0 ]; then
-   echo "This script must be run as root" 
+   echo "This script must be run as root"
    exit 1
    exit 1
 fi
 fi
 
 
@@ -52,6 +52,7 @@ set -e
 [ -z "$KEY" ] && KEY=nokey;
 [ -z "$KEY" ] && KEY=nokey;
 [ -z "$VERSION" ] && echo "no \$VERSION provided, fallback to latest" && VERSION=latest;
 [ -z "$VERSION" ] && echo "no \$VERSION provided, fallback to latest" && VERSION=latest;
 [ "latest" != "$VERSION" ] && [ "v" != `echo $VERSION | cut -c1` ] && VERSION="v$VERSION"
 [ "latest" != "$VERSION" ] && [ "v" != `echo $VERSION | cut -c1` ] && VERSION="v$VERSION"
+[ -z "$NAME" ] && NAME="";
 
 
 dist=netclient
 dist=netclient
 
 
@@ -105,5 +106,5 @@ else
 	wget -nv -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist
 	wget -nv -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist
 fi
 fi
 chmod +x netclient
 chmod +x netclient
-sudo ./netclient join -t $KEY
+sudo ./netclient join -t $KEY --name $NAME
 rm -f netclient
 rm -f netclient