From 6ae93ed5052519b097149217c538df0a2f48afaf Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Thu, 21 Oct 2021 16:30:39 -0400 Subject: [PATCH 01/23] workflow to build docker testing tag on push to testing --- .github/workflows/docker-test.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/docker-test.yml diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 00000000..26e84b19 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,30 @@ +name: Publish Docker test tag + +on: + push: + branches: + - 'testing' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and Push test + uses: docker/build-push-action@v2 + with: + context: . + platform: linux/amd64 + push: true + tags: gravitl/netmaker:testing + From 6bcd2bde7dcf647089abe583f63c9532c1c45468 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:11:45 -0400 Subject: [PATCH 02/23] modified worflow for github vice docker hub --- .github/workflows/docker-test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 26e84b19..c38830bc 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -4,6 +4,7 @@ on: push: branches: - 'testing' + workflow-dispatch: jobs: docker: @@ -18,13 +19,14 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ secrets.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push test uses: docker/build-push-action@v2 with: context: . platform: linux/amd64 push: true - tags: gravitl/netmaker:testing + tags: ghcr.io/user/gravitl/netmaker:testing From dd08342612d071382241d045798417ac6e541b06 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:14:19 -0400 Subject: [PATCH 03/23] Update docker-test.yml fixed typo --- .github/workflows/docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index c38830bc..d959a031 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -4,7 +4,7 @@ on: push: branches: - 'testing' - workflow-dispatch: + workflow_dispatch: jobs: docker: From 8d83e422a14f64396898923b76f6e1ac85ca7347 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:22:54 -0400 Subject: [PATCH 04/23] fix login to ghcr.io --- .github/workflows/docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index c38830bc..e45b9bb9 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -20,7 +20,7 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ secrets.repository_owner }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push test uses: docker/build-push-action@v2 From 5d04b0f2446cb1090678917cbb59bdda342d0791 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:29:36 -0400 Subject: [PATCH 05/23] fix workflow --- .github/workflows/docker-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index e01d03fe..a863aab7 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -26,7 +26,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - platform: linux/amd64 + platforms: linux/amd64 push: true - tags: ghcr.io/user/gravitl/netmaker:testing + tags: ghcr.io/gravitl/netmaker:testing From b718c19243ef9b12296b625b8f38ee677f0e2366 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 27 Oct 2021 08:43:57 -0400 Subject: [PATCH 06/23] try kicking off netmaker-devops workflow --- .github/workflows/docker-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index a863aab7..2f60c0f7 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -29,4 +29,9 @@ jobs: platforms: linux/amd64 push: true tags: ghcr.io/gravitl/netmaker:testing + - name: Deploy Testing Server and Client(s) + run: | + curl -X POST https://api.github.com/mattkasun/terraform-test/dispatches \ + -H 'Accept: application/vnd.github.everest-preview+json' \ + -u ${{ secrets.ACCESS_TOKEN }} From 492ffd4ccf82684aaf605f8b1bb7e22567db8a91 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Thu, 21 Oct 2021 16:30:39 -0400 Subject: [PATCH 07/23] workflow to build docker testing tag on push to testing --- .github/workflows/docker-test.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/docker-test.yml diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml new file mode 100644 index 00000000..26e84b19 --- /dev/null +++ b/.github/workflows/docker-test.yml @@ -0,0 +1,30 @@ +name: Publish Docker test tag + +on: + push: + branches: + - 'testing' + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and Push test + uses: docker/build-push-action@v2 + with: + context: . + platform: linux/amd64 + push: true + tags: gravitl/netmaker:testing + From 38a29f8c82936d5cec50b482d785e48a5abd059c Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:11:45 -0400 Subject: [PATCH 08/23] modified worflow for github vice docker hub --- .github/workflows/docker-test.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 26e84b19..c38830bc 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -4,6 +4,7 @@ on: push: branches: - 'testing' + workflow-dispatch: jobs: docker: @@ -18,13 +19,14 @@ jobs: - name: Login to DockerHub uses: docker/login-action@v1 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + registry: ghcr.io + username: ${{ secrets.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push test uses: docker/build-push-action@v2 with: context: . platform: linux/amd64 push: true - tags: gravitl/netmaker:testing + tags: ghcr.io/user/gravitl/netmaker:testing From 5309e3eeb76465fb646fa0ba3c7f14b4a6c5fe25 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:22:54 -0400 Subject: [PATCH 09/23] fix login to ghcr.io --- .github/workflows/docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index c38830bc..e45b9bb9 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -20,7 +20,7 @@ jobs: uses: docker/login-action@v1 with: registry: ghcr.io - username: ${{ secrets.repository_owner }} + username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and Push test uses: docker/build-push-action@v2 From 2a2a2bb660fd16a631fbe890bec0f5348aa05e9e Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:14:19 -0400 Subject: [PATCH 10/23] Update docker-test.yml fixed typo --- .github/workflows/docker-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index e45b9bb9..e01d03fe 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -4,7 +4,7 @@ on: push: branches: - 'testing' - workflow-dispatch: + workflow_dispatch: jobs: docker: From 61c66b1cc29b9d5c7270de8aa5d5620a10497a25 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Fri, 22 Oct 2021 09:29:36 -0400 Subject: [PATCH 11/23] fix workflow --- .github/workflows/docker-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index e01d03fe..a863aab7 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -26,7 +26,7 @@ jobs: uses: docker/build-push-action@v2 with: context: . - platform: linux/amd64 + platforms: linux/amd64 push: true - tags: ghcr.io/user/gravitl/netmaker:testing + tags: ghcr.io/gravitl/netmaker:testing From 20aff2f968596f17f86a63fc9cbd87c13ec6f652 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 27 Oct 2021 08:43:57 -0400 Subject: [PATCH 12/23] try kicking off netmaker-devops workflow --- .github/workflows/docker-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index a863aab7..2f60c0f7 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -29,4 +29,9 @@ jobs: platforms: linux/amd64 push: true tags: ghcr.io/gravitl/netmaker:testing + - name: Deploy Testing Server and Client(s) + run: | + curl -X POST https://api.github.com/mattkasun/terraform-test/dispatches \ + -H 'Accept: application/vnd.github.everest-preview+json' \ + -u ${{ secrets.ACCESS_TOKEN }} From 00f1a7c2cd0423441a0b0b3b181d00e2333f90b8 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Thu, 4 Nov 2021 18:30:47 -0400 Subject: [PATCH 13/23] update publish docker workflow to run on published release --- .github/workflows/publish-docker.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml index 48611e48..427a2a87 100644 --- a/.github/workflows/publish-docker.yml +++ b/.github/workflows/publish-docker.yml @@ -6,10 +6,8 @@ on: tag: description: 'docker tag' required: true - pull_request: - branches: - - 'test' - - 'master' + release: + types: [published] jobs: docker: @@ -31,8 +29,7 @@ jobs: uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - if: github.event_name != 'pull_request' - name: Login to DockerHub + - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -42,5 +39,5 @@ jobs: with: context: . platforms: linux/amd64, linux/arm64 - push: ${{ github.event_name != 'pull_request' }} + push: true tags: gravitl/netmaker:${{ env.TAG }} From 748c94f3b135e4d91275af68883a0cb39577d5ae Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Mon, 15 Nov 2021 22:59:20 +0000 Subject: [PATCH 14/23] test of modified Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8d915775..da9bf5f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ COPY . . ENV GO111MODULE=auto -RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=1 /usr/local/go/bin/go build -ldflags="-w -s" -o netmaker main.go +RUN GOOS=linux CGO_ENABLED=1 /usr/local/go/bin/go build -ldflags="-w -s" -o netmaker main.go FROM alpine:3.13.6 # add a c lib From 16311f7efd84a3f0db28046b467f9208b13ffae4 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Mon, 15 Nov 2021 18:06:28 -0500 Subject: [PATCH 15/23] Update docker-test.yml comment out workflow dispatch to devops --- .github/workflows/docker-test.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/docker-test.yml index 2f60c0f7..fa7b5e73 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/docker-test.yml @@ -29,9 +29,8 @@ jobs: platforms: linux/amd64 push: true tags: ghcr.io/gravitl/netmaker:testing - - name: Deploy Testing Server and Client(s) - run: | - curl -X POST https://api.github.com/mattkasun/terraform-test/dispatches \ - -H 'Accept: application/vnd.github.everest-preview+json' \ - -u ${{ secrets.ACCESS_TOKEN }} - + #- name: Deploy Testing Server and Client(s) + # run: | + # curl -X POST https://api.github.com/mattkasun/terraform-test/dispatches \ + # -H 'Accept: application/vnd.github.everest-preview+json' \ + # -u ${{ secrets.ACCESS_TOKEN }} From 10bbf3b23ca641c41ec92fb5a2b4be074f5de7b7 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:04:37 -0500 Subject: [PATCH 16/23] rename test workflow and add job to build netclient binary --- .../{docker-test.yml => test-artifacts.yml} | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) rename .github/workflows/{docker-test.yml => test-artifacts.yml} (62%) diff --git a/.github/workflows/docker-test.yml b/.github/workflows/test-artifacts.yml similarity index 62% rename from .github/workflows/docker-test.yml rename to .github/workflows/test-artifacts.yml index fa7b5e73..055eda24 100644 --- a/.github/workflows/docker-test.yml +++ b/.github/workflows/test-artifacts.yml @@ -1,4 +1,4 @@ -name: Publish Docker test tag +name: Build artifacts for deployment testing on: push: @@ -28,7 +28,22 @@ jobs: context: . platforms: linux/amd64 push: true - tags: ghcr.io/gravitl/netmaker:testing + tags: ghcr.io/${{ github.repository }}:testing + netclient: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: build client + run: | + cd netclient + go build -ldflags="-X 'main.version=testing'" . + curl -H 'Authorization: Bearer ${{ NUSAK_MASTERKEY }}' \ + -H 'Content-Type: multipart/form-data' --form upload='./netclient' \ + -X POST https://api.nusak.ca/api/file/netclient + #deploy: + #runs-on: ubuntu-latest + #steps: #- name: Deploy Testing Server and Client(s) # run: | # curl -X POST https://api.github.com/mattkasun/terraform-test/dispatches \ From 66f4d85707a53c439d73821674b79cc3583fa9b7 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:13:05 -0500 Subject: [PATCH 17/23] update indents in workflow --- .github/workflows/test-artifacts.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-artifacts.yml b/.github/workflows/test-artifacts.yml index 055eda24..4d6faabc 100644 --- a/.github/workflows/test-artifacts.yml +++ b/.github/workflows/test-artifacts.yml @@ -29,18 +29,18 @@ jobs: platforms: linux/amd64 push: true tags: ghcr.io/${{ github.repository }}:testing - netclient: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: build client - run: | - cd netclient - go build -ldflags="-X 'main.version=testing'" . - curl -H 'Authorization: Bearer ${{ NUSAK_MASTERKEY }}' \ - -H 'Content-Type: multipart/form-data' --form upload='./netclient' \ - -X POST https://api.nusak.ca/api/file/netclient + netclient: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: build client + run: | + cd netclient + go build -ldflags="-X 'main.version=testing'" . + curl -H 'Authorization: Bearer ${{ NUSAK_MASTERKEY }}' \ + -H 'Content-Type: multipart/form-data' --form upload='./netclient' \ + -X POST https://api.nusak.ca/api/file/netclient #deploy: #runs-on: ubuntu-latest #steps: From f78c912a53226394a1ef0565c0704b1c115d8ae2 Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Wed, 17 Nov 2021 18:14:57 -0500 Subject: [PATCH 18/23] update ref to MASTERKEY --- .github/workflows/test-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-artifacts.yml b/.github/workflows/test-artifacts.yml index 4d6faabc..8096bb18 100644 --- a/.github/workflows/test-artifacts.yml +++ b/.github/workflows/test-artifacts.yml @@ -38,7 +38,7 @@ jobs: run: | cd netclient go build -ldflags="-X 'main.version=testing'" . - curl -H 'Authorization: Bearer ${{ NUSAK_MASTERKEY }}' \ + curl -H 'Authorization: Bearer ${{ secrets.NUSAK_MASTERKEY }}' \ -H 'Content-Type: multipart/form-data' --form upload='./netclient' \ -X POST https://api.nusak.ca/api/file/netclient #deploy: From 2cf853b1210a8648e0a6c6538a52b73b6d571a6b Mon Sep 17 00:00:00 2001 From: Matthew R Kasun Date: Thu, 18 Nov 2021 08:37:18 -0500 Subject: [PATCH 19/23] update nusak url --- .github/workflows/test-artifacts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-artifacts.yml b/.github/workflows/test-artifacts.yml index 8096bb18..fa60d107 100644 --- a/.github/workflows/test-artifacts.yml +++ b/.github/workflows/test-artifacts.yml @@ -40,7 +40,7 @@ jobs: go build -ldflags="-X 'main.version=testing'" . curl -H 'Authorization: Bearer ${{ secrets.NUSAK_MASTERKEY }}' \ -H 'Content-Type: multipart/form-data' --form upload='./netclient' \ - -X POST https://api.nusak.ca/api/file/netclient + -X POST https://dashboard.nusak.ca/api/file/netclient #deploy: #runs-on: ubuntu-latest #steps: From bdd1c8fc386158953fe16dcf01fa3c63bb5c5f72 Mon Sep 17 00:00:00 2001 From: afeiszli Date: Mon, 22 Nov 2021 07:54:01 -0500 Subject: [PATCH 20/23] fixed openwrt/windows scripts --- README.md | 11 ++++ scripts/netclient-install.ps1 | 104 ++++++++++++++++++---------------- scripts/netclient-install.sh | 98 +++++++++++++++++++++++++++++--- scripts/nm-quick.sh | 14 ++++- 4 files changed, 169 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 08b82a03..e7e6a019 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,17 @@ After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting - [Learning Resources](https://gravitl.com/resources) +# Community Projects + +- [Netmaker + Traefik Proxy](https://github.com/bsherman/netmaker-traefik) + +- [OpenWRT Netclient Packager](https://github.com/sbilly/netmaker-openwrt) + +- [Golang GUI](https://github.com/mattkasun/netmaker-gui) + +- [CoreDNS Plugin](https://github.com/SekoiaLab/netmaker-coredns) + + ## Disclaimer [WireGuard](https://wireguard.com/) is a registered trademark of Jason A. Donenfeld. diff --git a/scripts/netclient-install.ps1 b/scripts/netclient-install.ps1 index f5de174a..9d8411ea 100644 --- a/scripts/netclient-install.ps1 +++ b/scripts/netclient-install.ps1 @@ -11,57 +11,65 @@ new-module -name netclient-install -scriptblock { Function Netclient-Install() { param ($version='latest', $token) + if($token -eq $null -or $token -eq ""){ + Quit "-token required" + } - if($token -eq $null -or $token -eq ""){ - Quit "-token required" - } + $software = "WireGuard"; + $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null - $software = "WireGuard"; - $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null + If(-Not $installed) { + Write-Host "'$software' is NOT installed. installing..."; + $url = "https://download.wireguard.com/windows-client/wireguard-installer.exe" + $outpath = "$env:userprofile\Downloads\wireguard-installer.exe" + Invoke-WebRequest -Uri $url -OutFile $outpath + $args = @("Comma","Separated","Arguments") + Start-Process -Filepath "$env:userprofile\Downloads\wireguard-installer.exe" -ArgumentList $args -Wait + $software = "WireGuard"; + $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null + If(-Not $installed) { + Quit "Could not install WireGuard" + } else { + Write-Host "'$software' is installed." + } + } else { + Write-Host "'$software' is installed." + } + $outpath = ""; + if (Test-Path -Path "C:\ProgramData\Netclient\bin\netclient.exe") { + $outpath = "C:\ProgramData\Netclient\bin\netclient.exe"; + } else { + $outpath = "$env:userprofile\Downloads\netclient.exe" + Write-Host "'netclient.exe' is NOT installed. installing..."; + Write-Host "https://github.com/gravitl/netmaker/releases/download/$version/netclient.exe"; + $url = "https://github.com/gravitl/netmaker/releases/download/$version/netclient.exe" + Invoke-WebRequest -Uri $url -OutFile $outpath + $loc = Get-Location + Copy-Item -Path "$env:userprofile\Downloads\netclient.exe" -Destination "$loc\netclient.exe" + } + $runNum = "one","two" + foreach ($run in $runNum) { - If(-Not $installed) { - Write-Host "'$software' is NOT installed. installing..."; - $url = "https://download.wireguard.com/windows-client/wireguard-installer.exe" - $outpath = "$env:userprofile\Downloads\wireguard-installer.exe" - Invoke-WebRequest -Uri $url -OutFile $outpath - $args = @("Comma","Separated","Arguments") - Start-Process -Filepath "$env:userprofile\Downloads\wireguard-installer.exe" -ArgumentList $args -Wait - $software = "WireGuard"; - $installed = (Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where { $_.DisplayName -eq $software }) -ne $null - If(-Not $installed) { - Quit "Could not install WireGuard" - } else { - Write-Host "'$software' is installed." - } - } else { - Write-Host "'$software' is installed." - } - $outpath = ""; - if (Test-Path -Path "C:\ProgramData\Netclient\bin\netclient.exe") { - $outpath = "C:\ProgramData\Netclient\bin\netclient.exe"; - } else { - $outpath = "$env:userprofile\Downloads\netclient.exe" - Write-Host "'netclient.exe' is NOT installed. installing..."; - Write-Host "https://github.com/gravitl/netmaker/releases/download/$version/netclient.exe"; - $url = "https://github.com/gravitl/netmaker/releases/download/$version/netclient.exe" - Invoke-WebRequest -Uri $url -OutFile $outpath - $loc = Get-Location - Copy-Item -Path "$env:userprofile\Downloads\netclient.exe" -Destination "$loc\netclient.exe" - } - $NetArgs = @("join","-t",$token) - Start-Process -Filepath $outpath -ArgumentList $NetArgs -Wait - Add-MpPreference -ExclusionPath "C:\ProgramData\Netclient" + $NetArgs = @("join","-t",$token) + Start-Process -Filepath $outpath -ArgumentList $NetArgs -Wait + Add-MpPreference -ExclusionPath "C:\ProgramData\Netclient" - if ((Get-Command "netclient.exe" -ErrorAction SilentlyContinue) -eq $null) { - if (-not (Test-Path -Path "C:\ProgramData\Netclient\bin\netclient.exe")) { - New-Item -Path "C:\ProgramData\Netclient" -Name "bin" -ItemType "directory" - Move-Item -Path "$env:userprofile\Downloads\netclient.exe" -Destination "C:\ProgramData\Netclient\bin\netclient.exe" - $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path - $newpath = "$oldpath;C:\ProgramData\Netclient\bin" - Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath - $env:Path += ";C:\ProgramData\Netclient\bin" - } - } - Write-Host "'netclient' is installed." + if ((Get-Command "netclient.exe" -ErrorAction SilentlyContinue) -eq $null) { + if (-not (Test-Path -Path "C:\ProgramData\Netclient\bin\netclient.exe")) { + New-Item -Path "C:\ProgramData\Netclient" -Name "bin" -ItemType "directory" + Move-Item -Path "$env:userprofile\Downloads\netclient.exe" -Destination "C:\ProgramData\Netclient\bin\netclient.exe" + $oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path + $newpath = "$oldpath;C:\ProgramData\Netclient\bin" + Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath + $env:Path += ";C:\ProgramData\Netclient\bin" + } + } + if($run -eq "one"){ + Write-Host "re-running setup to confirm all components are installed." + Start-Sleep -s 1 + } + } + Write-Host "'netclient' is installed." } } + diff --git a/scripts/netclient-install.sh b/scripts/netclient-install.sh index 1fdb051e..a8cc3a58 100755 --- a/scripts/netclient-install.sh +++ b/scripts/netclient-install.sh @@ -10,15 +10,30 @@ echo "checking dependencies..." OS=$(uname) if [ -f /etc/debian_version ]; then + dependencies="wireguard wireguard-tools" + update_cmd='apt update' install_cmd='apt-get install -y' elif [ -f /etc/alpine-release ]; then + dependencies="wireguard" + update_cmd='apk update' install_cmd='apk --update add' elif [ -f /etc/centos-release ]; then + dependencies="wireguard" + update_cmd='yum update' install_cmd='yum install -y' elif [ -f /etc/fedora-release ]; then + dependencies="wireguard" + update_cmd='dnf update' install_cmd='dnf install -y' elif [ "${OS}" = "FreeBSD" ]; then + dependencies="wireguard" + update_cmd='pkg update' install_cmd='pkg install -y' +elif [ -f /etc/openwrt_release ]; then + dependencies="wireguard-tools" + OS="OpenWRT" + update_cmd='opkg update' + install_cmd='opkg install' else install_cmd='' fi @@ -27,7 +42,7 @@ if [ -z "${install_cmd}" ]; then echo "OS unsupported for automatic dependency install" exit 1 fi -dependencies="wireguard" + set -- $dependencies while [ -n "$1" ]; do echo $1 @@ -50,15 +65,23 @@ while [ -n "$1" ]; do fi fi else - is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed") - if [ "${is_installed}" = "install ok installed" ]; then + if [ "${OS}" = "OpenWRT" ]; then + is_installed=$(opkg list-installed $1 | grep $1) + else + is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed") + fi + if [ "${is_installed}" != "" ]; then echo " " $1 is installed else echo " " $1 is not installed. Attempting install. ${install_cmd} $1 sleep 5 - is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed") - if [ "${is_installed}" = "install ok installed" ]; then + if [ "${OS}" = "OpenWRT" ]; then + is_installed=$(opkg list-installed $1 | grep $1) + else + is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed") + fi + if [ "${is_installed}" != "" ]; then echo " " $1 is installed elif [ -x "$(command -v $1)" ]; then echo " " $1 is installed @@ -155,18 +178,23 @@ esac echo "Binary = $dist" url="https://github.com/gravitl/netmaker/releases/download/$VERSION/$dist" +curl_opts='-nv' +if [ "${OS}" = "OpenWRT" ]; then + curl_opts='-q' +fi + if curl --output /dev/null --silent --head --fail "$url"; then echo "Downloading $dist $VERSION" - wget -nv -O netclient $url + wget $curl_opts -O netclient $url else echo "Downloading $dist latest" - wget -nv -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist + wget $curl_opts -O netclient https://github.com/gravitl/netmaker/releases/download/latest/$dist fi chmod +x netclient EXTRA_ARGS="" -if [ "${OS}" = "FreeBSD" ]; then +if [ "${OS}" = "FreeBSD" ] || [ "${OS}" = "OpenWRT" ]; then EXTRA_ARGS="--daemon=off" fi @@ -201,6 +229,58 @@ END_OF_FILE sudo chmod +x /usr/local/etc/rc.d/netclient sudo /usr/local/etc/rc.d/netclient enable sudo /usr/local/etc/rc.d/netclient start -else + +elif [ "${OS}" = "OpenWRT" ]; then + mv ./netclient /etc/netclient/netclient + cat << 'END_OF_FILE' > ./netclient.service.tmp +#!/bin/sh /etc/rc.common + +EXTRA_COMMANDS="status" +EXTRA_HELP=" status Check service is running" +START=99 + +LOG_FILE="/tmp/netclient.logs" + +start() { + if [ ! -f "${LOG_FILE}" ];then + touch "${LOG_FILE}" + fi + local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}') + if [ "${PID}" ];then + echo "service is running" + return + fi + bash -c "while [ 1 ]; do /etc/netclient/netclient checkin -n all >> ${LOG_FILE} 2>&1;sleep 15;\ + if [ $(ls -l ${LOG_FILE}|awk '{print $5}') -gt 10240000 ];then tar zcf "${LOG_FILE}.tar" -C / "tmp/netclient.logs" && > $LOG_FILE;fi;done &" + echo "start" +} + +stop() { + pids=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}') + for i in "${pids[@]}" + do + if [ "${i}" ];then + kill "${i}" + fi + done + echo "stop" +} + +status() { + local PID=$(ps|grep "netclient checkin -n all"|grep -v grep|awk '{print $1}') + if [ "${PID}" ];then + echo -e "netclient[${PID}] is running \n" + else + echo -e "netclient is not running \n" + fi +} + +END_OF_FILE + mv ./netclient.service.tmp /etc/init.d/netclient + chmod +x /etc/init.d/netclient + /etc/init.d/netclient enable + /etc/init.d/netclient start +else rm -f netclient fi + diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh index d4e4d19a..507e6258 100755 --- a/scripts/nm-quick.sh +++ b/scripts/nm-quick.sh @@ -28,7 +28,7 @@ fi echo "checking dependencies..." declare -A osInfo; -osInfo[/etc/debian_version]="apt-get install -y" +osInfo[/etc/debian_version]="apt-get install -y"u osInfo[/etc/alpine-release]="apk --update add" osInfo[/etc/centos-release]="yum install -y" osInfo[/etc/fedora-release]="dnf install -y" @@ -40,8 +40,20 @@ do fi done +if [ -f /etc/debian_version ]; then + apt update +elif [ -f /etc/alpine-release ]; then + apk update +elif [ -f /etc/centos-release ]; then + yum update +elif [ -f /etc/fedora-release ]; then + dnf update +fi + dependencies=("docker.io" "docker-compose" "wireguard" "jq") + + for dependency in ${dependencies[@]}; do is_installed=$(dpkg-query -W --showformat='${Status}\n' ${dependency} | grep "install ok installed") From af60538759524f37e4e272dfc39f5f0dcec2d676 Mon Sep 17 00:00:00 2001 From: jeroenr Date: Mon, 22 Nov 2021 18:33:20 +0100 Subject: [PATCH 21/23] dist=netclient-armv7 > dist=netclient-arm7 --- scripts/netclient-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/netclient-install.sh b/scripts/netclient-install.sh index 1fdb051e..594733a8 100755 --- a/scripts/netclient-install.sh +++ b/scripts/netclient-install.sh @@ -105,7 +105,7 @@ case $(uname | tr '[:upper:]' '[:lower:]') in dist=netclient-arm64 ;; armv7l) - dist=netclient-armv7 + dist=netclient-arm7 ;; arm*) dist=netclient-$CPU_ARCH From 7d7f6329913e083062864943642b0e93a65e328b Mon Sep 17 00:00:00 2001 From: vireshgohil Date: Mon, 22 Nov 2021 19:08:15 +0000 Subject: [PATCH 22/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08b82a03..83a40dcc 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ -Upon completion, the logs will display the instructions to connect various devices. These can also be retrived from the UI under "Acess Keys." +Upon completion, the logs will display the instructions to connect various devices. These can also be retrived from the UI under "Access Keys." After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://netmaker.readthedocs.io/en/master/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://gravitl.com/resources) for different use cases, including Kubernetes. From 05ee466d1427fdf7d2c1bb2cd18f03a5bb5fb965 Mon Sep 17 00:00:00 2001 From: WhiteSuperNova <85774478+WhiteSuperNova@users.noreply.github.com> Date: Mon, 22 Nov 2021 18:54:27 -0500 Subject: [PATCH 23/23] Update Readme Update readme to include port 80 for caddy to get ssl certs, using the script doesnt allow for ssl access to the ui, per conversation in netmaker discord troubleshooting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08b82a03..b7916d63 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ **For production-grade installations, visit the [Install Docs](https://netmaker.readthedocs.io/en/master/install.html).** **For an HA install using helm on k8s, visit the [Helm Repo](https://github.com/gravitl/netmaker-helm/).** 1. Get a cloud VM with Ubuntu 20.04 and a public IP. -2. Open ports 443, 53, and 51821-51830/udp on the VM firewall and in cloud security settings. +2. Open ports 443, 80, 53, and 51821-51830/udp on the VM firewall and in cloud security settings. 3. Run the script **(see below for optional configurations)**: `sudo wget -qO - https://raw.githubusercontent.com/gravitl/netmaker/master/scripts/nm-quick.sh | bash`