mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 07:56:12 +00:00
Do not attempt to show init system if not found
This commit is contained in:
+7
-1
@@ -130,10 +130,16 @@ func initializeModuleMap() {
|
||||
|
||||
// Init system module
|
||||
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 {
|
||||
switch s {
|
||||
case "INIT":
|
||||
return GetInitSystem()
|
||||
return initSystem
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -138,6 +138,11 @@ func GetInitSystem() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Return if init system can't be found
|
||||
if process == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Special cases
|
||||
// OpenRC check
|
||||
if _, err := os.Stat("/usr/sbin/openrc"); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user