Skip to content

Commit e244dcb

Browse files
committed
ee license check
os.Exit(0) on license check failure docker-compose -- restart netmaker container on faiure vice always
1 parent 9390c06 commit e244dcb

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

compose/docker-compose-emqx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
netmaker:
55
container_name: netmaker
66
image: gravitl/netmaker:v0.18.6
7-
restart: always
7+
restart: on-failure
88
volumes:
99
- dnsconfig:/root/config/dnsconfig
1010
- sqldata:/root/data

compose/docker-compose.ee.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
netmaker:
55
container_name: netmaker
66
image: gravitl/netmaker:REPLACE_SERVER_IMAGE_TAG
7-
restart: always
7+
restart: on-failure
88
volumes:
99
- dnsconfig:/root/config/dnsconfig
1010
- sqldata:/root/data

compose/docker-compose.netclient.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
image: 'gravitl/netclient:v0.18.6'
77
hostname: netmaker-1
88
network_mode: host
9-
restart: always
9+
restart: on-failure
1010
environment:
1111
TOKEN: "TOKEN_VALUE"
1212
volumes:

compose/docker-compose.reference.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
netmaker: # The Primary Server for running Netmaker
55
container_name: netmaker
66
image: gravitl/netmaker:REPLACE_SERVER_IMAGE_TAG
7-
restart: always
7+
restart: on-failure
88
volumes: # Volume mounts necessary for sql, coredns, and mqtt
99
- dnsconfig:/root/config/dnsconfig
1010
- sqldata:/root/data

compose/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
netmaker:
55
container_name: netmaker
66
image: gravitl/netmaker:REPLACE_SERVER_IMAGE_TAG
7-
restart: always
7+
restart: on-failure
88
volumes:
99
- dnsconfig:/root/config/dnsconfig
1010
- sqldata:/root/data

ee/license.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ func ValidateLicense() error {
4444
netmakerAccountID := servercfg.GetNetmakerAccountID()
4545
logger.Log(0, "proceeding with Netmaker license validation...")
4646
if len(licenseKeyValue) == 0 || len(netmakerAccountID) == 0 {
47-
logger.FatalLog(errValidation.Error())
47+
logger.FatalLog0(errValidation.Error())
4848
}
4949

5050
apiPublicKey, err := getLicensePublicKey(licenseKeyValue)
5151
if err != nil {
52-
logger.FatalLog(errValidation.Error())
52+
logger.FatalLog0(errValidation.Error())
5353
}
5454

5555
tempPubKey, tempPrivKey, err := FetchApiServerKeys()
5656
if err != nil {
57-
logger.FatalLog(errValidation.Error())
57+
logger.FatalLog0(errValidation.Error())
5858
}
5959

6060
licenseSecret := LicenseSecret{
@@ -64,32 +64,32 @@ func ValidateLicense() error {
6464

6565
secretData, err := json.Marshal(&licenseSecret)
6666
if err != nil {
67-
logger.FatalLog(errValidation.Error())
67+
logger.FatalLog0(errValidation.Error())
6868
}
6969

7070
encryptedData, err := ncutils.BoxEncrypt(secretData, apiPublicKey, tempPrivKey)
7171
if err != nil {
72-
logger.FatalLog(errValidation.Error())
72+
logger.FatalLog0(errValidation.Error())
7373
}
7474

7575
validationResponse, err := validateLicenseKey(encryptedData, tempPubKey)
7676
if err != nil || len(validationResponse) == 0 {
77-
logger.FatalLog(errValidation.Error())
77+
logger.FatalLog0(errValidation.Error())
7878
}
7979

8080
var licenseResponse ValidatedLicense
8181
if err = json.Unmarshal(validationResponse, &licenseResponse); err != nil {
82-
logger.FatalLog(errValidation.Error())
82+
logger.FatalLog0(errValidation.Error())
8383
}
8484

8585
respData, err := ncutils.BoxDecrypt(base64decode(licenseResponse.EncryptedLicense), apiPublicKey, tempPrivKey)
8686
if err != nil {
87-
logger.FatalLog(errValidation.Error())
87+
logger.FatalLog0(errValidation.Error())
8888
}
8989

9090
license := LicenseKey{}
9191
if err = json.Unmarshal(respData, &license); err != nil {
92-
logger.FatalLog(errValidation.Error())
92+
logger.FatalLog0(errValidation.Error())
9393
}
9494

9595
Limits.Networks = math.MaxInt

logger/logger.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ func FatalLog(message ...string) {
138138
os.Exit(2)
139139
}
140140

141+
// FatalLog0 - exits os after logging
142+
func FatalLog0(message ...string) {
143+
fmt.Printf("[%s] Fatal: %s \n", program, MakeString(" ", message...))
144+
os.Exit(0)
145+
}
146+
141147
// == private ==
142148

143149
// resetLogs - reallocates logs map

0 commit comments

Comments
 (0)