Harald Hoyer f97365
From a0eadcdc644d571da58f718d73dacb4f68bef56b Mon Sep 17 00:00:00 2001
Harald Hoyer f97365
From: Hannes Reinecke <hare@suse.de>
Harald Hoyer f97365
Date: Thu, 5 Dec 2013 09:29:28 +0100
Harald Hoyer f97365
Subject: [PATCH] 00warpclock: Set correct timezone
Harald Hoyer f97365
Harald Hoyer f97365
Add module for setting correct timezone.
Harald Hoyer f97365
Harald Hoyer f97365
References: bnc#830060
Harald Hoyer f97365
Harald Hoyer f97365
For now, this module will not be included automatically due to different
Harald Hoyer f97365
expectations (see e.g.  https://bugzilla.redhat.com/show_bug.cgi?id=981617)
Harald Hoyer f97365
Harald Hoyer f97365
Signed-off-by: Hannes Reinecke <hare@suse.de>
Harald Hoyer f97365
Signed-off-by: Daniel Molkentin <daniel.molkentin@suse.com>
Harald Hoyer f97365
---
Harald Hoyer f97365
 modules.d/00warpclock/module-setup.sh | 29 +++++++++++++++++++++++++++++
Harald Hoyer f97365
 modules.d/00warpclock/warpclock.sh    |  9 +++++++++
Harald Hoyer f97365
 2 files changed, 38 insertions(+)
Harald Hoyer f97365
Harald Hoyer f97365
diff --git a/modules.d/00warpclock/module-setup.sh b/modules.d/00warpclock/module-setup.sh
Harald Hoyer f97365
new file mode 100644
Harald Hoyer f97365
index 00000000..ea1348ed
Harald Hoyer f97365
--- /dev/null
Harald Hoyer f97365
+++ b/modules.d/00warpclock/module-setup.sh
Harald Hoyer f97365
@@ -0,0 +1,29 @@
Harald Hoyer f97365
+#!/bin/bash
Harald Hoyer f97365
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
Harald Hoyer f97365
+# ex: ts=8 sw=4 sts=4 et filetype=sh
Harald Hoyer f97365
+
Harald Hoyer f97365
+# called by dracut
Harald Hoyer f97365
+check() {
Harald Hoyer f97365
+    # hwclock does not exist on S390(x), bail out silently then
Harald Hoyer f97365
+    local _arch=$(uname -m)
Harald Hoyer f97365
+    [ "$_arch" = "s390" -o "$_arch" = "s390x" ] && return 1
Harald Hoyer f97365
+
Harald Hoyer f97365
+    [ -e /etc/localtime -a -e /etc/adjtime ] || return 1
Harald Hoyer f97365
+    require_binaries /sbin/hwclock || return 1
Harald Hoyer f97365
+
Harald Hoyer f97365
+    return 255
Harald Hoyer f97365
+}
Harald Hoyer f97365
+
Harald Hoyer f97365
+# called by dracut
Harald Hoyer f97365
+depends() {
Harald Hoyer f97365
+    return 0
Harald Hoyer f97365
+}
Harald Hoyer f97365
+
Harald Hoyer f97365
+# called by dracut
Harald Hoyer f97365
+install() {
Harald Hoyer f97365
+    inst /usr/share/zoneinfo/UTC
Harald Hoyer f97365
+    inst /etc/localtime
Harald Hoyer f97365
+    inst /etc/adjtime
Harald Hoyer f97365
+    inst_hook pre-trigger 00 "$moddir/warpclock.sh"
Harald Hoyer f97365
+    inst /sbin/hwclock
Harald Hoyer f97365
+}
Harald Hoyer f97365
diff --git a/modules.d/00warpclock/warpclock.sh b/modules.d/00warpclock/warpclock.sh
Harald Hoyer f97365
new file mode 100644
Harald Hoyer f97365
index 00000000..f64818c6
Harald Hoyer f97365
--- /dev/null
Harald Hoyer f97365
+++ b/modules.d/00warpclock/warpclock.sh
Harald Hoyer f97365
@@ -0,0 +1,9 @@
Harald Hoyer f97365
+#!/bin/sh
Harald Hoyer f97365
+
Harald Hoyer f97365
+if test -e /etc/adjtime ; then
Harald Hoyer f97365
+    while read line ; do
Harald Hoyer f97365
+	if test "$line" = LOCAL ; then
Harald Hoyer f97365
+	    hwclock --systz
Harald Hoyer f97365
+	fi
Harald Hoyer f97365
+    done < /etc/adjtime
Harald Hoyer f97365
+fi
Harald Hoyer f97365