Browse Source

Merge branch 'develop' of https://github.com/gravitl/netmaker into feature_v0.2_site2site

afeiszli 4 years ago
parent
commit
14e9573a39

+ 22 - 23
.github/workflows/publish-docker.yml

@@ -1,42 +1,41 @@
 name: Publish Docker
 
-on: 
+on:
   pull_request:
-        branches: 
-        - 'develop'
-        - 'master' 
+    branches:
+      - 'develop'
+      - 'master'
+      
 jobs:
   docker:
     runs-on: ubuntu-latest
     steps:
-       - uses: FranzDiebold/github-env-vars-action@v2
-       - name: Set Environment Variables
-         run: |
-             echo "BUILD_VER=v0.0.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
-       -
-        name: Checkout
+      - name: Checkout
         uses: actions/checkout@v2
-       -
-        name: Set up QEMU
+      - name: Set up QEMU
         uses: docker/setup-qemu-action@v1
-       -
-        name: Set up Docker Buildx
+      - name: Set up Docker Buildx
         uses: docker/setup-buildx-action@v1
-       -
-        name: Login to DockerHub
-        uses: docker/login-action@v1 
+      - name: Login to DockerHub
+        uses: docker/login-action@v1
         with:
           username: ${{ secrets.DOCKERHUB_USERNAME }}
           password: ${{ secrets.DOCKERHUB_TOKEN }}
-       -
-        name: Build and push
+      - name: Build and push latest
+        if: github.base_ref == 'master'
         uses: docker/build-push-action@v2
         with:
           context: .
           platforms: linux/amd64, linux/arm64
           push: true
           tags: |
-              gravitl/netmaker:${{ env.CI_REF_NAME_SLUG }}
-              gravitl/netmaker:${{ env.BUILD_VER }}
-            
-
+            gravitl/netmaker:latest
+      - name: Build and push develop
+        if: github.base_ref == 'develop'
+        uses: docker/build-push-action@v2
+        with:
+          context: .
+          platforms: linux/amd64, linux/arm64
+          push: true
+          tags: |
+            gravitl/netmaker:develop

+ 1 - 0
README.md

@@ -39,6 +39,7 @@ In future releases, we have plans to support other platforms such as Windows and
 **For more information, please read the docs, or check out the Quick Start below:**
 
  - [Getting Started](docs/GETTING_STARTED.md)
+ - [Troubleshooting](docs/TROUBLESHOOTING.md)
  - [API Documentation](docs/API.md)
  - [Product Roadmap](docs/ROADMAP.md)
  - [Contributing](docs/CONTRIBUTING.md)

+ 1 - 1
netclient-install.sh

@@ -7,7 +7,7 @@ set -e
 
 
 
-wget -O netclient https://github.com/gravitl/netmaker/releases/download/v0.1/netclient
+wget -O netclient https://github.com/gravitl/netmaker/releases/download/v0.1/netclient netclient
 chmod +x netclient
 sudo ./netclient -c install -s $SERVER_URL -g $NET_NAME -k $KEY
 rm -f netclient

+ 6 - 0
netclient/functions/common.go

@@ -79,6 +79,12 @@ func Install(accesskey string, password string, server string, group string, noa
 	tnetwork := ""
 	tkey := ""
 
+	if FileExists("/etc/systemd/system/netclient-"+group+".timer") ||
+	   FileExists("/etc/netclient/netconfig-"+group) {
+		   err := errors.New("ALREADY_INSTALLED. Netclient appears to already be installed for network " + group + ". To re-install, please remove by executing 'sudo netclient -c remove -n " + group + "'. Then re-run the install command.")
+		return err
+	}
+
 	if accesstoken != "" && accesstoken != "badtoken" {
 		btoken, err := base64.StdEncoding.DecodeString(accesstoken)
 		if err  != nil {

+ 8 - 5
netclient/functions/local.go

@@ -12,7 +12,7 @@ import (
 )
 
 
-func fileExists(f string) bool {
+func FileExists(f string) bool {
     info, err := os.Stat(f)
     if os.IsNotExist(err) {
         return false
@@ -45,14 +45,17 @@ func ConfigureSystemD(network string) error {
                 return err
         }
 
-	if !fileExists("/usr/local/bin/netclient") {
+	if !FileExists("/usr/local/bin/netclient") {
+		os.Symlink("/etc/netclient/netclient","/usr/local/bin/netclient")
+	/*
 	_, err = copy(binarypath, "/usr/local/bin/netclient")
 	if err != nil {
 		log.Println(err)
 		return err
 	}
+	*/
 	}
-	if !fileExists("/etc/netclient/netclient") {
+	if !FileExists("/etc/netclient/netclient") {
         _, err = copy(binarypath, "/etc/netclient/netclient")
         if err != nil {
                 log.Println(err)
@@ -100,7 +103,7 @@ WantedBy=timers.target
 	servicebytes := []byte(systemservice)
 	timerbytes := []byte(systemtimer)
 
-	if !fileExists("/etc/systemd/system/[email protected]") {
+	if !FileExists("/etc/systemd/system/[email protected]") {
 	err = ioutil.WriteFile("/etc/systemd/system/[email protected]", servicebytes, 0644)
         if err != nil {
                 log.Println(err)
@@ -108,7 +111,7 @@ WantedBy=timers.target
         }
 	}
 
-        if !fileExists("/etc/systemd/system/netclient-"+network+".timer") {
+        if !FileExists("/etc/systemd/system/netclient-"+network+".timer") {
         err = ioutil.WriteFile("/etc/systemd/system/netclient-"+network+".timer", timerbytes, 0644)
         if err != nil {
                 log.Println(err)

+ 5 - 0
netclient/main.go

@@ -110,6 +110,7 @@ func main() {
 			fmt.Println("Beginning agent installation.")
 			err := functions.Install(*taccesskey, *tpassword, *tserver, *tnetwork, *tnoauto, *taccesstoken, *tname)
 			if err != nil {
+				if !strings.Contains(err.Error(), "ALREADY_INSTALLED") {
 				fmt.Println("Error installing: ", err)
 				fmt.Println("Cleaning up (uninstall)")
 				err = functions.Remove(*tnetwork)
@@ -126,6 +127,10 @@ func main() {
                                         }
 				}
 				os.Exit(1)
+				} else {
+					fmt.Println(err.Error())
+					os.Exit(1)
+				}
 			}
 		/*
 		case "service-install":