Reintroduce setclock to write system clock to RTC at shutdown
authorHugo Villeneuve <hugo@hugovil.com>
Fri, 14 Aug 2015 21:19:26 +0000 (17:19 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Fri, 14 Aug 2015 21:19:44 +0000 (17:19 -0400)
stage1/bootscripts/setclock [new file with mode: 0755]
stage1/install-bootscripts

diff --git a/stage1/bootscripts/setclock b/stage1/bootscripts/setclock
new file mode 100755 (executable)
index 0000000..d07e135
--- /dev/null
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+# setclock - Save system time value to hardware clock on shutdown and reboot
+
+# Source functions library
+source /etc/rc.d/init.d/functions
+
+log_script_name "$0 $*"
+
+# Load clock parameters
+source /etc/sysconfig/clock
+
+case "$UTC" in
+    yes|true|1)
+       TIME_BASE="--utc"
+       ;;
+    no|false|0)
+       TIME_BASE="--localtime"
+       ;;
+    *)
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+# See how we were called
+case "$1" in
+    stop)
+       cmd_run_log_box "Saving system time value in hardware clock" \
+           /sbin/hwclock --systohc "$TIME_BASE"
+       ;;
+    *)
+       echo "Usage: $0 {stop}"
+        exit ${EXIT_CODE_FAILURE}
+       ;;
+esac
+
+exit $?
index b2595f3..5e2e539 100755 (executable)
@@ -40,12 +40,14 @@ bootscript_add_rcsysinit swap        40 00
 bootscript_add_rcsysinit cleanfs     45 00
 
 # rc0.d
+bootscript_add_manual 0 setclock    55 00
 bootscript_add_manual 0 sendsignals 60 00
 bootscript_add_manual 0 swap        65 00
 bootscript_add_manual 0 mountfs     70 00
 bootscript_add_manual 0 halt        99 00
 
 # rc6.d is almost identical to rc0.d
+bootscript_add_manual 0 setclock    55 00
 bootscript_add_manual 6 sendsignals 60 00
 bootscript_add_manual 6 swap        65 00
 bootscript_add_manual 6 mountfs     70 00