Do not attempt to show init system if not found

This commit is contained in:
2025-12-22 20:01:14 +02:00
parent cecce857e1
commit 7f7c7d646d
2 changed files with 12 additions and 1 deletions
+7 -1
View File
@@ -130,10 +130,16 @@ func initializeModuleMap() {
// Init system module // Init system module
initSystemModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "init_system", Format: "%3Init: %4$INIT"}, Execute: func(sm StormfetchModule) string { initSystemModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "init_system", Format: "%3Init: %4$INIT"}, Execute: func(sm StormfetchModule) string {
initSystem := GetInitSystem()
if initSystem == "" {
return ""
}
return os.Expand(sm.Format, func(s string) string { return os.Expand(sm.Format, func(s string) string {
switch s { switch s {
case "INIT": case "INIT":
return GetInitSystem() return initSystem
default: default:
return "" return ""
} }
+5
View File
@@ -138,6 +138,11 @@ func GetInitSystem() string {
return "" return ""
} }
// Return if init system can't be found
if process == nil {
return ""
}
// Special cases // Special cases
// OpenRC check // OpenRC check
if _, err := os.Stat("/usr/sbin/openrc"); err == nil { if _, err := os.Stat("/usr/sbin/openrc"); err == nil {