mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
fix #17244: use /etc/timezone where timedatectl
is missing on Linux
Signed-off-by: nabbisen <nabbisen@scqr.net>
This commit is contained in:
@ -1,12 +1,17 @@
|
|||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getLocalTimeZone() (string, error) {
|
func getLocalTimeZone() (string, error) {
|
||||||
output, err := exec.Command("timedatectl", "show", "--property=Timezone").Output()
|
output, err := exec.Command("timedatectl", "show", "--property=Timezone").Output()
|
||||||
|
if errors.Is(err, exec.ErrNotFound) {
|
||||||
|
output, err = os.ReadFile("/etc/timezone")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user