Pull request: home: do not add linux deps on non-linux systems

Updates #3609.

Squashed commit of the following:

commit 8f890d2806938db1aee05833d1b2ae8ff1bc9fd4
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Sep 17 16:10:09 2021 +0300

    home: do not add linux deps on non-linux systems
This commit is contained in:
Ainar Garipov 2021-09-17 16:24:44 +03:00
parent bf1263628a
commit 6ac28ee8ee
1 changed files with 10 additions and 7 deletions

View File

@ -17,8 +17,8 @@ import (
"github.com/kardianos/service" "github.com/kardianos/service"
) )
// TODO(a.garipov): Move shell templates into actual files. Either during the // TODO(a.garipov): Consider moving the shell templates into actual files and
// v0.106.0 cycle using packr or during the following cycle using go:embed. // using go:embed instead of using large string constants.
const ( const (
launchdStdoutPath = "/var/log/AdGuardHome.stdout.log" launchdStdoutPath = "/var/log/AdGuardHome.stdout.log"
@ -313,18 +313,21 @@ func configureService(c *service.Config) {
// POSIX / systemd // POSIX / systemd
// Redirect stderr and stdout to files. Make sure we always restart. // Redirect stderr and stdout to files. Make sure we always restart.
// Start only once network is up on Linux/systemd.
c.Option["LogOutput"] = true c.Option["LogOutput"] = true
c.Option["Restart"] = "always" c.Option["Restart"] = "always"
// Start only once network is up on Linux/systemd.
if runtime.GOOS == "linux" {
c.Dependencies = []string{ c.Dependencies = []string{
"After=syslog.target network-online.target", "After=syslog.target network-online.target",
} }
}
// Use modified service file templates. // Use the modified service file templates.
c.Option["SystemdScript"] = systemdScript c.Option["SystemdScript"] = systemdScript
c.Option["SysvScript"] = sysvScript c.Option["SysvScript"] = sysvScript
// On OpenWrt we're using a different type of sysvScript. // Use different scripts on OpenWrt and FreeBSD.
if aghos.IsOpenWrt() { if aghos.IsOpenWrt() {
c.Option["SysvScript"] = openWrtScript c.Option["SysvScript"] = openWrtScript
} else if runtime.GOOS == "freebsd" { } else if runtime.GOOS == "freebsd" {