Compare commits
2 Commits
0ed976a06e
...
cd0faaefe5
Author | SHA1 | Date | |
---|---|---|---|
cd0faaefe5 | |||
4b9bc59810 |
27
utils.go
27
utils.go
@ -419,18 +419,29 @@ func GetInitSystem() string {
|
|||||||
return strings.TrimSpace(string(out))
|
return strings.TrimSpace(string(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
link, err := os.Readlink("/sbin/init")
|
process, err := ps.FindProcess(1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "Unknown"
|
return ""
|
||||||
}
|
}
|
||||||
if path.Base(link) == "systemd" {
|
|
||||||
return "Systemd " + runCommand("systemctl --version | head -1 | awk '{print $2}'")
|
// Special cases
|
||||||
} else if path.Base(link) == "openrc-init" {
|
// OpenRC check
|
||||||
|
if _, err := os.Stat("/usr/sbin/openrc"); err == nil {
|
||||||
return "OpenRC " + runCommand("openrc --version | awk '{print $3}'")
|
return "OpenRC " + runCommand("openrc --version | awk '{print $3}'")
|
||||||
} else if path.Base(link) == "runit-init" {
|
}
|
||||||
|
|
||||||
|
// Default PID 1 process name checking
|
||||||
|
switch process.Executable() {
|
||||||
|
case "systemd":
|
||||||
|
return "Systemd " + runCommand("systemctl --version | head -n1 | awk '{print $2}'")
|
||||||
|
case "runit":
|
||||||
return "Runit"
|
return "Runit"
|
||||||
} else {
|
case "dinit":
|
||||||
return "Unknown"
|
return "Dinit " + runCommand("dinit --version | head -n1 | awk '{print substr($3, 1, length($3)-1)}'")
|
||||||
|
case "enit":
|
||||||
|
return "Enit " + runCommand("enit --version | awk '{print $3}'")
|
||||||
|
default:
|
||||||
|
return process.Executable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user