From fe3bfc6adec7d7f1ece9b98b818a3894f85568a9 Mon Sep 17 00:00:00 2001 From: Evan Gates Date: Mon, 20 Sep 2021 11:05:11 -0700 Subject: [PATCH] core-services/03-console-setup.sh: respect localtime hwclock When TIMEZONE was unset or empty, the resulting empty TZ variable in the environment caused hwclock to set the timezone to UTC and ignore the value of /etc/localtime. Only set TZ when TIMEZONE is non-empty. Thanks to quinq in #voidlinux for finding the root cause of the bug. hwclock(8): The system timezone is configured by the TZ environment variable or the /etc/localtime file, as tzset(3) would interpret them. tzset(3): If the TZ variable does appear in the environment, but its value is empty, or its value cannot be interpreted using any of the formats specified below, then Coordinated Universal Time (UTC) is used. Fixes: 6394a10 (core-services/02-console-setup.sh: setup HARDWARECLOCK if set.) --- core-services/03-console-setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core-services/03-console-setup.sh b/core-services/03-console-setup.sh index 5c8d4685..c27a7f96 100644 --- a/core-services/03-console-setup.sh +++ b/core-services/03-console-setup.sh @@ -21,6 +21,6 @@ fi if [ -n "$HARDWARECLOCK" ]; then msg "Setting up RTC to '${HARDWARECLOCK}'..." - TZ=$TIMEZONE hwclock --systz \ + eval ${TIMEZONE:+TZ=$TIMEZONE} hwclock --systz \ ${HARDWARECLOCK:+--$(echo $HARDWARECLOCK |tr A-Z a-z) --noadjfile} || emergency_shell fi