Ophestra Umiker
4b7d616862
Exit cleanup state information is now stored in a dedicated struct and built up using methods of that struct. Signed-off-by: Ophestra Umiker <cat@ophivana.moe>
25 lines
376 B
Go
25 lines
376 B
Go
package util
|
|
|
|
import (
|
|
"errors"
|
|
"io/fs"
|
|
"os"
|
|
)
|
|
|
|
const (
|
|
systemdCheckPath = "/run/systemd/system"
|
|
)
|
|
|
|
// SdBooted implements https://www.freedesktop.org/software/systemd/man/sd_booted.html
|
|
func SdBooted() (bool, error) {
|
|
_, err := os.Stat(systemdCheckPath)
|
|
if err != nil {
|
|
if errors.Is(err, fs.ErrNotExist) {
|
|
err = nil
|
|
}
|
|
return false, err
|
|
}
|
|
|
|
return true, nil
|
|
}
|