From a86495ea6fdd56519afc65586c0f7f9c0f4f5ab2 Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Tue, 14 Dec 2021 14:16:09 -0600 Subject: Set machine timezone Added an option to podman machine init to declare the timezone of the resulting machine. the default is to use the value of the host name or else a given timezone name like America/Chicago. Fixes: #11895 Signed-off-by: Brent Baude [NO NEW TESTS NEEDED] Signed-off-by: Brent Baude --- pkg/machine/ignition_linux.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pkg/machine/ignition_linux.go (limited to 'pkg/machine/ignition_linux.go') diff --git a/pkg/machine/ignition_linux.go b/pkg/machine/ignition_linux.go new file mode 100644 index 000000000..6db5a8e7a --- /dev/null +++ b/pkg/machine/ignition_linux.go @@ -0,0 +1,15 @@ +package machine + +import ( + "os/exec" + "strings" +) + +func getLocalTimeZone() (string, error) { + output, err := exec.Command("timedatectl", "show", "--property=Timezone").Output() + if err != nil { + return "", err + } + // Remove prepended field and the newline + return strings.TrimPrefix(strings.TrimSuffix(string(output), "\n"), "Timezone="), nil +} -- cgit v1.2.3-54-g00ecf