mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-11 19:51:29 +08:00
updated logic for join/leave network
This commit is contained in:
@@ -139,6 +139,7 @@ func Uninstall() error {
|
||||
}
|
||||
}
|
||||
err = nil
|
||||
|
||||
// clean up OS specific stuff
|
||||
if ncutils.IsWindows() {
|
||||
daemon.CleanupWindows()
|
||||
@@ -213,31 +214,9 @@ func LeaveNetwork(network string) error {
|
||||
logger.Log(1, "removed ", node.Network, " network locally")
|
||||
}
|
||||
|
||||
currentNets, err := ncutils.GetSystemNetworks()
|
||||
if err != nil || len(currentNets) <= 1 {
|
||||
daemon.Stop() // stop system daemon if last network
|
||||
return RemoveLocalInstance(cfg, network)
|
||||
}
|
||||
return daemon.Restart()
|
||||
}
|
||||
|
||||
// RemoveLocalInstance - remove all netclient files locally for a network
|
||||
func RemoveLocalInstance(cfg *config.ClientConfig, networkName string) error {
|
||||
|
||||
if cfg.Daemon != "off" {
|
||||
if ncutils.IsWindows() {
|
||||
// TODO: Remove job?
|
||||
} else if ncutils.IsMac() {
|
||||
//TODO: Delete mac daemon
|
||||
} else if ncutils.IsFreeBSD() {
|
||||
daemon.RemoveFreebsdDaemon()
|
||||
} else {
|
||||
daemon.RemoveSystemDServices()
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteInterface - delete an interface of a network
|
||||
func DeleteInterface(ifacename string, postdown string) error {
|
||||
return wireguard.RemoveConf(ifacename, true)
|
||||
|
Reference in New Issue
Block a user