mirror of
https://github.com/taigrr/systemctl.git
synced 2026-04-02 02:28:50 -07:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21fce7918e | |||
| 54f4f7a235 |
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
package systemctl
|
package systemctl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
12
helpers.go
12
helpers.go
@@ -1,8 +1,11 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
package systemctl
|
package systemctl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -112,6 +115,15 @@ func GetMaskedUnits(ctx context.Context, opts Options) ([]string, error) {
|
|||||||
return units, nil
|
return units, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if systemd is the current init system
|
||||||
|
func IsSystemd() (bool, error) {
|
||||||
|
b, err := os.ReadFile("/proc/1/comm")
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(b)) == "systemd", nil
|
||||||
|
}
|
||||||
|
|
||||||
// check if a service is masked
|
// check if a service is masked
|
||||||
func IsMasked(ctx context.Context, unit string, opts Options) (bool, error) {
|
func IsMasked(ctx context.Context, unit string, opts Options) (bool, error) {
|
||||||
units, err := GetMaskedUnits(ctx, opts)
|
units, err := GetMaskedUnits(ctx, opts)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
package systemctl
|
package systemctl
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
package systemctl
|
package systemctl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user