[LEDE-DEV] [PATCH] base-files: sysfixtime: Allow system time in local timezones
Petr Štetiar
ynezz at true.cz
Tue Oct 18 14:11:43 PDT 2016
Currently we're forced to have system time in the UTC timezone as
hardware clock, mainly because kernel expects in rtc_hctosys(), that RTC
time is held in UTC timezone.
With this patch one can now have local system time for example in CEST
timezone and RTC time still in UTC with boolean config option `rtc_utc`.
Signed-off-by: Petr Štetiar <ynezz at true.cz>
---
package/base-files/files/etc/init.d/sysfixtime | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/package/base-files/files/etc/init.d/sysfixtime b/package/base-files/files/etc/init.d/sysfixtime
index 81d1c52..83e1397 100755
--- a/package/base-files/files/etc/init.d/sysfixtime
+++ b/package/base-files/files/etc/init.d/sysfixtime
@@ -6,6 +6,28 @@ STOP=90
RTC_DEV=/dev/rtc0
HWCLOCK=/sbin/hwclock
+IN_UTC=''
+
+. /lib/functions/procd.sh
+
+validate_system_section() {
+ uci_validate_section system system "${1}" \
+ 'rtc_utc:bool:0'
+}
+
+rtc_config() {
+ local rtc_utc
+
+ validate_system_section "${1}" || {
+ echo "validation failed"
+ return 1
+ }
+
+ [ $rtc_utc = 1 ] && IN_UTC='-u'
+}
+
+config_load system
+config_foreach rtc_config system
boot() {
start && exit 0
@@ -16,11 +38,11 @@ boot() {
}
start() {
- [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s -f $RTC_DEV
+ [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -s $IN_UTC -f $RTC_DEV
}
stop() {
- [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w -f $RTC_DEV && \
+ [ -e "$RTC_DEV" ] && [ -e "$HWCLOCK" ] && $HWCLOCK -w $IN_UTC -f $RTC_DEV && \
logger -t sysfixtime "saved '$(date)' to $RTC_DEV"
}
--
1.9.1
More information about the Lede-dev
mailing list