Skip to content

Commit

Permalink
Merge branch 'jb52072_system_time_failure' into 'master'
Browse files Browse the repository at this point in the history
Add set system time -preinit plugin

See merge request mer-core/dsme!47
  • Loading branch information
spiiroin committed Feb 2, 2021
2 parents b6e056a + 10304db commit 913abe0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions preinit/set_system_time
@@ -0,0 +1,14 @@
#!/bin/sh

# Set system time from RTC
hwclock -s

# Apply correction value that DSME writes to
# a file in case device has read-only RTC TOD
DELTA_TIME_FILE="/var/tmp/delta-time"
if [ -f $DELTA_TIME_FILE ]; then
DELTA_TIME_VALUE=$(cat $DELTA_TIME_FILE)
date -s@$(($(date +'%s')+$DELTA_TIME_VALUE))
fi

exit 0
2 changes: 2 additions & 0 deletions rpm/dsme.spec
Expand Up @@ -73,6 +73,7 @@ install -d %{buildroot}%{_unitdir}/multi-user.target.wants/
ln -s ../%{name}.service %{buildroot}%{_unitdir}/multi-user.target.wants/%{name}.service
install -d %{buildroot}/var/lib/dsme
[ ! -f %{buildroot}/var/lib/dsme/alarm_queue_status ] && echo 0 > %{buildroot}/var/lib/dsme/alarm_queue_status
install -D -m755 preinit/set_system_time %{buildroot}/usr/lib/startup/preinit/set_system_time

%preun
if [ "$1" -eq 0 ]; then
Expand All @@ -99,6 +100,7 @@ systemctl daemon-reload || :
/var/lib/dsme
%config(noreplace) /var/lib/dsme/alarm_queue_status
/etc/profile.d/reboot-via-dsme.sh
/usr/lib/startup/preinit/set_system_time

%files plugin-devel
%defattr(-,root,root,-)
Expand Down

0 comments on commit 913abe0

Please sign in to comment.