From 4dd9d35c8198950f587f233782cbf84db131b91c Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Thu, 18 Jan 2024 21:20:53 +0530
Subject: [PATCH 01/46] cleanup script
---
scripts/nm-quick.sh | 145 ++++++++------------------------------------
1 file changed, 26 insertions(+), 119 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index c5a07fe12..20637aa0a 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -13,60 +13,29 @@ if [ $(id -u) -ne 0 ]; then
fi
unset INSTALL_TYPE
-unset BUILD_TYPE
unset BUILD_TAG
unset IMAGE_TAG
unset AUTO_BUILD
unset NETMAKER_BASE_DOMAIN
-
+INSTALL_TYPE="pro"
# usage - displays usage instructions
usage() {
echo "nm-quick.sh v$NM_QUICK_VERSION"
- echo "usage: ./nm-quick.sh [-e] [-b buildtype] [-t tag] [-a auto] [-d domain]"
- echo " -e if specified, will install netmaker pro"
- echo " -b type of build; options:"
- echo " \"version\" - will install a specific version of Netmaker using remote git and dockerhub"
- echo " \"local\": - will install by cloning repo and building images from git"
- echo " \"branch\": - will install a specific branch using remote git and dockerhub"
- echo " -t tag of build; if buildtype=version, tag=version. If builtype=branch or builtype=local, tag=branch"
- echo " -a auto-build; skip prompts and use defaults, if none provided"
- echo " -d domain; if specified, will use this domain instead of auto-generating one"
- echo "examples:"
- echo " nm-quick.sh -e -b version -t $LATEST"
- echo " nm-quick.sh -e -b local -t feature_v0.17.2_newfeature"
- echo " nm-quick.sh -e -b branch -t develop"
- echo " nm-quick.sh -e -b version -t $LATEST -a -d example.com"
+ echo "usage: ./nm-quick.sh [-c]"
+ echo " -c if specified, will install netmaker community version"
+
exit 1
}
while getopts evab:d:t: flag; do
case "${flag}" in
- e)
- INSTALL_TYPE="pro"
- UPGRADE_FLAG="yes"
+ c)
+ INSTALL_TYPE="ce"
;;
v)
usage
exit 0
;;
- a)
- AUTO_BUILD="on"
- ;;
- b)
- BUILD_TYPE=${OPTARG}
- if [[ ! "$BUILD_TYPE" =~ ^(version|local|branch)$ ]]; then
- echo "error: $BUILD_TYPE is invalid"
- echo "valid options: version, local, branch"
- usage
- exit 1
- fi
- ;;
- t)
- BUILD_TAG=${OPTARG}
- ;;
- d)
- NETMAKER_BASE_DOMAIN=${OPTARG}
- ;;
esac
done
@@ -93,21 +62,9 @@ EOF
# set_buildinfo - sets the information based on script input for how the installation should be run
set_buildinfo() {
- if [ -z "$BUILD_TYPE" ]; then
- BUILD_TYPE="version"
- BUILD_TAG=$LATEST
- fi
-
- if [ -z "$BUILD_TAG" ] && [ "$BUILD_TYPE" = "version" ]; then
- BUILD_TAG=$LATEST
- fi
-
- if [ -z "$BUILD_TAG" ] && [ ! -z "$BUILD_TYPE" ]; then
- echo "error: must specify build tag when build type \"$BUILD_TYPE\" is specified"
- usage
- exit 1
- fi
+
+ BUILD_TAG=$LATEST
IMAGE_TAG=$(sed 's/\//-/g' <<<"$BUILD_TAG")
if [ "$1" = "ce" ]; then
@@ -141,7 +98,6 @@ set_buildinfo() {
fi
echo "-----------Build Options-----------------------------"
echo " Pro or CE: $INSTALL_TYPE"
- echo " Build Type: $BUILD_TYPE"
echo " Build Tag: $BUILD_TAG"
echo " Image Tag: $IMAGE_TAG"
echo " Installer: v$NM_QUICK_VERSION"
@@ -283,24 +239,15 @@ save_config() { (
save_config_item NM_EMAIL "$EMAIL"
save_config_item NM_DOMAIN "$NETMAKER_BASE_DOMAIN"
save_config_item UI_IMAGE_TAG "$IMAGE_TAG"
- if [ "$BUILD_TYPE" = "local" ]; then
- save_config_item UI_IMAGE_TAG "$LATEST"
- else
- save_config_item UI_IMAGE_TAG "$IMAGE_TAG"
- fi
# version-specific entries
if [ "$INSTALL_TYPE" = "pro" ]; then
save_config_item NETMAKER_TENANT_ID "$TENANT_ID"
save_config_item LICENSE_KEY "$LICENSE_KEY"
save_config_item METRICS_EXPORTER "on"
save_config_item PROMETHEUS "on"
- if [ "$BUILD_TYPE" = "version" ]; then
- save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG-ee"
- else
- save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG"
- fi
+ save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG-ee"
else
- save_config_item METRICS_EXPORTER "off"
+ save_config_item "off"
save_config_item PROMETHEUS "off"
save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG"
fi
@@ -345,38 +292,7 @@ save_config_item() { (
fi
); }
-# local_install_setup - builds artifacts based on specified branch locally to use in install
-local_install_setup() { (
- if test -z "$NM_SKIP_CLONE"; then
- rm -rf netmaker-tmp
- mkdir netmaker-tmp
- cd netmaker-tmp
- git clone --single-branch --depth=1 --branch=$BUILD_TAG https://www.github.com/gravitl/netmaker
- else
- cd netmaker-tmp
- echo "Skipping git clone on NM_SKIP_CLONE"
- fi
- cd netmaker
- if test -z "$NM_SKIP_BUILD"; then
- docker build --no-cache --build-arg version=$IMAGE_TAG -t gravitl/netmaker:$IMAGE_TAG .
- else
- echo "Skipping build on NM_SKIP_BUILD"
- fi
- cp compose/docker-compose.yml "$SCRIPT_DIR/docker-compose.yml"
- if [ "$INSTALL_TYPE" = "pro" ]; then
- cp compose/docker-compose.ee.yml "$SCRIPT_DIR/docker-compose.override.yml"
- cp docker/Caddyfile-pro "$SCRIPT_DIR/Caddyfile"
- else
- cp docker/Caddyfile "$SCRIPT_DIR/Caddyfile"
- fi
- cp scripts/netmaker.default.env "$SCRIPT_DIR/netmaker.default.env"
- cp docker/mosquitto.conf "$SCRIPT_DIR/mosquitto.conf"
- cp docker/wait.sh "$SCRIPT_DIR/wait.sh"
- cd ../../
- if test -z "$NM_SKIP_CLONE"; then
- rm -rf netmaker-tmp
- fi
-); }
+
# install_dependencies - install necessary packages to run netmaker
install_dependencies() {
@@ -670,10 +586,6 @@ set_install_vars() {
echo "Confirm Settings for Installation"
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
- if [ ! "$BUILD_TYPE" = "local" ]; then
- IMAGE_TAG="$LATEST"
- fi
-
confirm
}
@@ -688,26 +600,22 @@ install_netmaker() {
echo "Pulling config files..."
- if [ "$BUILD_TYPE" = "local" ]; then
- local_install_setup
- else
- local BASE_URL="https://raw.githubusercontent.com/gravitl/netmaker/$BUILD_TAG"
-
- local COMPOSE_URL="$BASE_URL/compose/docker-compose.yml"
- local CADDY_URL="$BASE_URL/docker/Caddyfile"
- if [ "$INSTALL_TYPE" = "pro" ]; then
- local COMPOSE_OVERRIDE_URL="$BASE_URL/compose/docker-compose.pro.yml"
- local CADDY_URL="$BASE_URL/docker/Caddyfile-pro"
- fi
- wget -qO "$SCRIPT_DIR"/docker-compose.yml $COMPOSE_URL
- if test -n "$COMPOSE_OVERRIDE_URL"; then
- wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
- fi
- wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
- wget -qO "$SCRIPT_DIR"/netmaker.default.env "$BASE_URL/scripts/netmaker.default.env"
- wget -qO "$SCRIPT_DIR"/mosquitto.conf "$BASE_URL/docker/mosquitto.conf"
- wget -qO "$SCRIPT_DIR"/wait.sh "$BASE_URL/docker/wait.sh"
+
+ local BASE_URL="https://raw.githubusercontent.com/gravitl/netmaker/$BUILD_TAG"
+ local COMPOSE_URL="$BASE_URL/compose/docker-compose.yml"
+ local CADDY_URL="$BASE_URL/docker/Caddyfile"
+ if [ "$INSTALL_TYPE" = "pro" ]; then
+ local COMPOSE_OVERRIDE_URL="$BASE_URL/compose/docker-compose.pro.yml"
+ local CADDY_URL="$BASE_URL/docker/Caddyfile-pro"
+ fi
+ wget -qO "$SCRIPT_DIR"/docker-compose.yml $COMPOSE_URL
+ if test -n "$COMPOSE_OVERRIDE_URL"; then
+ wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
fi
+ wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
+ wget -qO "$SCRIPT_DIR"/netmaker.default.env "$BASE_URL/scripts/netmaker.default.env"
+ wget -qO "$SCRIPT_DIR"/mosquitto.conf "$BASE_URL/docker/mosquitto.conf"
+ wget -qO "$SCRIPT_DIR"/wait.sh "$BASE_URL/docker/wait.sh"
chmod +x "$SCRIPT_DIR"/wait.sh
mkdir -p /etc/netmaker
@@ -881,4 +789,3 @@ configure_netclient
# 13. print success message
print_success
-# cp -f /etc/skel/.bashrc /root/.bashrc
From abe7f4cf52faacfb516b5f8850e0f2e1f86d4c9d Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Thu, 18 Jan 2024 21:45:55 +0530
Subject: [PATCH 02/46] upgrade flag
---
scripts/nm-quick.sh | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 20637aa0a..fd1aaf2ca 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -18,6 +18,7 @@ unset IMAGE_TAG
unset AUTO_BUILD
unset NETMAKER_BASE_DOMAIN
INSTALL_TYPE="pro"
+UPGRADE_FLAG="yes"
# usage - displays usage instructions
usage() {
echo "nm-quick.sh v$NM_QUICK_VERSION"
@@ -31,6 +32,7 @@ while getopts evab:d:t: flag; do
case "${flag}" in
c)
INSTALL_TYPE="ce"
+ UPGRADE_FLAG="no"
;;
v)
usage
@@ -129,7 +131,9 @@ install_yq() {
setup_netclient() {
set +e
- netclient uninstall
+ if [ -x "$(command -v netclient)" ]; then
+ netclient uninstall
+ fi
set -e
wget -qO netclient https://github.com/gravitl/netclient/releases/download/$LATEST/netclient-linux-$ARCH
@@ -739,9 +743,6 @@ print_logo
if [ -f "$CONFIG_PATH" ]; then
echo "Using config: $CONFIG_PATH"
source "$CONFIG_PATH"
- if [ "$UPGRADE_FLAG" = "yes" ]; then
- INSTALL_TYPE="pro"
- fi
fi
# 2. setup the build instructions
From 6749fb45167aacd5adc6bab2e3b2f75cd47baeba Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Fri, 19 Jan 2024 14:51:51 +0530
Subject: [PATCH 03/46] add trial license logic
---
database/database.go | 44 ++++++-------
logic/telemetry.go | 12 ++--
logic/timer.go | 7 ++-
logic/traffic.go | 4 +-
pro/initialize.go | 37 ++++++++---
pro/trial.go | 146 +++++++++++++++++++++++++++++++++++++++++++
6 files changed, 209 insertions(+), 41 deletions(-)
create mode 100644 pro/trial.go
diff --git a/database/database.go b/database/database.go
index c51340ab3..dc6385b34 100644
--- a/database/database.go
+++ b/database/database.go
@@ -124,29 +124,29 @@ func InitializeDatabase() error {
}
func createTables() {
- createTable(NETWORKS_TABLE_NAME)
- createTable(NODES_TABLE_NAME)
- createTable(CERTS_TABLE_NAME)
- createTable(DELETED_NODES_TABLE_NAME)
- createTable(USERS_TABLE_NAME)
- createTable(DNS_TABLE_NAME)
- createTable(EXT_CLIENT_TABLE_NAME)
- createTable(PEERS_TABLE_NAME)
- createTable(SERVERCONF_TABLE_NAME)
- createTable(SERVER_UUID_TABLE_NAME)
- createTable(GENERATED_TABLE_NAME)
- createTable(NODE_ACLS_TABLE_NAME)
- createTable(SSO_STATE_CACHE)
- createTable(METRICS_TABLE_NAME)
- createTable(NETWORK_USER_TABLE_NAME)
- createTable(USER_GROUPS_TABLE_NAME)
- createTable(CACHE_TABLE_NAME)
- createTable(HOSTS_TABLE_NAME)
- createTable(ENROLLMENT_KEYS_TABLE_NAME)
- createTable(HOST_ACTIONS_TABLE_NAME)
+ CreateTable(NETWORKS_TABLE_NAME)
+ CreateTable(NODES_TABLE_NAME)
+ CreateTable(CERTS_TABLE_NAME)
+ CreateTable(DELETED_NODES_TABLE_NAME)
+ CreateTable(USERS_TABLE_NAME)
+ CreateTable(DNS_TABLE_NAME)
+ CreateTable(EXT_CLIENT_TABLE_NAME)
+ CreateTable(PEERS_TABLE_NAME)
+ CreateTable(SERVERCONF_TABLE_NAME)
+ CreateTable(SERVER_UUID_TABLE_NAME)
+ CreateTable(GENERATED_TABLE_NAME)
+ CreateTable(NODE_ACLS_TABLE_NAME)
+ CreateTable(SSO_STATE_CACHE)
+ CreateTable(METRICS_TABLE_NAME)
+ CreateTable(NETWORK_USER_TABLE_NAME)
+ CreateTable(USER_GROUPS_TABLE_NAME)
+ CreateTable(CACHE_TABLE_NAME)
+ CreateTable(HOSTS_TABLE_NAME)
+ CreateTable(ENROLLMENT_KEYS_TABLE_NAME)
+ CreateTable(HOST_ACTIONS_TABLE_NAME)
}
-func createTable(tableName string) error {
+func CreateTable(tableName string) error {
return getCurrentDB()[CREATE_TABLE].(func(string) error)(tableName)
}
@@ -194,7 +194,7 @@ func DeleteAllRecords(tableName string) error {
if err != nil {
return err
}
- err = createTable(tableName)
+ err = CreateTable(tableName)
if err != nil {
return err
}
diff --git a/logic/telemetry.go b/logic/telemetry.go
index e4d480304..12b7035c6 100644
--- a/logic/telemetry.go
+++ b/logic/telemetry.go
@@ -32,12 +32,12 @@ func sendTelemetry() error {
return nil
}
- var telRecord, err = fetchTelemetryRecord()
+ var telRecord, err = FetchTelemetryRecord()
if err != nil {
return err
}
// get telemetry data
- d, err := fetchTelemetryData()
+ d, err := FetchTelemetryData()
if err != nil {
return err
}
@@ -71,8 +71,8 @@ func sendTelemetry() error {
})
}
-// fetchTelemetry - fetches telemetry data: count of various object types in DB
-func fetchTelemetryData() (telemetryData, error) {
+// FetchTelemetryData - fetches telemetry data: count of various object types in DB
+func FetchTelemetryData() (telemetryData, error) {
var data telemetryData
data.IsPro = servercfg.IsPro
@@ -138,8 +138,8 @@ func getClientCount(nodes []models.Node) clientCount {
return count
}
-// fetchTelemetryRecord - get the existing UUID and Timestamp from the DB
-func fetchTelemetryRecord() (models.Telemetry, error) {
+// FetchTelemetryRecord - get the existing UUID and Timestamp from the DB
+func FetchTelemetryRecord() (models.Telemetry, error) {
var rawData string
var telObj models.Telemetry
var err error
diff --git a/logic/timer.go b/logic/timer.go
index 2d0fbb6e8..db36f5792 100644
--- a/logic/timer.go
+++ b/logic/timer.go
@@ -3,11 +3,12 @@ package logic
import (
"context"
"fmt"
- "github.com/gravitl/netmaker/logger"
- "golang.org/x/exp/slog"
"sync"
"time"
+ "github.com/gravitl/netmaker/logger"
+ "golang.org/x/exp/slog"
+
"github.com/gravitl/netmaker/models"
)
@@ -24,7 +25,7 @@ var HookManagerCh = make(chan models.HookDetails, 3)
// TimerCheckpoint - Checks if 24 hours has passed since telemetry was last sent. If so, sends telemetry data to posthog
func TimerCheckpoint() error {
// get the telemetry record in the DB, which contains a timestamp
- telRecord, err := fetchTelemetryRecord()
+ telRecord, err := FetchTelemetryRecord()
if err != nil {
return err
}
diff --git a/logic/traffic.go b/logic/traffic.go
index 596bd7370..3c065c29e 100644
--- a/logic/traffic.go
+++ b/logic/traffic.go
@@ -2,7 +2,7 @@ package logic
// RetrievePrivateTrafficKey - retrieves private key of server
func RetrievePrivateTrafficKey() ([]byte, error) {
- var telRecord, err = fetchTelemetryRecord()
+ var telRecord, err = FetchTelemetryRecord()
if err != nil {
return nil, err
}
@@ -12,7 +12,7 @@ func RetrievePrivateTrafficKey() ([]byte, error) {
// RetrievePublicTrafficKey - retrieves public key of server
func RetrievePublicTrafficKey() ([]byte, error) {
- var telRecord, err = fetchTelemetryRecord()
+ var telRecord, err = FetchTelemetryRecord()
if err != nil {
return nil, err
}
diff --git a/pro/initialize.go b/pro/initialize.go
index 32c89857c..ac338110b 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -4,6 +4,8 @@
package pro
import (
+ "time"
+
controller "github.com/gravitl/netmaker/controllers"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
@@ -17,6 +19,7 @@ import (
// InitPro - Initialize Pro Logic
func InitPro() {
servercfg.IsPro = true
+ proLogic.InitTrial()
models.SetLogo(retrieveProLogo())
controller.HttpMiddlewares = append(
controller.HttpMiddlewares,
@@ -31,18 +34,36 @@ func InitPro() {
)
logic.EnterpriseCheckFuncs = append(logic.EnterpriseCheckFuncs, func() {
// == License Handling ==
- ClearLicenseCache()
- if err := ValidateLicense(); err != nil {
- slog.Error(err.Error())
- return
+ enableLicenseHook := false
+ trialEndDate, err := getTrialEndDate()
+ if err != nil {
+ slog.Error("failed to get trial end date", "error", err)
+ enableLicenseHook = true
+ }
+ // check if trial ended
+ if time.Now().After(trialEndDate) {
+ // trial ended already
+ enableLicenseHook = true
+ }
+ if enableLicenseHook {
+ slog.Info("starting license checker")
+ ClearLicenseCache()
+ if err := ValidateLicense(); err != nil {
+ slog.Error(err.Error())
+ return
+ }
+ slog.Info("proceeding with Paid Tier license")
+ logic.SetFreeTierForTelemetry(false)
+ // == End License Handling ==
+ AddLicenseHooks()
+ } else {
+ addTrialLicenseHook()
}
- slog.Info("proceeding with Paid Tier license")
- logic.SetFreeTierForTelemetry(false)
- // == End License Handling ==
- AddLicenseHooks()
+
if servercfg.GetServerConfig().RacAutoDisable {
AddRacHooks()
}
+
})
logic.ResetFailOver = proLogic.ResetFailOver
logic.ResetFailedOverPeer = proLogic.ResetFailedOverPeer
diff --git a/pro/trial.go b/pro/trial.go
new file mode 100644
index 000000000..63e4c83eb
--- /dev/null
+++ b/pro/trial.go
@@ -0,0 +1,146 @@
+//go:build ee
+// +build ee
+
+package pro
+
+import (
+ "crypto/rand"
+ "encoding/json"
+ "errors"
+ "time"
+
+ "github.com/gravitl/netmaker/database"
+ "github.com/gravitl/netmaker/logger"
+ "github.com/gravitl/netmaker/logic"
+ "github.com/gravitl/netmaker/models"
+ "github.com/gravitl/netmaker/netclient/ncutils"
+ "golang.org/x/crypto/nacl/box"
+ "golang.org/x/exp/slog"
+)
+
+type TrialInfo struct {
+ PrivKey []byte `json:"priv_key"`
+ PubKey []byte `json:"pub_key"`
+ Secret string `json:"secret"`
+}
+
+func addTrialLicenseHook() {
+ logic.HookManagerCh <- models.HookDetails{
+ Hook: TrialLicenseHook,
+ Interval: time.Hour,
+ }
+}
+
+type TrialDates struct {
+ TrialStartedAt time.Time `json:"trial_started_at"`
+ TrialEndsAt time.Time `json:"trial_ends_at"`
+}
+
+const trial_table_name = "trial"
+
+const trial_data_key = "trialdata"
+
+// store trial date
+func InitTrial() error {
+ telData, err := logic.FetchTelemetryData()
+ if err != nil {
+ return err
+ }
+ if telData.Hosts > 0 || telData.Networks > 0 || telData.Users > 0 {
+ return nil
+ }
+ err = database.CreateTable(trial_table_name)
+ if err != nil {
+ slog.Error("failed to create table", "table name", trial_table_name, "err", err.Error())
+ return err
+ }
+ // setup encryption keys
+ trafficPubKey, trafficPrivKey, err := box.GenerateKey(rand.Reader) // generate traffic keys
+ if err != nil {
+ return err
+ }
+ tPriv, err := ncutils.ConvertKeyToBytes(trafficPrivKey)
+ if err != nil {
+ return err
+ }
+
+ tPub, err := ncutils.ConvertKeyToBytes(trafficPubKey)
+ if err != nil {
+ return err
+ }
+ trialDates := TrialDates{
+ TrialStartedAt: time.Now(),
+ TrialEndsAt: time.Now().Add(time.Hour * 24 * 30),
+ }
+ t := TrialInfo{
+ PrivKey: tPriv,
+ PubKey: tPub,
+ }
+ tel, err := logic.FetchTelemetryRecord()
+ if err != nil {
+ return err
+ }
+
+ trialDatesData, err := json.Marshal(trialDates)
+ if err != nil {
+ return err
+ }
+ trialDatesSecret, err := ncutils.BoxEncrypt(trialDatesData, (*[32]byte)(tel.TrafficKeyPub), (*[32]byte)(t.PrivKey))
+ if err != nil {
+ return err
+ }
+ t.Secret = string(trialDatesSecret)
+ trialData, err := json.Marshal(t)
+ if err != nil {
+ return err
+ }
+ err = database.Insert(trial_data_key, string(trialData), trial_table_name)
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func TrialLicenseHook() error {
+ endDate, err := getTrialEndDate()
+ if err != nil {
+ logger.FatalLog0("failed to trial end date", err.Error())
+ }
+ if time.Now().After(endDate) {
+ logger.FatalLog0("***IMPORTANT: Your Trial Has Ended, to continue using pro version, please visit https://app.netmaker.io/ and create on-prem tenant to obtain a license***\nIf you wish to downgrade to community version, please run this command `/root/nm-quick.sh -d`")
+
+ }
+ return nil
+}
+
+// get trial date
+func getTrialEndDate() (time.Time, error) {
+ record, err := database.FetchRecord(trial_table_name, trial_data_key)
+ if err != nil {
+ return time.Time{}, err
+ }
+ var trialInfo TrialInfo
+ err = json.Unmarshal([]byte(record), &trialInfo)
+ if err != nil {
+ return time.Time{}, err
+ }
+ tel, err := logic.FetchTelemetryRecord()
+ if err != nil {
+ return time.Time{}, err
+ }
+ // decrypt secret
+ secretDecrypt, err := ncutils.BoxDecrypt([]byte(trialInfo.Secret), (*[32]byte)(trialInfo.PubKey), (*[32]byte)(tel.TrafficKeyPriv))
+ if err != nil {
+ return time.Time{}, err
+ }
+ trialDates := TrialDates{}
+ err = json.Unmarshal(secretDecrypt, &trialDates)
+ if err != nil {
+ return time.Time{}, err
+ }
+ if trialDates.TrialEndsAt.IsZero() {
+ return time.Time{}, errors.New("invalid date")
+ }
+ return trialDates.TrialEndsAt, nil
+
+}
From 5b7d1709e5b147c5fbab0daec74701a1b959cb41 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Fri, 19 Jan 2024 15:07:14 +0530
Subject: [PATCH 04/46] remvove license input on pro in script
---
scripts/nm-quick.sh | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index fd1aaf2ca..14b6a82d8 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -485,24 +485,6 @@ set_install_vars() {
wait_seconds 1
- if [ "$INSTALL_TYPE" = "pro" ]; then
-
- echo "-----------------------------------------------------"
- echo "Provide Details for pro installation:"
- echo " 1. Log into https://app.netmaker.io"
- echo " 2. follow instructions to get a license at: https://docs.netmaker.io/ee/ee-setup.html"
- echo " 3. Retrieve License and Tenant ID"
- echo " 4. note email address"
- echo "-----------------------------------------------------"
- unset LICENSE_KEY
- while [ -z "$LICENSE_KEY" ]; do
- read -p "License Key: " LICENSE_KEY
- done
- unset TENANT_ID
- while [ -z ${TENANT_ID} ]; do
- read -p "Tenant ID: " TENANT_ID
- done
- fi
unset GET_EMAIL
unset RAND_EMAIL
@@ -582,10 +564,6 @@ set_install_vars() {
echo " domain: $NETMAKER_BASE_DOMAIN"
echo " email: $EMAIL"
echo " public ip: $SERVER_HOST"
- if [ "$INSTALL_TYPE" = "pro" ]; then
- echo " license: $LICENSE_KEY"
- echo " account id: $TENANT_ID"
- fi
echo "-----------------------------------------------------------------"
echo "Confirm Settings for Installation"
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
From c674929b90727f3bd73331aadc0e64cb5b83db7d Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Fri, 19 Jan 2024 17:57:30 +0530
Subject: [PATCH 05/46] invoke trial from main
---
main_ee.go | 1 +
pro/initialize.go | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/main_ee.go b/main_ee.go
index 90001d870..f05c1d136 100644
--- a/main_ee.go
+++ b/main_ee.go
@@ -6,5 +6,6 @@ package main
import "github.com/gravitl/netmaker/pro"
func init() {
+ pro.InitTrial()
pro.InitPro()
}
diff --git a/pro/initialize.go b/pro/initialize.go
index ac338110b..785209292 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -19,7 +19,6 @@ import (
// InitPro - Initialize Pro Logic
func InitPro() {
servercfg.IsPro = true
- proLogic.InitTrial()
models.SetLogo(retrieveProLogo())
controller.HttpMiddlewares = append(
controller.HttpMiddlewares,
From 040e700099b3126e2cebcc3405662f1380db0bea Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Fri, 19 Jan 2024 19:10:07 +0530
Subject: [PATCH 06/46] revamp pro trial invocation
---
main_ee.go | 1 -
pro/initialize.go | 27 ++++++++++++++++++++-------
pro/trial.go | 3 ++-
3 files changed, 22 insertions(+), 9 deletions(-)
diff --git a/main_ee.go b/main_ee.go
index f05c1d136..90001d870 100644
--- a/main_ee.go
+++ b/main_ee.go
@@ -6,6 +6,5 @@ package main
import "github.com/gravitl/netmaker/pro"
func init() {
- pro.InitTrial()
pro.InitPro()
}
diff --git a/pro/initialize.go b/pro/initialize.go
index 785209292..efa083f9e 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -7,6 +7,7 @@ import (
"time"
controller "github.com/gravitl/netmaker/controllers"
+ "github.com/gravitl/netmaker/logger"
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/mq"
@@ -34,16 +35,28 @@ func InitPro() {
logic.EnterpriseCheckFuncs = append(logic.EnterpriseCheckFuncs, func() {
// == License Handling ==
enableLicenseHook := false
- trialEndDate, err := getTrialEndDate()
- if err != nil {
- slog.Error("failed to get trial end date", "error", err)
+ licenseKeyValue := servercfg.GetLicenseKey()
+ netmakerTenantID := servercfg.GetNetmakerTenantID()
+ if licenseKeyValue != "" && netmakerTenantID != "" {
enableLicenseHook = true
}
- // check if trial ended
- if time.Now().After(trialEndDate) {
- // trial ended already
- enableLicenseHook = true
+ if !enableLicenseHook {
+ err := initTrial()
+ if err != nil {
+ logger.FatalLog0("failed to init trail", err.Error())
+ }
+ trialEndDate, err := getTrialEndDate()
+ if err != nil {
+ slog.Error("failed to get trial end date", "error", err)
+ enableLicenseHook = true
+ }
+ // check if trial ended
+ if time.Now().After(trialEndDate) {
+ // trial ended already
+ enableLicenseHook = true
+ }
}
+
if enableLicenseHook {
slog.Info("starting license checker")
ClearLicenseCache()
diff --git a/pro/trial.go b/pro/trial.go
index 63e4c83eb..6c6b66332 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -41,7 +41,7 @@ const trial_table_name = "trial"
const trial_data_key = "trialdata"
// store trial date
-func InitTrial() error {
+func initTrial() error {
telData, err := logic.FetchTelemetryData()
if err != nil {
return err
@@ -52,6 +52,7 @@ func InitTrial() error {
err = database.CreateTable(trial_table_name)
if err != nil {
slog.Error("failed to create table", "table name", trial_table_name, "err", err.Error())
+ if errors.Is
return err
}
// setup encryption keys
From 34e61403c54d0cce44c24179444fad1b7bebbe23 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Fri, 19 Jan 2024 19:13:02 +0530
Subject: [PATCH 07/46] fix build
---
pro/trial.go | 1 -
1 file changed, 1 deletion(-)
diff --git a/pro/trial.go b/pro/trial.go
index 6c6b66332..4a36ea9ff 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -52,7 +52,6 @@ func initTrial() error {
err = database.CreateTable(trial_table_name)
if err != nil {
slog.Error("failed to create table", "table name", trial_table_name, "err", err.Error())
- if errors.Is
return err
}
// setup encryption keys
From ffb979001f8b5765472962518977566e6f0ecf18 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Sat, 20 Jan 2024 00:30:46 +0530
Subject: [PATCH 08/46] store trial as bytes
---
pro/trial.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pro/trial.go b/pro/trial.go
index 4a36ea9ff..bf1d8d8f1 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -21,7 +21,7 @@ import (
type TrialInfo struct {
PrivKey []byte `json:"priv_key"`
PubKey []byte `json:"pub_key"`
- Secret string `json:"secret"`
+ Secret []byte `json:"secret"`
}
func addTrialLicenseHook() {
@@ -89,7 +89,7 @@ func initTrial() error {
if err != nil {
return err
}
- t.Secret = string(trialDatesSecret)
+ t.Secret = trialDatesSecret
trialData, err := json.Marshal(t)
if err != nil {
return err
@@ -129,7 +129,7 @@ func getTrialEndDate() (time.Time, error) {
return time.Time{}, err
}
// decrypt secret
- secretDecrypt, err := ncutils.BoxDecrypt([]byte(trialInfo.Secret), (*[32]byte)(trialInfo.PubKey), (*[32]byte)(tel.TrafficKeyPriv))
+ secretDecrypt, err := ncutils.BoxDecrypt(trialInfo.Secret, (*[32]byte)(trialInfo.PubKey), (*[32]byte)(tel.TrafficKeyPriv))
if err != nil {
return time.Time{}, err
}
From e390398e8cfe30ac396d7ff1954b986170ccb8cc Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Sat, 20 Jan 2024 01:10:13 +0530
Subject: [PATCH 09/46] conv key pair to bytes
---
pro/trial.go | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/pro/trial.go b/pro/trial.go
index bf1d8d8f1..6bd664cc6 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -85,7 +85,11 @@ func initTrial() error {
if err != nil {
return err
}
- trialDatesSecret, err := ncutils.BoxEncrypt(trialDatesData, (*[32]byte)(tel.TrafficKeyPub), (*[32]byte)(t.PrivKey))
+ telePubKey, err := ncutils.ConvertBytesToKey(tel.TrafficKeyPub)
+ if err != nil {
+ return err
+ }
+ trialDatesSecret, err := ncutils.BoxEncrypt(trialDatesData, telePubKey, trafficPrivKey)
if err != nil {
return err
}
@@ -128,8 +132,16 @@ func getTrialEndDate() (time.Time, error) {
if err != nil {
return time.Time{}, err
}
+ telePrivKey, err := ncutils.ConvertBytesToKey(tel.TrafficKeyPriv)
+ if err != nil {
+ return time.Time{}, err
+ }
+ trialPubKey, err := ncutils.ConvertBytesToKey(trialInfo.PubKey)
+ if err != nil {
+ return time.Time{}, err
+ }
// decrypt secret
- secretDecrypt, err := ncutils.BoxDecrypt(trialInfo.Secret, (*[32]byte)(trialInfo.PubKey), (*[32]byte)(tel.TrafficKeyPriv))
+ secretDecrypt, err := ncutils.BoxDecrypt(trialInfo.Secret, trialPubKey, telePrivKey)
if err != nil {
return time.Time{}, err
}
From 7a39ef3e4ed9dbc03ef596fc65f1281baf8ca10d Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Sat, 20 Jan 2024 01:30:09 +0530
Subject: [PATCH 10/46] add trial end date to server status api
---
controllers/server.go | 13 ++++++++-----
logic/serverconf.go | 40 ++++++----------------------------------
pro/initialize.go | 1 +
3 files changed, 15 insertions(+), 39 deletions(-)
diff --git a/controllers/server.go b/controllers/server.go
index 841552928..5e6f324f9 100644
--- a/controllers/server.go
+++ b/controllers/server.go
@@ -5,6 +5,7 @@ import (
"net/http"
"strings"
"syscall"
+ "time"
"github.com/gorilla/mux"
"golang.org/x/exp/slog"
@@ -109,22 +110,24 @@ func getUsage(w http.ResponseWriter, _ *http.Request) {
// 200: serverConfigResponse
func getStatus(w http.ResponseWriter, r *http.Request) {
type status struct {
- DB bool `json:"db_connected"`
- Broker bool `json:"broker_connected"`
- LicenseError string `json:"license_error"`
- IsPro bool `json:"is_pro"`
+ DB bool `json:"db_connected"`
+ Broker bool `json:"broker_connected"`
+ LicenseError string `json:"license_error"`
+ IsPro bool `json:"is_pro"`
+ TrialEndDate time.Time `json:"trial_end_date"`
}
licenseErr := ""
if servercfg.ErrLicenseValidation != nil {
licenseErr = servercfg.ErrLicenseValidation.Error()
}
-
+ trialEndDate, _ := logic.GetTrialEndDate()
currentServerStatus := status{
DB: database.IsConnected(),
Broker: mq.IsConnected(),
LicenseError: licenseErr,
IsPro: servercfg.IsPro,
+ TrialEndDate: trialEndDate,
}
w.Header().Set("Content-Type", "application/json")
diff --git a/logic/serverconf.go b/logic/serverconf.go
index c307c29d5..de369c689 100644
--- a/logic/serverconf.go
+++ b/logic/serverconf.go
@@ -2,6 +2,8 @@ package logic
import (
"encoding/json"
+ "time"
+
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/servercfg"
)
@@ -19,46 +21,16 @@ var (
EgressesLimit = 1000000000
// FreeTier - specifies if free tier
FreeTier = false
+
+ GetTrialEndDate = func() (time.Time, error) {
+ return time.Time{}, nil
+ }
)
type serverData struct {
PrivateKey string `json:"privatekey,omitempty" bson:"privatekey,omitempty"`
}
-// StorePrivKey - stores server client WireGuard privatekey if needed
-func StorePrivKey(serverID string, privateKey string) error {
- var newData = serverData{}
- var err error
- var data []byte
- newData.PrivateKey = privateKey
- data, err = json.Marshal(&newData)
- if err != nil {
- return err
- }
- return database.Insert(serverID, string(data), database.SERVERCONF_TABLE_NAME)
-}
-
-// FetchPrivKey - fetches private key
-func FetchPrivKey(serverID string) (string, error) {
- var dbData string
- var err error
- var fetchedData = serverData{}
- dbData, err = database.FetchRecord(database.SERVERCONF_TABLE_NAME, serverID)
- if err != nil {
- return "", err
- }
- err = json.Unmarshal([]byte(dbData), &fetchedData)
- if err != nil {
- return "", err
- }
- return fetchedData.PrivateKey, nil
-}
-
-// RemovePrivKey - removes a private key
-func RemovePrivKey(serverID string) error {
- return database.DeleteRecord(database.SERVERCONF_TABLE_NAME, serverID)
-}
-
// FetchJWTSecret - fetches jwt secret from db
func FetchJWTSecret() (string, error) {
var dbData string
diff --git a/pro/initialize.go b/pro/initialize.go
index efa083f9e..64ea99230 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -96,6 +96,7 @@ func InitPro() {
logic.RelayUpdates = proLogic.RelayUpdates
logic.IsInternetGw = proLogic.IsInternetGw
logic.SetInternetGw = proLogic.SetInternetGw
+ logic.GetTrialEndDate = getTrialEndDate
mq.UpdateMetrics = proLogic.MQUpdateMetrics
mq.UpdateMetricsFallBack = proLogic.MQUpdateMetricsFallBack
}
From 17980cc22285490f849abc8f9b972f307941d748 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Sat, 20 Jan 2024 01:39:31 +0530
Subject: [PATCH 11/46] get trial end date only if license key is missing
---
controllers/server.go | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/controllers/server.go b/controllers/server.go
index 5e6f324f9..3e35eb601 100644
--- a/controllers/server.go
+++ b/controllers/server.go
@@ -121,7 +121,10 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
if servercfg.ErrLicenseValidation != nil {
licenseErr = servercfg.ErrLicenseValidation.Error()
}
- trialEndDate, _ := logic.GetTrialEndDate()
+ var trialEndDate time.Time
+ if servercfg.GetLicenseKey() == "" {
+ trialEndDate, _ = logic.GetTrialEndDate()
+ }
currentServerStatus := status{
DB: database.IsConnected(),
Broker: mq.IsConnected(),
From dbc48b1b2ff9af50a9aa52b3d52752d6fd0efd6d Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Mon, 22 Jan 2024 13:25:30 +0530
Subject: [PATCH 12/46] check if trial table is empty
---
pro/trial.go | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/pro/trial.go b/pro/trial.go
index 6bd664cc6..5eb5bc2e9 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -15,7 +15,6 @@ import (
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/netclient/ncutils"
"golang.org/x/crypto/nacl/box"
- "golang.org/x/exp/slog"
)
type TrialInfo struct {
@@ -49,11 +48,14 @@ func initTrial() error {
if telData.Hosts > 0 || telData.Networks > 0 || telData.Users > 0 {
return nil
}
- err = database.CreateTable(trial_table_name)
- if err != nil {
- slog.Error("failed to create table", "table name", trial_table_name, "err", err.Error())
+ database.CreateTable(trial_table_name)
+ records, err := database.FetchRecords(trial_table_name)
+ if err != nil && !database.IsEmptyRecord(err) {
return err
}
+ if len(records) > 0 {
+ return nil
+ }
// setup encryption keys
trafficPubKey, trafficPrivKey, err := box.GenerateKey(rand.Reader) // generate traffic keys
if err != nil {
From 5b335fb7628dcb91f5099105343f0cf76fb22c7c Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 00:18:04 +0530
Subject: [PATCH 13/46] add upgrade and downgrade options
---
scripts/nm-quick.sh | 260 +++++++++++++++++++++++++-------------------
1 file changed, 148 insertions(+), 112 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 14b6a82d8..8c9917e55 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -15,31 +15,19 @@ fi
unset INSTALL_TYPE
unset BUILD_TAG
unset IMAGE_TAG
-unset AUTO_BUILD
unset NETMAKER_BASE_DOMAIN
INSTALL_TYPE="pro"
-UPGRADE_FLAG="yes"
# usage - displays usage instructions
usage() {
echo "nm-quick.sh v$NM_QUICK_VERSION"
echo "usage: ./nm-quick.sh [-c]"
- echo " -c if specified, will install netmaker community version"
-
+ echo " -c if specified, will install netmaker community version"
+ echo " -u if specified, will upgrade netmaker to pro version"
+ echo " -d if specified, will downgrade netmaker to community version"
exit 1
}
-while getopts evab:d:t: flag; do
- case "${flag}" in
- c)
- INSTALL_TYPE="ce"
- UPGRADE_FLAG="no"
- ;;
- v)
- usage
- exit 0
- ;;
- esac
-done
+
# print_logo - prints the netmaker logo
print_logo() {
@@ -74,10 +62,7 @@ set_buildinfo() {
elif [ "$1" = "pro" ]; then
INSTALL_TYPE="pro"
fi
-
- if [ "$AUTO_BUILD" = "on" ] && [ -z "$INSTALL_TYPE" ]; then
- INSTALL_TYPE="ce"
- elif [ -z "$INSTALL_TYPE" ]; then
+ if [ -z "$INSTALL_TYPE" ]; then
echo "-----------------------------------------------------"
echo "Would you like to install Netmaker Community Edition (CE), or Netmaker Enterprise Edition (pro)?"
echo "pro will require you to create an account at https://app.netmaker.io"
@@ -217,9 +202,6 @@ wait_seconds() { (
# confirm - get user input to confirm that they want to perform the next step
confirm() { (
- if [ "$AUTO_BUILD" = "on" ]; then
- return 0
- fi
while true; do
read -p 'Does everything look right? [y/n]: ' yn
case $yn in
@@ -440,27 +422,23 @@ set_install_vars() {
echo "For this reason, we STRONGLY RECOMMEND using your own domain. Using the auto-generated domain may lead to a failed installation due to rate limiting."
echo "-----------------------------------------------------"
- if [ "$AUTO_BUILD" = "on" ]; then
- DOMAIN_TYPE="auto"
- else
- select domain_option in "Auto Generated ($NETMAKER_BASE_DOMAIN)" "Custom Domain (e.x: netmaker.example.com)"; do
- case $REPLY in
- 1)
- echo "using $NETMAKER_BASE_DOMAIN for base domain"
- DOMAIN_TYPE="auto"
- break
- ;;
- 2)
- read -p "Enter Custom Domain (make sure *.domain points to $SERVER_HOST first): " domain
- NETMAKER_BASE_DOMAIN=$domain
- echo "using $NETMAKER_BASE_DOMAIN"
- DOMAIN_TYPE="custom"
- break
- ;;
- *) echo "invalid option $REPLY" ;;
- esac
- done
- fi
+ select domain_option in "Auto Generated ($NETMAKER_BASE_DOMAIN)" "Custom Domain (e.x: netmaker.example.com)"; do
+ case $REPLY in
+ 1)
+ echo "using $NETMAKER_BASE_DOMAIN for base domain"
+ DOMAIN_TYPE="auto"
+ break
+ ;;
+ 2)
+ read -p "Enter Custom Domain (make sure *.domain points to $SERVER_HOST first): " domain
+ NETMAKER_BASE_DOMAIN=$domain
+ echo "using $NETMAKER_BASE_DOMAIN"
+ DOMAIN_TYPE="custom"
+ break
+ ;;
+ *) echo "invalid option $REPLY" ;;
+ esac
+ done
wait_seconds 2
@@ -491,9 +469,7 @@ set_install_vars() {
RAND_EMAIL="$(echo $RANDOM | md5sum | head -c 16)@email.com"
# suggest the prev email or a random one
EMAIL_SUGGESTED=${NM_EMAIL:-$RAND_EMAIL}
- if [ -z $AUTO_BUILD ]; then
- read -p "Email Address for Domain Registration (click 'enter' to use $EMAIL_SUGGESTED): " GET_EMAIL
- fi
+ read -p "Email Address for Domain Registration (click 'enter' to use $EMAIL_SUGGESTED): " GET_EMAIL
if [ -z "$GET_EMAIL" ]; then
EMAIL="$EMAIL_SUGGESTED"
if [ "$EMAIL" = "$NM_EMAIL" ]; then
@@ -511,9 +487,8 @@ set_install_vars() {
unset GET_MQ_PASSWORD
unset CONFIRM_MQ_PASSWORD
echo "Enter Credentials For MQ..."
- if [ -z $AUTO_BUILD ]; then
- read -p "MQ Username (click 'enter' to use 'netmaker'): " GET_MQ_USERNAME
- fi
+
+ read -p "MQ Username (click 'enter' to use 'netmaker'): " GET_MQ_USERNAME
if [ -z "$GET_MQ_USERNAME" ]; then
echo "using default username for mq"
MQ_USERNAME="netmaker"
@@ -528,33 +503,33 @@ set_install_vars() {
)
fi
- if [ -z $AUTO_BUILD ]; then
- select domain_option in "Auto Generated / Config Password" "Input Your Own Password"; do
- case $REPLY in
- 1)
- echo "using random password for mq"
- break
- ;;
- 2)
- while true; do
- echo "Enter your Password For MQ: "
- read -s GET_MQ_PASSWORD
- echo "Enter your password again to confirm: "
- read -s CONFIRM_MQ_PASSWORD
- if [ ${GET_MQ_PASSWORD} != ${CONFIRM_MQ_PASSWORD} ]; then
- echo "wrong password entered, try again..."
- continue
- fi
- MQ_PASSWORD="$GET_MQ_PASSWORD"
- echo "MQ Password Saved Successfully!!"
- break
- done
+
+ select domain_option in "Auto Generated / Config Password" "Input Your Own Password"; do
+ case $REPLY in
+ 1)
+ echo "using random password for mq"
+ break
+ ;;
+ 2)
+ while true; do
+ echo "Enter your Password For MQ: "
+ read -s GET_MQ_PASSWORD
+ echo "Enter your password again to confirm: "
+ read -s CONFIRM_MQ_PASSWORD
+ if [ ${GET_MQ_PASSWORD} != ${CONFIRM_MQ_PASSWORD} ]; then
+ echo "wrong password entered, try again..."
+ continue
+ fi
+ MQ_PASSWORD="$GET_MQ_PASSWORD"
+ echo "MQ Password Saved Successfully!!"
break
- ;;
- *) echo "invalid option $REPLY" ;;
- esac
- done
- fi
+ done
+ break
+ ;;
+ *) echo "invalid option $REPLY" ;;
+ esac
+ done
+
wait_seconds 2
@@ -700,6 +675,10 @@ cleanup() {
fi
fi
+ stop_services
+}
+
+stop_services(){
echo "Stopping all containers..."
local containers=("mq" "netmaker-ui" "coredns" "turn" "caddy" "netmaker" "netmaker-exporter" "prometheus" "grafana")
for name in "${containers[@]}"; do
@@ -714,57 +693,114 @@ cleanup() {
done
}
-# 1. print netmaker logo
-print_logo
+upgrade() {
+ set_buildinfo
+ stop_services
+ echo "-----------------------------------------------------"
+ echo "Provide Details for pro installation:"
+ echo " 1. Log into https://app.netmaker.io"
+ echo " 2. follow instructions to get a license at: https://docs.netmaker.io/ee/ee-setup.html"
+ echo " 3. Retrieve License and Tenant ID"
+ echo " 4. note email address"
+ echo "-----------------------------------------------------"
+ unset LICENSE_KEY
+ while [ -z "$LICENSE_KEY" ]; do
+ read -p "License Key: " LICENSE_KEY
+ done
+ unset TENANT_ID
+ while [ -z ${TENANT_ID} ]; do
+ read -p "Tenant ID: " TENANT_ID
+ done
+ save_config
+ install_netmaker
+}
-# read the config
-if [ -f "$CONFIG_PATH" ]; then
- echo "Using config: $CONFIG_PATH"
- source "$CONFIG_PATH"
-fi
+downgrade () {
+ set_buildinfo
+ stop_services
+ save_config
+ if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
+ rm -f "$SCRIPT_DIR"/docker-compose.override.yml
+ fi
+ install_netmaker
+}
-# 2. setup the build instructions
-set_buildinfo
-set +e
+main (){
+ # 1. print netmaker logo
+ print_logo
-# 3. install necessary packages
-install_dependencies
+ # read the config
+ if [ -f "$CONFIG_PATH" ]; then
+ echo "Using config: $CONFIG_PATH"
+ source "$CONFIG_PATH"
+ fi
-# 4. install yq if necessary
-install_yq
-set -e
+ while getopts evab:d:t: flag; do
+ case "${flag}" in
+ c)
+ INSTALL_TYPE="ce"
+ ;;
+ u)
+ INSTALL_TYPE="pro"
+ upgrade
+ exit 0
+ ;;
+ d)
+ INSTALL_TYPE="ce"
+ downgrade
+ exit 0
+ ;;
+ v)
+ usage
+ exit 0
+ ;;
+ esac
+done
-# 6. get user input for variables
-set_install_vars
+ # 2. setup the build instructions
+ set_buildinfo
+ set +e
+ # 3. install necessary packages
+ install_dependencies
-set +e
-cleanup
-set -e
+ # 4. install yq if necessary
+ install_yq
+
+ set -e
+
+ # 6. get user input for variables
+ set_install_vars
+
+ set +e
+ cleanup
+ set -e
-# 7. get and set config files, startup docker-compose
-install_netmaker
+ # 7. get and set config files, startup docker-compose
+ install_netmaker
-set +e
+ set +e
-# 8. make sure Caddy certs are working
-test_connection
+ # 8. make sure Caddy certs are working
+ test_connection
-# 9. install the netmaker CLI
-setup_nmctl
+ # 9. install the netmaker CLI
+ setup_nmctl
-# 10. create a default mesh network for netmaker
-setup_mesh
+ # 10. create a default mesh network for netmaker
+ setup_mesh
-set -e
+ set -e
-# 11. add netclient to docker-compose and start it up
-setup_netclient
+ # 11. add netclient to docker-compose and start it up
+ setup_netclient
-# 12. make the netclient a default host and ingress gw
-configure_netclient
+ # 12. make the netclient a default host and ingress gw
+ configure_netclient
-# 13. print success message
-print_success
+ # 13. print success message
+ print_success
+}
+main "${@}"
\ No newline at end of file
From 49641dff5a67576cfa41c46e6ab0427ac5a7a278 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 00:26:40 +0530
Subject: [PATCH 14/46] fix script args
---
scripts/nm-quick.sh | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 8c9917e55..b8a6a6d5f 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -694,6 +694,7 @@ stop_services(){
}
upgrade() {
+ print_logo
set_buildinfo
stop_services
echo "-----------------------------------------------------"
@@ -716,6 +717,7 @@ upgrade() {
}
downgrade () {
+ print_logo
set_buildinfo
stop_services
save_config
@@ -727,8 +729,6 @@ downgrade () {
main (){
- # 1. print netmaker logo
- print_logo
# read the config
if [ -f "$CONFIG_PATH" ]; then
@@ -737,7 +737,7 @@ main (){
fi
- while getopts evab:d:t: flag; do
+ while getopts :cudv flag; do
case "${flag}" in
c)
INSTALL_TYPE="ce"
@@ -759,6 +759,9 @@ main (){
esac
done
+ # 1. print netmaker logo
+ print_logo
+
# 2. setup the build instructions
set_buildinfo
set +e
From 49c64ef95b6b959511672b890770a29d09b19a1c Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 00:41:32 +0530
Subject: [PATCH 15/46] save config only if values are not empty
---
scripts/nm-quick.sh | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index b8a6a6d5f..600ecc6df 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -219,11 +219,16 @@ confirm() { (
done
) }
+
save_config() { (
echo "Saving the config to $CONFIG_PATH"
touch "$CONFIG_PATH"
- save_config_item NM_EMAIL "$EMAIL"
- save_config_item NM_DOMAIN "$NETMAKER_BASE_DOMAIN"
+ if [ -n "$EMAIL" ]; then
+ save_config_item NM_EMAIL "$EMAIL"
+ fi
+ if [ -n "$NETMAKER_BASE_DOMAIN" ]; then
+ save_config_item NM_DOMAIN "$NETMAKER_BASE_DOMAIN"
+ fi
save_config_item UI_IMAGE_TAG "$IMAGE_TAG"
# version-specific entries
if [ "$INSTALL_TYPE" = "pro" ]; then
From cf9febba03b85a8e10c251496785da7b77d33bd9 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 00:48:16 +0530
Subject: [PATCH 16/46] fix script args
---
scripts/nm-quick.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 600ecc6df..0c0f62085 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -700,7 +700,7 @@ stop_services(){
upgrade() {
print_logo
- set_buildinfo
+ set_buildinfo "$INSTALL_TYPE"
stop_services
echo "-----------------------------------------------------"
echo "Provide Details for pro installation:"
@@ -723,7 +723,7 @@ upgrade() {
downgrade () {
print_logo
- set_buildinfo
+ set_buildinfo "$INSTALL_TYPE"
stop_services
save_config
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
From dc953c73a86ae88a04a69300f686144182dcc144 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 00:53:02 +0530
Subject: [PATCH 17/46] fix script args
---
scripts/nm-quick.sh | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 0c0f62085..23467f59a 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -57,11 +57,6 @@ set_buildinfo() {
BUILD_TAG=$LATEST
IMAGE_TAG=$(sed 's/\//-/g' <<<"$BUILD_TAG")
- if [ "$1" = "ce" ]; then
- INSTALL_TYPE="ce"
- elif [ "$1" = "pro" ]; then
- INSTALL_TYPE="pro"
- fi
if [ -z "$INSTALL_TYPE" ]; then
echo "-----------------------------------------------------"
echo "Would you like to install Netmaker Community Edition (CE), or Netmaker Enterprise Edition (pro)?"
@@ -700,7 +695,7 @@ stop_services(){
upgrade() {
print_logo
- set_buildinfo "$INSTALL_TYPE"
+ set_buildinfo
stop_services
echo "-----------------------------------------------------"
echo "Provide Details for pro installation:"
@@ -723,7 +718,7 @@ upgrade() {
downgrade () {
print_logo
- set_buildinfo "$INSTALL_TYPE"
+ set_buildinfo
stop_services
save_config
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
From c16ea48bb4e9e33c1db1a0f0861c49a87e4dfc8e Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 00:55:55 +0530
Subject: [PATCH 18/46] fix script args
---
scripts/nm-quick.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 23467f59a..b4fd07c87 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -736,7 +736,7 @@ main (){
source "$CONFIG_PATH"
fi
-
+ INSTALL_TYPE="pro"
while getopts :cudv flag; do
case "${flag}" in
c)
From ce34a3f4cbb58dd83924ea79a9739eb52db9a5ea Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 01:02:32 +0530
Subject: [PATCH 19/46] more info log
---
scripts/nm-quick.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index b4fd07c87..b4d5bb5d1 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -679,7 +679,7 @@ cleanup() {
}
stop_services(){
- echo "Stopping all containers..."
+ echo "Stopping all containers, this will take a while please wait..."
local containers=("mq" "netmaker-ui" "coredns" "turn" "caddy" "netmaker" "netmaker-exporter" "prometheus" "grafana")
for name in "${containers[@]}"; do
local running=$(docker ps | grep -w "$name")
From 96c649558562c6190f741891044217b95ae93b48 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 08:02:03 +0530
Subject: [PATCH 20/46] check if netclient exists
---
scripts/nm-quick.sh | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index b4d5bb5d1..a5f028ff0 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -665,6 +665,9 @@ print_success() {
cleanup() {
# remove the existing netclient's instance from the existing network
+ if ! command -v netclient >/dev/null 2>&1; then
+ return
+ fi
if command -v nmctl >/dev/null 2>&1; then
local node_id=$(netclient list | jq '.[0].node_id' 2>/dev/null)
# trim doublequotes
From 1f44817e644b3ae82312176e2efcb7f9ea3e91d3 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 08:33:17 +0530
Subject: [PATCH 21/46] add tenantid check
---
controllers/server.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/controllers/server.go b/controllers/server.go
index 3e35eb601..6e10d456f 100644
--- a/controllers/server.go
+++ b/controllers/server.go
@@ -122,7 +122,7 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
licenseErr = servercfg.ErrLicenseValidation.Error()
}
var trialEndDate time.Time
- if servercfg.GetLicenseKey() == "" {
+ if servercfg.GetLicenseKey() == "" || servercfg.GetNetmakerTenantID() == "" {
trialEndDate, _ = logic.GetTrialEndDate()
}
currentServerStatus := status{
From 487c3f51b02358c7f02505f9a2c6d666d9f61090 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 09:08:08 +0530
Subject: [PATCH 22/46] addtional logs in script
---
pro/initialize.go | 1 +
scripts/nm-quick.sh | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/pro/initialize.go b/pro/initialize.go
index 64ea99230..b032dd1d6 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -69,6 +69,7 @@ func InitPro() {
// == End License Handling ==
AddLicenseHooks()
} else {
+ slog.Info("starting trial license hook")
addTrialLicenseHook()
}
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index a5f028ff0..679a24d58 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -16,7 +16,6 @@ unset INSTALL_TYPE
unset BUILD_TAG
unset IMAGE_TAG
unset NETMAKER_BASE_DOMAIN
-INSTALL_TYPE="pro"
# usage - displays usage instructions
usage() {
echo "nm-quick.sh v$NM_QUICK_VERSION"
@@ -746,11 +745,13 @@ main (){
INSTALL_TYPE="ce"
;;
u)
+ echo "upgrading to pro version..."
INSTALL_TYPE="pro"
upgrade
exit 0
;;
d)
+ echo "downgrading to community version..."
INSTALL_TYPE="ce"
downgrade
exit 0
From 32974e21d4b09cda5daa15520809820e580428e9 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 09:21:19 +0530
Subject: [PATCH 23/46] skip trial end date check on err
---
pro/initialize.go | 12 +++++++-----
pro/trial.go | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/pro/initialize.go b/pro/initialize.go
index b032dd1d6..c7b54495e 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -49,12 +49,14 @@ func InitPro() {
if err != nil {
slog.Error("failed to get trial end date", "error", err)
enableLicenseHook = true
+ } else {
+ // check if trial ended
+ if time.Now().After(trialEndDate) {
+ // trial ended already
+ enableLicenseHook = true
+ }
}
- // check if trial ended
- if time.Now().After(trialEndDate) {
- // trial ended already
- enableLicenseHook = true
- }
+
}
if enableLicenseHook {
diff --git a/pro/trial.go b/pro/trial.go
index 5eb5bc2e9..791bf1668 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -46,7 +46,7 @@ func initTrial() error {
return err
}
if telData.Hosts > 0 || telData.Networks > 0 || telData.Users > 0 {
- return nil
+ return nil // database is already populated, so skip creating trial
}
database.CreateTable(trial_table_name)
records, err := database.FetchRecords(trial_table_name)
From 1d250963aa51285ab8e8edda336980cc9ba90197 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 09:34:49 +0530
Subject: [PATCH 24/46] add license logs
---
pro/initialize.go | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pro/initialize.go b/pro/initialize.go
index c7b54495e..802acd556 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -60,18 +60,18 @@ func InitPro() {
}
if enableLicenseHook {
- slog.Info("starting license checker")
+ logger.Log(0, "starting license checker")
ClearLicenseCache()
if err := ValidateLicense(); err != nil {
slog.Error(err.Error())
return
}
- slog.Info("proceeding with Paid Tier license")
+ logger.Log(0, "proceeding with Paid Tier license")
logic.SetFreeTierForTelemetry(false)
// == End License Handling ==
AddLicenseHooks()
} else {
- slog.Info("starting trial license hook")
+ logger.Log(0, "starting trial license hook")
addTrialLicenseHook()
}
From 2a4d04ceb6c68626f5107d0d5dcb41d1fc5a1392 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 10:02:46 +0530
Subject: [PATCH 25/46] limit api handler if trail has ended
---
pro/initialize.go | 3 ++-
pro/trial.go | 13 +++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/pro/initialize.go b/pro/initialize.go
index 802acd556..8b28eba77 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -43,7 +43,8 @@ func InitPro() {
if !enableLicenseHook {
err := initTrial()
if err != nil {
- logger.FatalLog0("failed to init trail", err.Error())
+ logger.Log(0, "failed to init trial", err.Error())
+ enableLicenseHook = true
}
trialEndDate, err := getTrialEndDate()
if err != nil {
diff --git a/pro/trial.go b/pro/trial.go
index 791bf1668..9b4025753 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -1,6 +1,3 @@
-//go:build ee
-// +build ee
-
package pro
import (
@@ -14,6 +11,7 @@ import (
"github.com/gravitl/netmaker/logic"
"github.com/gravitl/netmaker/models"
"github.com/gravitl/netmaker/netclient/ncutils"
+ "github.com/gravitl/netmaker/servercfg"
"golang.org/x/crypto/nacl/box"
)
@@ -39,7 +37,7 @@ const trial_table_name = "trial"
const trial_data_key = "trialdata"
-// store trial date
+// stores trial end date
func initTrial() error {
telData, err := logic.FetchTelemetryData()
if err != nil {
@@ -107,14 +105,17 @@ func initTrial() error {
return nil
}
+// TrialLicenseHook - hook func to check if pro trial has ended
func TrialLicenseHook() error {
endDate, err := getTrialEndDate()
if err != nil {
logger.FatalLog0("failed to trial end date", err.Error())
}
if time.Now().After(endDate) {
- logger.FatalLog0("***IMPORTANT: Your Trial Has Ended, to continue using pro version, please visit https://app.netmaker.io/ and create on-prem tenant to obtain a license***\nIf you wish to downgrade to community version, please run this command `/root/nm-quick.sh -d`")
-
+ logger.Log(0, "***IMPORTANT: Your Trial Has Ended, to continue using pro version, please visit https://app.netmaker.io/ and create on-prem tenant to obtain a license***\nIf you wish to downgrade to community version, please run this command `/root/nm-quick.sh -d`")
+ err = errors.New("your trial has ended")
+ servercfg.ErrLicenseValidation = err
+ return err
}
return nil
}
From 4fe282d5d7850ba85b4cbbedaeb07211954dfd83 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 10:34:45 +0530
Subject: [PATCH 26/46] add trial license status to server status api
---
controllers/server.go | 33 +++++++++++++++++++++------------
1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/controllers/server.go b/controllers/server.go
index 6e10d456f..c939706ed 100644
--- a/controllers/server.go
+++ b/controllers/server.go
@@ -110,11 +110,12 @@ func getUsage(w http.ResponseWriter, _ *http.Request) {
// 200: serverConfigResponse
func getStatus(w http.ResponseWriter, r *http.Request) {
type status struct {
- DB bool `json:"db_connected"`
- Broker bool `json:"broker_connected"`
- LicenseError string `json:"license_error"`
- IsPro bool `json:"is_pro"`
- TrialEndDate time.Time `json:"trial_end_date"`
+ DB bool `json:"db_connected"`
+ Broker bool `json:"broker_connected"`
+ LicenseError string `json:"license_error"`
+ IsPro bool `json:"is_pro"`
+ TrialEndDate time.Time `json:"trial_end_date"`
+ IsOnTrialLicense bool `json:"is_on_trial_license"`
}
licenseErr := ""
@@ -122,15 +123,23 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
licenseErr = servercfg.ErrLicenseValidation.Error()
}
var trialEndDate time.Time
- if servercfg.GetLicenseKey() == "" || servercfg.GetNetmakerTenantID() == "" {
- trialEndDate, _ = logic.GetTrialEndDate()
+ var err error
+ isOnTrial := false
+ if servercfg.IsPro && (servercfg.GetLicenseKey() == "" || servercfg.GetNetmakerTenantID() == "") {
+ trialEndDate, err = logic.GetTrialEndDate()
+ if err != nil {
+ slog.Error("failed to get trial end date", "error", err)
+ } else {
+ isOnTrial = true
+ }
}
currentServerStatus := status{
- DB: database.IsConnected(),
- Broker: mq.IsConnected(),
- LicenseError: licenseErr,
- IsPro: servercfg.IsPro,
- TrialEndDate: trialEndDate,
+ DB: database.IsConnected(),
+ Broker: mq.IsConnected(),
+ LicenseError: licenseErr,
+ IsPro: servercfg.IsPro,
+ TrialEndDate: trialEndDate,
+ IsOnTrialLicense: isOnTrial,
}
w.Header().Set("Content-Type", "application/json")
From 13caec205bbbe0c73fa0628b8bbaa65b642c093d Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 11:37:59 +0530
Subject: [PATCH 27/46] get pro override compose only on upgrade
---
scripts/nm-quick.sh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 679a24d58..b67fb027b 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -16,6 +16,7 @@ unset INSTALL_TYPE
unset BUILD_TAG
unset IMAGE_TAG
unset NETMAKER_BASE_DOMAIN
+unset UPGRADE_FLAG
# usage - displays usage instructions
usage() {
echo "nm-quick.sh v$NM_QUICK_VERSION"
@@ -565,7 +566,7 @@ install_netmaker() {
local CADDY_URL="$BASE_URL/docker/Caddyfile-pro"
fi
wget -qO "$SCRIPT_DIR"/docker-compose.yml $COMPOSE_URL
- if test -n "$COMPOSE_OVERRIDE_URL"; then
+ if [ "$UPGRADE_FLAG" = "yes" ]; then
wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
fi
wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
@@ -747,6 +748,7 @@ main (){
u)
echo "upgrading to pro version..."
INSTALL_TYPE="pro"
+ UPGRADE_FLAG="yes"
upgrade
exit 0
;;
From a57c6691f88c746cf3c579c9979bf9b5888542a8 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 11:42:29 +0530
Subject: [PATCH 28/46] turn of exporter only on upgrade
---
scripts/nm-quick.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index b67fb027b..42df2c653 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -229,8 +229,10 @@ save_config() { (
if [ "$INSTALL_TYPE" = "pro" ]; then
save_config_item NETMAKER_TENANT_ID "$TENANT_ID"
save_config_item LICENSE_KEY "$LICENSE_KEY"
- save_config_item METRICS_EXPORTER "on"
- save_config_item PROMETHEUS "on"
+ if [ "$UPGRADE_FLAG" = "yes" ];then
+ save_config_item METRICS_EXPORTER "on"
+ save_config_item PROMETHEUS "on"
+ fi
save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG-ee"
else
save_config_item "off"
From b7e900f4bc759ef5f1aba6a0c3f080e9018eb758 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 11:44:51 +0530
Subject: [PATCH 29/46] turn of exporter only on upgrade
---
scripts/nm-quick.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 42df2c653..c66004d7a 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -450,7 +450,7 @@ set_install_vars() {
echo " api.$NETMAKER_BASE_DOMAIN"
echo " broker.$NETMAKER_BASE_DOMAIN"
- if [ "$INSTALL_TYPE" = "pro" ]; then
+ if [ "$UPGRADE_FLAG" = "yes" ]; then
echo " prometheus.$NETMAKER_BASE_DOMAIN"
echo " netmaker-exporter.$NETMAKER_BASE_DOMAIN"
echo " grafana.$NETMAKER_BASE_DOMAIN"
From c2eb66243bd5a6615d26e0fdc9c0d12fedc58736 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 11:47:57 +0530
Subject: [PATCH 30/46] rm overeride file if present
---
scripts/nm-quick.sh | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index c66004d7a..73d70e27b 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -570,6 +570,8 @@ install_netmaker() {
wget -qO "$SCRIPT_DIR"/docker-compose.yml $COMPOSE_URL
if [ "$UPGRADE_FLAG" = "yes" ]; then
wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
+ elif [ test -f "$SCRIPT_DIR"/docker-compose.override.yml ]; then
+ rm -f "$SCRIPT_DIR"/docker-compose.override.yml
fi
wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
wget -qO "$SCRIPT_DIR"/netmaker.default.env "$BASE_URL/scripts/netmaker.default.env"
From 1e90772d9b5b52a5299b4a20b72919954fc16857 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 11:50:57 +0530
Subject: [PATCH 31/46] rm overide file if present
---
scripts/nm-quick.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 73d70e27b..cc42c5b1c 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -570,7 +570,7 @@ install_netmaker() {
wget -qO "$SCRIPT_DIR"/docker-compose.yml $COMPOSE_URL
if [ "$UPGRADE_FLAG" = "yes" ]; then
wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
- elif [ test -f "$SCRIPT_DIR"/docker-compose.override.yml ]; then
+ elif [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
fi
wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
From 1a17f4ea4d18f786c04c064798fff3e716d45039 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 16:16:28 +0530
Subject: [PATCH 32/46] script fixes
---
scripts/nm-quick.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index cc42c5b1c..c9db17027 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -235,7 +235,7 @@ save_config() { (
fi
save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG-ee"
else
- save_config_item "off"
+ save_config_item METRICS_EXPORTER "off"
save_config_item PROMETHEUS "off"
save_config_item SERVER_IMAGE_TAG "$IMAGE_TAG"
fi
@@ -244,7 +244,7 @@ save_config() { (
"INSTALL_TYPE" "NODE_ID" "DNS_MODE" "NETCLIENT_AUTO_UPDATE" "API_PORT"
"CORS_ALLOWED_ORIGIN" "DISPLAY_KEYS" "DATABASE" "SERVER_BROKER_ENDPOINT" "VERBOSITY"
"DEBUG_MODE" "REST_BACKEND" "DISABLE_REMOTE_IP_CHECK" "TELEMETRY" "AUTH_PROVIDER" "CLIENT_ID" "CLIENT_SECRET"
- "FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_AUTO_DISABLE")
+ "FRONTEND_URL" "AZURE_TENANT" "OIDC_ISSUER" "EXPORTER_API_PORT" "JWT_VALIDITY_DURATION" "RAC_AUTO_DISABLE" "CACHING_ENABLED")
for name in "${toCopy[@]}"; do
save_config_item $name "${!name}"
done
From 17a63928b6674deb47c0a82b60bd30d03c6e4e67 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 16:41:28 +0530
Subject: [PATCH 33/46] image tag for testing
---
scripts/nm-quick.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index c9db17027..472c3ffc8 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -55,7 +55,7 @@ set_buildinfo() {
BUILD_TAG=$LATEST
- IMAGE_TAG=$(sed 's/\//-/g' <<<"$BUILD_TAG")
+ IMAGE_TAG=NET-898
if [ -z "$INSTALL_TYPE" ]; then
echo "-----------------------------------------------------"
From a446c50f121d598dfed38e7bb0ea9a62fea3ac15 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Tue, 23 Jan 2024 22:17:32 +0530
Subject: [PATCH 34/46] check for pro, if host is getting relayed
---
logic/peers.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/logic/peers.go b/logic/peers.go
index 8359c35d5..9826156e6 100644
--- a/logic/peers.go
+++ b/logic/peers.go
@@ -144,7 +144,7 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, getExtpeersExtraRoutes(peer.Network)...)
}
_, isFailOverPeer := node.FailOverPeers[peer.ID.String()]
- if (node.IsRelayed && node.RelayedBy != peer.ID.String()) ||
+ if servercfg.IsPro && (node.IsRelayed && node.RelayedBy != peer.ID.String()) ||
(peer.IsRelayed && peer.RelayedBy != node.ID.String()) || isFailOverPeer {
// if node is relayed and peer is not the relay, set remove to true
if _, ok := peerIndexMap[peerHost.PublicKey.String()]; ok {
From c690eb18c2517588a8cbcba4bb2308d93b7865ce Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 00:29:21 +0530
Subject: [PATCH 35/46] mover failOver func to pro pkg
---
logic/peers.go | 29 ++++-------------------------
pro/initialize.go | 1 +
pro/logic/failover.go | 27 +++++++++++++++++++++++++++
3 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/logic/peers.go b/logic/peers.go
index 9826156e6..94e16f734 100644
--- a/logic/peers.go
+++ b/logic/peers.go
@@ -24,6 +24,10 @@ var (
ResetFailedOverPeer = func(failedOverNode *models.Node) error {
return nil
}
+ // GetFailOverPeerIps - gets failover peerips
+ GetFailOverPeerIps = func(peer, node *models.Node) []net.IPNet {
+ return []net.IPNet{}
+ }
)
// GetPeerUpdateForHost - gets the consolidated peer update for the host from all networks
@@ -362,31 +366,6 @@ func GetAllowedIPs(node, peer *models.Node, metrics *models.Metrics) []net.IPNet
return allowedips
}
-func GetFailOverPeerIps(peer, node *models.Node) []net.IPNet {
- allowedips := []net.IPNet{}
- for failOverpeerID := range node.FailOverPeers {
- failOverpeer, err := GetNodeByID(failOverpeerID)
- if err == nil && failOverpeer.FailedOverBy == peer.ID {
- if failOverpeer.Address.IP != nil {
- allowed := net.IPNet{
- IP: failOverpeer.Address.IP,
- Mask: net.CIDRMask(32, 32),
- }
- allowedips = append(allowedips, allowed)
- }
- if failOverpeer.Address6.IP != nil {
- allowed := net.IPNet{
- IP: failOverpeer.Address6.IP,
- Mask: net.CIDRMask(128, 128),
- }
- allowedips = append(allowedips, allowed)
- }
-
- }
- }
- return allowedips
-}
-
func GetEgressIPs(peer *models.Node) []net.IPNet {
peerHost, err := GetHost(peer.HostID.String())
diff --git a/pro/initialize.go b/pro/initialize.go
index 8b28eba77..5481e5072 100644
--- a/pro/initialize.go
+++ b/pro/initialize.go
@@ -83,6 +83,7 @@ func InitPro() {
})
logic.ResetFailOver = proLogic.ResetFailOver
logic.ResetFailedOverPeer = proLogic.ResetFailedOverPeer
+ logic.GetFailOverPeerIps = proLogic.GetFailOverPeerIps
logic.DenyClientNodeAccess = proLogic.DenyClientNode
logic.IsClientNodeAllowed = proLogic.IsClientNodeAllowed
logic.AllowClientNodeAccess = proLogic.RemoveDeniedNodeFromClient
diff --git a/pro/logic/failover.go b/pro/logic/failover.go
index d8006334b..c3a94c207 100644
--- a/pro/logic/failover.go
+++ b/pro/logic/failover.go
@@ -2,6 +2,7 @@ package logic
import (
"errors"
+ "net"
"github.com/google/uuid"
"github.com/gravitl/netmaker/logic"
@@ -96,3 +97,29 @@ func ResetFailOver(failOverNode *models.Node) error {
}
return nil
}
+
+// GetFailOverPeerIps - adds the failedOvered peerIps by the peer
+func GetFailOverPeerIps(peer, node *models.Node) []net.IPNet {
+ allowedips := []net.IPNet{}
+ for failOverpeerID := range node.FailOverPeers {
+ failOverpeer, err := logic.GetNodeByID(failOverpeerID)
+ if err == nil && failOverpeer.FailedOverBy == peer.ID {
+ if failOverpeer.Address.IP != nil {
+ allowed := net.IPNet{
+ IP: failOverpeer.Address.IP,
+ Mask: net.CIDRMask(32, 32),
+ }
+ allowedips = append(allowedips, allowed)
+ }
+ if failOverpeer.Address6.IP != nil {
+ allowed := net.IPNet{
+ IP: failOverpeer.Address6.IP,
+ Mask: net.CIDRMask(128, 128),
+ }
+ allowedips = append(allowedips, allowed)
+ }
+
+ }
+ }
+ return allowedips
+}
From baaba5912802aabc0444545426449015e010747a Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 00:31:17 +0530
Subject: [PATCH 36/46] check for pro, if host is getting relayed
---
logic/peers.go | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/logic/peers.go b/logic/peers.go
index 94e16f734..c63ea2867 100644
--- a/logic/peers.go
+++ b/logic/peers.go
@@ -148,16 +148,18 @@ func GetPeerUpdateForHost(network string, host *models.Host, allNodes []models.N
hostPeerUpdate.EgressRoutes = append(hostPeerUpdate.EgressRoutes, getExtpeersExtraRoutes(peer.Network)...)
}
_, isFailOverPeer := node.FailOverPeers[peer.ID.String()]
- if servercfg.IsPro && (node.IsRelayed && node.RelayedBy != peer.ID.String()) ||
- (peer.IsRelayed && peer.RelayedBy != node.ID.String()) || isFailOverPeer {
- // if node is relayed and peer is not the relay, set remove to true
- if _, ok := peerIndexMap[peerHost.PublicKey.String()]; ok {
+ if servercfg.IsPro {
+ if (node.IsRelayed && node.RelayedBy != peer.ID.String()) ||
+ (peer.IsRelayed && peer.RelayedBy != node.ID.String()) || isFailOverPeer {
+ // if node is relayed and peer is not the relay, set remove to true
+ if _, ok := peerIndexMap[peerHost.PublicKey.String()]; ok {
+ continue
+ }
+ peerConfig.Remove = true
+ hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
+ peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
continue
}
- peerConfig.Remove = true
- hostPeerUpdate.Peers = append(hostPeerUpdate.Peers, peerConfig)
- peerIndexMap[peerHost.PublicKey.String()] = len(hostPeerUpdate.Peers) - 1
- continue
}
uselocal := false
From c67571e0d09ad9076fcd568b18fdbf9845ab0f87 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 15:46:30 +0530
Subject: [PATCH 37/46] on upgrade and downgrade of tier perisist image tag
---
scripts/nm-quick.sh | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 472c3ffc8..748acb33c 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -55,7 +55,7 @@ set_buildinfo() {
BUILD_TAG=$LATEST
- IMAGE_TAG=NET-898
+ IMAGE_TAG=$(sed 's/\//-/g' <<<"$BUILD_TAG")
if [ -z "$INSTALL_TYPE" ]; then
echo "-----------------------------------------------------"
@@ -702,8 +702,9 @@ stop_services(){
upgrade() {
print_logo
- set_buildinfo
stop_services
+ unset IMAGE_TAG
+ IMAGE_TAG=$UI_IMAGE_TAG
echo "-----------------------------------------------------"
echo "Provide Details for pro installation:"
echo " 1. Log into https://app.netmaker.io"
@@ -725,7 +726,8 @@ upgrade() {
downgrade () {
print_logo
- set_buildinfo
+ unset IMAGE_TAG
+ IMAGE_TAG=$UI_IMAGE_TAG
stop_services
save_config
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
From f5357228884ffd22fbb9c8a144e2bef63361c3e1 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 17:25:55 +0530
Subject: [PATCH 38/46] avoid pull new config on upgrade and downgrade
---
scripts/nm-quick.sh | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 748acb33c..6d56193ec 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -11,7 +11,9 @@ if [ $(id -u) -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
-
+# increase the timeouts
+export DOCKER_CLIENT_TIMEOUT=120
+export COMPOSE_HTTP_TIMEOUT=120
unset INSTALL_TYPE
unset BUILD_TAG
unset IMAGE_TAG
@@ -587,9 +589,7 @@ install_netmaker() {
echo "Starting containers..."
- # increase the timeouts
- export DOCKER_CLIENT_TIMEOUT=120
- export COMPOSE_HTTP_TIMEOUT=120
+
# start docker and rebuild containers / networks
cd "${SCRIPT_DIR}"
@@ -721,7 +721,11 @@ upgrade() {
read -p "Tenant ID: " TENANT_ID
done
save_config
- install_netmaker
+ # start docker and rebuild containers / networks
+ cd "${SCRIPT_DIR}"
+ docker-compose up -d --force-recreate
+ cd -
+ wait_seconds 2
}
downgrade () {
@@ -733,7 +737,11 @@ downgrade () {
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
fi
- install_netmaker
+ # start docker and rebuild containers / networks
+ cd "${SCRIPT_DIR}"
+ docker-compose up -d --force-recreate
+ cd -
+ wait_seconds 2
}
From 4a0ec2621753e57e10f6766a10bde4eca1a02925 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 17:51:15 +0530
Subject: [PATCH 39/46] get override files on upgrade
---
scripts/nm-quick.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 6d56193ec..c81e44dcc 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -702,7 +702,6 @@ stop_services(){
upgrade() {
print_logo
- stop_services
unset IMAGE_TAG
IMAGE_TAG=$UI_IMAGE_TAG
echo "-----------------------------------------------------"
@@ -721,6 +720,11 @@ upgrade() {
read -p "Tenant ID: " TENANT_ID
done
save_config
+
+ local COMPOSE_OVERRIDE_URL="$BASE_URL/compose/docker-compose.pro.yml"
+ wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
+ local CADDY_URL="$BASE_URL/docker/Caddyfile-pro"
+ wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
# start docker and rebuild containers / networks
cd "${SCRIPT_DIR}"
docker-compose up -d --force-recreate
@@ -732,7 +736,6 @@ downgrade () {
print_logo
unset IMAGE_TAG
IMAGE_TAG=$UI_IMAGE_TAG
- stop_services
save_config
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
From 21647978966fad3cb1ced46f5c0a295c216baa23 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 18:02:26 +0530
Subject: [PATCH 40/46] copy build tag
---
scripts/nm-quick.sh | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index c81e44dcc..19d989c30 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -704,12 +704,13 @@ upgrade() {
print_logo
unset IMAGE_TAG
IMAGE_TAG=$UI_IMAGE_TAG
+ BUILD_TAG=$UI_IMAGE_TAG
+ unset BUILD_TAG
echo "-----------------------------------------------------"
echo "Provide Details for pro installation:"
echo " 1. Log into https://app.netmaker.io"
echo " 2. follow instructions to get a license at: https://docs.netmaker.io/ee/ee-setup.html"
echo " 3. Retrieve License and Tenant ID"
- echo " 4. note email address"
echo "-----------------------------------------------------"
unset LICENSE_KEY
while [ -z "$LICENSE_KEY" ]; do
@@ -720,7 +721,7 @@ upgrade() {
read -p "Tenant ID: " TENANT_ID
done
save_config
-
+ local BASE_URL="https://raw.githubusercontent.com/gravitl/netmaker/$BUILD_TAG"
local COMPOSE_OVERRIDE_URL="$BASE_URL/compose/docker-compose.pro.yml"
wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
local CADDY_URL="$BASE_URL/docker/Caddyfile-pro"
@@ -735,7 +736,9 @@ upgrade() {
downgrade () {
print_logo
unset IMAGE_TAG
+ unset BUILD_TAG
IMAGE_TAG=$UI_IMAGE_TAG
+ BUILD_TAG=$UI_IMAGE_TAG
save_config
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
From 69dd212a0f95fc94c7d335231d9a7d1cf86cdff4 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 18:08:10 +0530
Subject: [PATCH 41/46] fix upgrade and downgrade
---
scripts/nm-quick.sh | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 19d989c30..62cdf87c4 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -721,16 +721,8 @@ upgrade() {
read -p "Tenant ID: " TENANT_ID
done
save_config
- local BASE_URL="https://raw.githubusercontent.com/gravitl/netmaker/$BUILD_TAG"
- local COMPOSE_OVERRIDE_URL="$BASE_URL/compose/docker-compose.pro.yml"
- wget -qO "$SCRIPT_DIR"/docker-compose.override.yml $COMPOSE_OVERRIDE_URL
- local CADDY_URL="$BASE_URL/docker/Caddyfile-pro"
- wget -qO "$SCRIPT_DIR"/Caddyfile "$CADDY_URL"
# start docker and rebuild containers / networks
- cd "${SCRIPT_DIR}"
- docker-compose up -d --force-recreate
- cd -
- wait_seconds 2
+ install_netmaker
}
downgrade () {
@@ -744,10 +736,7 @@ downgrade () {
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
fi
# start docker and rebuild containers / networks
- cd "${SCRIPT_DIR}"
- docker-compose up -d --force-recreate
- cd -
- wait_seconds 2
+ install_netmaker
}
From dc6ffe10d39df38a6fe407b1758b844624a01750 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 18:14:40 +0530
Subject: [PATCH 42/46] fix upgrade and downgrade
---
scripts/nm-quick.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 62cdf87c4..3d3f72482 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -703,9 +703,9 @@ stop_services(){
upgrade() {
print_logo
unset IMAGE_TAG
+ unset BUILD_TAG
IMAGE_TAG=$UI_IMAGE_TAG
BUILD_TAG=$UI_IMAGE_TAG
- unset BUILD_TAG
echo "-----------------------------------------------------"
echo "Provide Details for pro installation:"
echo " 1. Log into https://app.netmaker.io"
From 02985329206b878e94b899d80e792dc1a97f4afa Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 18:18:46 +0530
Subject: [PATCH 43/46] fix upgrade and downgrade
---
scripts/nm-quick.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 3d3f72482..6c758e058 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -736,6 +736,7 @@ downgrade () {
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
fi
# start docker and rebuild containers / networks
+ stop_services
install_netmaker
}
From 330c230ed738232d2e1c0920e99ae918c01b6f85 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 18:28:25 +0530
Subject: [PATCH 44/46] fix upgrade and downgrade
---
scripts/nm-quick.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/nm-quick.sh b/scripts/nm-quick.sh
index 6c758e058..6e44ddcfe 100755
--- a/scripts/nm-quick.sh
+++ b/scripts/nm-quick.sh
@@ -722,6 +722,7 @@ upgrade() {
done
save_config
# start docker and rebuild containers / networks
+ stop_services
install_netmaker
}
From 5f203834f13c59db0f3ff0cffe9dce1722cb9d17 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 18:32:09 +0530
Subject: [PATCH 45/46] replace readthedocs url
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 5213f9b8b..4267b31af 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,7 @@ If you're just looking to use Netmaker, you can create an account for free at [n
# Self-Hosted Quick Start
-These are the instructions for deploying a Netmaker server on your own cloud VM as quickly as possible. For more detailed instructions, visit the [Install Docs](https://netmaker.readthedocs.io/en/master/install.html).
+These are the instructions for deploying a Netmaker server on your own cloud VM as quickly as possible. For more detailed instructions, visit the [Install Docs](https://docs.netmaker.io/install.html).
1. Get a cloud VM with Ubuntu 22.04 and a public IP.
2. Open ports 443, 80, 3479, 8089 and 51821-51830/udp on the VM firewall and in cloud security settings.
@@ -68,7 +68,7 @@ This script gives you the option to deploy the Community or Enterprise version o
-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://www.netmaker.io/blog) for different use cases, including Kubernetes.
+After installing Netmaker, check out the [Walkthrough](https://itnext.io/getting-started-with-netmaker-a-wireguard-virtual-networking-platform-3d563fbd87f0) and [Getting Started](https://docs.netmaker.io/getting-started.html) guides to learn more about configuring networks. Or, check out some of our other [Tutorials](https://www.netmaker.io/blog) for different use cases, including Kubernetes.
# Get Support
From 7a36b939e48b971ca2c8b8a86c71226f86d78c38 Mon Sep 17 00:00:00 2001
From: abhishek9686
Date: Wed, 24 Jan 2024 19:09:33 +0530
Subject: [PATCH 46/46] change trial period to 14 days
---
pro/trial.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pro/trial.go b/pro/trial.go
index 9b4025753..149120900 100644
--- a/pro/trial.go
+++ b/pro/trial.go
@@ -70,7 +70,7 @@ func initTrial() error {
}
trialDates := TrialDates{
TrialStartedAt: time.Now(),
- TrialEndsAt: time.Now().Add(time.Hour * 24 * 30),
+ TrialEndsAt: time.Now().Add(time.Hour * 24 * 14),
}
t := TrialInfo{
PrivKey: tPriv,