Compare commits
No commits in common. "cd0faaefe5e5d479583c02f6416741ce01383100" and "0ed976a06e9fa6821952648767dc8738a4ccfdd0" have entirely different histories.
cd0faaefe5
...
0ed976a06e
27
utils.go
27
utils.go
@ -419,29 +419,18 @@ func GetInitSystem() string {
|
|||||||
return strings.TrimSpace(string(out))
|
return strings.TrimSpace(string(out))
|
||||||
}
|
}
|
||||||
|
|
||||||
process, err := ps.FindProcess(1)
|
link, err := os.Readlink("/sbin/init")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return "Unknown"
|
||||||
}
|
}
|
||||||
|
if path.Base(link) == "systemd" {
|
||||||
// Special cases
|
return "Systemd " + runCommand("systemctl --version | head -1 | awk '{print $2}'")
|
||||||
// OpenRC check
|
} else if path.Base(link) == "openrc-init" {
|
||||||
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"
|
||||||
case "dinit":
|
} else {
|
||||||
return "Dinit " + runCommand("dinit --version | head -n1 | awk '{print substr($3, 1, length($3)-1)}'")
|
return "Unknown"
|
||||||
case "enit":
|
|
||||||
return "Enit " + runCommand("enit --version | awk '{print $3}'")
|
|
||||||
default:
|
|
||||||
return process.Executable()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user