base-files: fix /tmp/TZ when zoneinfo not installed
authorPaul Spooren <mail@aparcar.org>
Thu, 24 Jun 2021 17:42:53 +0000 (07:42 -1000)
committerPaul Spooren <mail@aparcar.org>
Sat, 26 Jun 2021 00:56:48 +0000 (14:56 -1000)
The zoneinfo packages are not installed per default so neither
/tmp/localtime nor /tmp/TZ is generated.

This patch mostly reverts the previous fix and instead incooperates a
solution suggested by Jo.

Fixes "base-files: fix zoneinfo support " 8af62ed

Signed-off-by: Paul Spooren <mail@aparcar.org>
(cherry picked from commit 56bdb6bb9781f8a0bbec5fc3075b9d2b8d12f9a8)

package/base-files/files/etc/init.d/system

index 219b29812d7b09f6322ad3ef9689f41958971865..62cf2db3dd12f3c2bc5ae3e95b1700d710edb611 100755 (executable)
@@ -21,13 +21,10 @@ system_config() {
 
        echo "$hostname" > /proc/sys/kernel/hostname
        [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
-       rm -f /tmp/TZ
-       if [ -n "$zonename" ]; then
-               local zname=$(echo "$zonename" | tr ' ' _)
-               [ -f "/usr/share/zoneinfo/$zname" ] && ln -sf "/usr/share/zoneinfo/$zname" /tmp/localtime
-       else
-               echo "$timezone" > /tmp/TZ
-       fi
+       echo "$timezone" > /tmp/TZ
+       [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/${zonename// /_}" ] \
+               && ln -sf "/usr/share/zoneinfo/${zonename// /_}" /tmp/localtime \
+               && rm -f /tmp/TZ
 
        # apply timezone to kernel
        date -k