mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-08 14:38:30 -04:00
core: remove unused functions after migration
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"slices"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -28,62 +26,3 @@ func isArchPackageInstalled(packageName string) bool {
|
|||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
return err == nil
|
return err == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type systemdServiceState struct {
|
|
||||||
Name string
|
|
||||||
EnabledState string
|
|
||||||
NeedsDisable bool
|
|
||||||
Exists bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// checkSystemdServiceEnabled returns (state, should_disable, error) for a systemd service
|
|
||||||
func checkSystemdServiceEnabled(serviceName string) (string, bool, error) {
|
|
||||||
cmd := exec.Command("systemctl", "is-enabled", serviceName)
|
|
||||||
output, err := cmd.Output()
|
|
||||||
|
|
||||||
stateStr := strings.TrimSpace(string(output))
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
knownStates := []string{"disabled", "masked", "masked-runtime", "not-found", "enabled", "enabled-runtime", "static", "indirect", "alias"}
|
|
||||||
isKnownState := slices.Contains(knownStates, stateStr)
|
|
||||||
|
|
||||||
if !isKnownState {
|
|
||||||
return stateStr, false, fmt.Errorf("systemctl is-enabled failed: %w (output: %s)", err, stateStr)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldDisable := false
|
|
||||||
switch stateStr {
|
|
||||||
case "enabled", "enabled-runtime", "static", "indirect", "alias":
|
|
||||||
shouldDisable = true
|
|
||||||
case "disabled", "masked", "masked-runtime", "not-found":
|
|
||||||
shouldDisable = false
|
|
||||||
default:
|
|
||||||
shouldDisable = true
|
|
||||||
}
|
|
||||||
|
|
||||||
return stateStr, shouldDisable, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSystemdServiceState(serviceName string) (*systemdServiceState, error) {
|
|
||||||
state := &systemdServiceState{
|
|
||||||
Name: serviceName,
|
|
||||||
Exists: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
enabledState, needsDisable, err := checkSystemdServiceEnabled(serviceName)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to check enabled state: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
state.EnabledState = enabledState
|
|
||||||
state.NeedsDisable = needsDisable
|
|
||||||
|
|
||||||
if enabledState == "not-found" {
|
|
||||||
state.Exists = false
|
|
||||||
return state, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
state.Exists = true
|
|
||||||
return state, nil
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user