mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-15 23:46: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
|
// 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 ""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user