Commit feb4f8f2 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/rootfs_override: save date over restarts

--add running all /etc/init.d/K* scripts before restart
--add /etc/init.d/K90time_save.sh script to save current date
--set saved date in case date cannot be received from ntp
--update developer manual
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent da583f7b
......@@ -1623,7 +1623,7 @@ allows to make some sense of the overall area. The structure
is filled by library functions and accessed by shared memory users.
You can see how it is used in @t{tools/wrs_dump_shmem.c}.
The following functions are defined. Pleae look in the source code
The following functions are defined. Please look in the source code
for details about how they are used:
@table @code
......@@ -1798,6 +1798,22 @@ We may also consider to use one of the kernel's mechanisms for persistent
storage of information across reboots, to recover panic messages
after a reboot.
@c ==========================================================================
@node Time keeping over restarts
@section Time keeping over restarts
At normal restart, current time is saved in @t{/update/saved_date}.
Later, at boot switch tries to retrieve correct time from ntp server
if configured in dot-config.
If no correct date can be retrieved via ntp, switch tries to set date stored in
@t{/update/saved_date}. Please note that at crash, power down or
reset by reset button no date information is saved. After such restart switch
will set date to last gentle reboot or to 1st of January 1970 if there were no
gentle restarts before.
Date set from file @t{/update/saved_date} is never correct, but is based on
best effort principle.
@c ==========================================================================
@node SDB and Hardware Information
@section SDB and Hardware Information
......
#!/bin/sh
echo "Saving time "`date +%Y.%m.%d-%H:%M:%S`
date +%Y.%m.%d-%H:%M:%S > /update/saved_date
......@@ -4,18 +4,32 @@
/wr/bin/wr_date get > /dev/null
F=/wr/etc/wr_date.conf
# if there is no config file, do nothing else.
test -f $F || exit 0
# pick the first server, if any
S=$(grep 'ntpserver' $F | sed 's/ntpserver//' | head -n 1)
date_set=0
# check whether there is config file
if [ -f $F ]; then
# pick the first server, if any
S=$(grep 'ntpserver' $F | sed 's/ntpserver//' | head -n 1)
# check whether server found
if [ -n "$S" ]; then
# if none, exit
test -z "$S" && exit 0
# pick busybox ntpd explicitly, to avoid real ntpd instances
echo "Setting host time using ntpd"
busybox ntpd -n -q -p $S
echo "Setting WR time from host time"
/wr/bin/wr_date set host
# pick busybox ntpd explicitly, to avoid real ntpd instances
echo "Setting host time using ntpd"
busybox ntpd -n -q -p $S
if [ $? == 0 ]; then
# successful
echo "Date set from $S"
date_set=1
echo "Setting WR time from host time"
/wr/bin/wr_date set host
fi
fi
fi
# if ntp failed, try to restore date saved before last reboot
if [ $date_set = 0 ] && [ -f /update/update_date ]; then
#date is not accurate but no better idea.
echo "Restore saved time"
date -s `cat /update/update_date`
echo "Setting WR time from host time"
/wr/bin/wr_date set host
fi
#!/bin/sh
if [ -n "$WRS_VERBOSE" ]; then
set -x;
SH_X="sh -x"
fi
# Stop all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/K??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set stop
. $i
)
;;
*)
# No sh extension, so fork subprocess.
eval $SH_X $i stop
;;
esac
done
......@@ -29,5 +29,7 @@ ttyGS0::respawn:/bin/ash --login
ttyS0::respawn:/bin/ash --login
# Stuff to do before rebooting
# run all /etc/init.d/K* scripts
null::shutdown:/etc/init.d/rcK -a -r
null::shutdown:/bin/umount -a -r
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment