瀏覽代碼

base: fix setting timezone

Saúl Ibarra Corretgé 5 年之前
父節點
當前提交
8e7ea34c50
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      base/rootfs/etc/cont-init.d/01-set-timezone

+ 8 - 4
base/rootfs/etc/cont-init.d/01-set-timezone

@@ -1,6 +1,10 @@
-#!/usr/bin/with-contenv sh
+#!/usr/bin/with-contenv bash
 
-if [ $TZ ]; then
-    [ -f /usr/share/zoneinfo/$TZ ] && cp /usr/share/zoneinfo/$TZ /etc/localtime || echo "WARNING: $TZ is not a valid time zone."
-    [ -f /usr/share/zoneinfo/$TZ ] && echo "$TZ" >  /etc/timezone
+if [[ ! -z "$TZ" ]]; then
+    if [[ -f /usr/share/zoneinfo/$TZ ]]; then
+         ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
+         echo "$TZ" >  /etc/timezone
+    else
+        echo "WARNING: $TZ is not a valid time zone."
+    fi
 fi