mirror of
https://gitlab.com/buildroot.org/buildroot.git
synced 2026-10-01 06:21:56 -09:00
package/hwclock-initscript: new package
Add a new initscript to save the date and time to the hardware clock on shutdown. Signed-off-by: Michael Walle <michael@walle.cc> [Arnout: - package as hwclock-initscript instead of buildroot-initscripts; - mention in help text that it isn't needed at boot; - rewrite initscript according to our usual pattern; - fix shellcheck errors. ] Signed-off-by: Arnout Vandecappelle <arnout@rnout.be>
This commit is contained in:
committed by
Arnout Vandecappelle
parent
faf2b8a627
commit
c09ee07b2c
@@ -2866,6 +2866,7 @@ menu "System tools"
|
|||||||
source "package/getent/Config.in"
|
source "package/getent/Config.in"
|
||||||
source "package/gkrellm/Config.in"
|
source "package/gkrellm/Config.in"
|
||||||
source "package/htop/Config.in"
|
source "package/htop/Config.in"
|
||||||
|
source "package/hwclock-initscript/Config.in"
|
||||||
source "package/ibm-sw-tpm2/Config.in"
|
source "package/ibm-sw-tpm2/Config.in"
|
||||||
source "package/initscripts/Config.in"
|
source "package/initscripts/Config.in"
|
||||||
source "package/iotop/Config.in"
|
source "package/iotop/Config.in"
|
||||||
|
|||||||
10
package/hwclock-initscript/Config.in
Normal file
10
package/hwclock-initscript/Config.in
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
config BR2_PACKAGE_HWCLOCK_INITSCRIPT
|
||||||
|
bool "hwclock-initscript"
|
||||||
|
depends on !BR2_PACKAGE_SYSTEMD
|
||||||
|
depends on BR2_PACKAGE_BUSYBOX || BR2_PACKAGE_UTIL_LINUX_HWCLOCK
|
||||||
|
help
|
||||||
|
Initscript to save the date and time to the hardware clock on
|
||||||
|
shutdown.
|
||||||
|
|
||||||
|
Note that the kernel already loads the time from the hwclock
|
||||||
|
at boot time, no init script is needed for that.
|
||||||
39
package/hwclock-initscript/S20hwclock
Normal file
39
package/hwclock-initscript/S20hwclock
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
#
|
||||||
|
# hwclock This writes the system time to the RTC on shutdown
|
||||||
|
#
|
||||||
|
|
||||||
|
RTC_DEVICE=rtc0
|
||||||
|
DAEMON=hwclock
|
||||||
|
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
||||||
|
|
||||||
|
# Quietly do nothing if /dev/rtc0 does not exist
|
||||||
|
[ -c /dev/$RTC_DEVICE ] || exit 0
|
||||||
|
|
||||||
|
start(){
|
||||||
|
: # Nothing to do on startup
|
||||||
|
}
|
||||||
|
|
||||||
|
stop(){
|
||||||
|
printf "Saving the system clock to /dev/%s\n" "${RTC_DEVICE}"
|
||||||
|
/sbin/$DAEMON -f "/dev/${RTC_DEVICE}" -w
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
stop
|
||||||
|
;;
|
||||||
|
restart|reload)
|
||||||
|
stop
|
||||||
|
start
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop|restart|reload}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
12
package/hwclock-initscript/hwclock-initscript.mk
Normal file
12
package/hwclock-initscript/hwclock-initscript.mk
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# hwclock-initscript
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
define HWCLOCK_INITSCRIPT_INSTALL_INIT_SYSV
|
||||||
|
$(INSTALL) -D -m 0755 $(HWCLOCK_INITSCRIPT_PKGDIR)/S20hwclock \
|
||||||
|
$(TARGET_DIR)/etc/init.d/S20hwclock
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(eval $(generic-package))
|
||||||
Reference in New Issue
Block a user