|
@@ -29,12 +29,10 @@ func SetupSystemDDaemon(interval string) error {
|
|
log.Println("couldnt find or create /etc/netclient")
|
|
log.Println("couldnt find or create /etc/netclient")
|
|
return err
|
|
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 {
|
|
if err != nil {
|
|
log.Println(err)
|
|
log.Println(err)
|
|
return err
|
|
return err
|
|
@@ -42,36 +40,17 @@ func SetupSystemDDaemon(interval string) error {
|
|
}
|
|
}
|
|
|
|
|
|
systemservice := `[Unit]
|
|
systemservice := `[Unit]
|
|
-Description=Network Check
|
|
|
|
-Wants=netclient.timer
|
|
|
|
|
|
+Description=Netclient message queue
|
|
|
|
|
|
[Service]
|
|
[Service]
|
|
Type=simple
|
|
Type=simple
|
|
-ExecStart=/etc/netclient/netclient checkin -n all
|
|
|
|
|
|
+ExecStart=/usr/sbin/netclient daemon
|
|
|
|
|
|
[Install]
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
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)
|
|
servicebytes := []byte(systemservice)
|
|
- timerbytes := []byte(systemtimer)
|
|
|
|
|
|
|
|
if !ncutils.FileExists("/etc/systemd/system/netclient.service") {
|
|
if !ncutils.FileExists("/etc/systemd/system/netclient.service") {
|
|
err = os.WriteFile("/etc/systemd/system/netclient.service", servicebytes, 0644)
|
|
err = os.WriteFile("/etc/systemd/system/netclient.service", servicebytes, 0644)
|
|
@@ -80,25 +59,17 @@ WantedBy=timers.target
|
|
return err
|
|
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 enable netclient.service", true)
|
|
_, _ = ncutils.RunCmd("systemctl daemon-reload", 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
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
func CleanupLinux() {
|
|
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)
|
|
ncutils.PrintLog("Removing netclient binary: "+err.Error(), 1)
|
|
}
|
|
}
|
|
}
|
|
}
|