mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-06 09:22:42 +08:00
added backups to help with reboot
This commit is contained in:
@@ -151,10 +151,11 @@ func CheckConfig(cliconf config.ClientConfig) error {
|
||||
// Pull - pulls the latest config from the server, if manual it will overwrite
|
||||
func Pull(network string, manual bool) (*models.Node, error) {
|
||||
cfg, err := config.ReadConfig(network)
|
||||
node := cfg.Node
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
node := cfg.Node
|
||||
servercfg := cfg.Server
|
||||
|
||||
if cfg.Node.IPForwarding == "yes" && !ncutils.IsWindows() {
|
||||
@@ -243,6 +244,10 @@ func Pull(network string, manual bool) (*models.Node, error) {
|
||||
if ncutils.IsLinux() {
|
||||
setDNS(&resNode, servercfg, &cfg.Node)
|
||||
}
|
||||
var bkupErr = config.SaveBackup(network)
|
||||
if bkupErr != nil {
|
||||
ncutils.Log("unable to update backup file")
|
||||
}
|
||||
|
||||
return &resNode, err
|
||||
}
|
||||
|
@@ -5,6 +5,9 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
nodepb "github.com/gravitl/netmaker/grpc"
|
||||
"github.com/gravitl/netmaker/models"
|
||||
"github.com/gravitl/netmaker/netclient/auth"
|
||||
@@ -16,8 +19,6 @@ import (
|
||||
"github.com/gravitl/netmaker/netclient/wireguard"
|
||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||
"google.golang.org/grpc"
|
||||
"log"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
// JoinNetwork - helps a client join a network
|
||||
@@ -185,6 +186,10 @@ func JoinNetwork(cfg config.ClientConfig, privateKey string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// attempt to make backup
|
||||
if err = config.SaveBackup(node.Network); err != nil {
|
||||
ncutils.Log("failed to make backup, node will not auto restore if config is corrupted")
|
||||
}
|
||||
}
|
||||
|
||||
ncutils.Log("retrieving peers")
|
||||
|
Reference in New Issue
Block a user