diff --git a/netclient/daemon/macos.go b/netclient/daemon/macos.go
index 4fe21ff1..cf1cfddb 100644
--- a/netclient/daemon/macos.go
+++ b/netclient/daemon/macos.go
@@ -19,8 +19,8 @@ func SetupMacDaemon(interval string) error {
}
binarypath := dir + "/netclient"
- if !ncutils.FileExists("/etc/netclient/netclient") {
- err = ncutils.Copy(binarypath, "/etc/netclient/netclient")
+ if !ncutils.FileExists("/sbin/netclient") {
+ err = ncutils.Copy(binarypath, "/sbin/netclient")
if err != nil {
log.Println(err)
return err
@@ -49,6 +49,7 @@ func CleanupMac() {
}
os.RemoveAll(ncutils.GetNetclientPath())
+ os.Remove("/sbin/netclient")
}
func CreateMacService(servicename string, interval string) error {
@@ -76,10 +77,8 @@ func MacDaemonString(interval string) string {
Labelcom.gravitl.netclient
ProgramArguments
- /etc/netclient/netclient
- checkin
- -n
- all
+ /sbin/netclient
+ daemon
StandardOutPath/etc/netclient/com.gravitl.netclient.log
StandardErrorPath/etc/netclient/com.gravitl.netclient.log
diff --git a/netclient/daemon/systemd.go b/netclient/daemon/systemd.go
index 015f4626..6b1ecc4a 100644
--- a/netclient/daemon/systemd.go
+++ b/netclient/daemon/systemd.go
@@ -29,12 +29,10 @@ func SetupSystemDDaemon(interval string) error {
log.Println("couldnt find or create /etc/netclient")
return err
}
-
- if !ncutils.FileExists("/usr/local/bin/netclient") {
- os.Symlink("/etc/netclient/netclient", "/usr/local/bin/netclient")
- }
- if !ncutils.FileExists("/etc/netclient/netclient") {
- err = ncutils.Copy(binarypath, "/etc/netclient/netclient")
+ //install binary
+ //should check if the existing binary is the corect version -- for now only copy if file doesn't exist
+ if !ncutils.FileExists("/usr/sbin/netclient") {
+ err = ncutils.Copy(binarypath, "/usr/sbin/netclient")
if err != nil {
log.Println(err)
return err
@@ -42,36 +40,17 @@ func SetupSystemDDaemon(interval string) error {
}
systemservice := `[Unit]
-Description=Network Check
-Wants=netclient.timer
+Description=Netclient message queue
[Service]
Type=simple
-ExecStart=/etc/netclient/netclient checkin -n all
+ExecStart=/usr/sbin/netclient daemon
[Install]
WantedBy=multi-user.target
-`
-
- systemtimer := `[Unit]
-Description=Calls the Netmaker Mesh Client Service
-Requires=netclient.service
-
-[Timer]
-Unit=netclient.service
-
-`
- systemtimer = systemtimer + "OnCalendar=*:*:0/" + interval
-
- systemtimer = systemtimer +
- `
-
-[Install]
-WantedBy=timers.target
`
servicebytes := []byte(systemservice)
- timerbytes := []byte(systemtimer)
if !ncutils.FileExists("/etc/systemd/system/netclient.service") {
err = os.WriteFile("/etc/systemd/system/netclient.service", servicebytes, 0644)
@@ -80,25 +59,17 @@ WantedBy=timers.target
return err
}
}
-
- if !ncutils.FileExists("/etc/systemd/system/netclient.timer") {
- err = os.WriteFile("/etc/systemd/system/netclient.timer", timerbytes, 0644)
- if err != nil {
- log.Println(err)
- return err
- }
- }
-
_, _ = ncutils.RunCmd("systemctl enable netclient.service", true)
_, _ = ncutils.RunCmd("systemctl daemon-reload", true)
- _, _ = ncutils.RunCmd("systemctl enable netclient.timer", true)
- _, _ = ncutils.RunCmd("systemctl start netclient.timer", true)
+ _, _ = ncutils.RunCmd("systemctl start netclient.server", true)
return nil
}
func CleanupLinux() {
- err := os.RemoveAll(ncutils.GetNetclientPath())
- if err != nil {
+ if err := os.RemoveAll(ncutils.GetNetclientPath()); err != nil {
+ ncutils.PrintLog("Removing netclient configs: "+err.Error(), 1)
+ }
+ if err := os.Remove("/usr/sbin/netclient"); err != nil {
ncutils.PrintLog("Removing netclient binary: "+err.Error(), 1)
}
}