31 lines
589 B
Go
31 lines
589 B
Go
package update
|
|
|
|
import (
|
|
domain "RenewCMS/internal/domain/update"
|
|
"os"
|
|
"runtime"
|
|
)
|
|
|
|
const systemdRuntimeDirectory = "/run/systemd/system"
|
|
|
|
type SystemMachineProbe struct{}
|
|
|
|
var _ domain.MachineProbe = &SystemMachineProbe{}
|
|
|
|
func NewSystemMachineProbe() *SystemMachineProbe {
|
|
return &SystemMachineProbe{}
|
|
}
|
|
|
|
func (p *SystemMachineProbe) OS() string {
|
|
return runtime.GOOS
|
|
}
|
|
|
|
func (p *SystemMachineProbe) SystemdRunning() bool {
|
|
info, err := os.Stat(systemdRuntimeDirectory)
|
|
return err == nil && info.IsDir()
|
|
}
|
|
|
|
func (p *SystemMachineProbe) IsRoot() bool {
|
|
return os.Geteuid() == 0
|
|
}
|