c09ee07b2c
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>
40 lines
605 B
Bash
40 lines
605 B
Bash
#! /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
|