Files
initscripts/SRC/initscripts/init.d/hwclock
Jay Larson 3112172beb This package has gone through significant changes:
* Re-wrote/cleaned up init scripts
  * Re-wrote init-functions
  * Moved some things (init scripts, defaults, configs) to other packages
  * Added update-rc which manages /etc/rc* directories
  * Added usher to manage defaults
2017-05-16 16:44:05 -05:00

58 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
### BEGIN INIT INFO
# Provides: hwclock
# Required-Start: $local_fs
# Required-Stop:
# Should-Start: modules
# Should-Stop: $syslog
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Synchronize the system and hardware clocks
# Description: During boot sync the hardware clock to the
# system clock if udev is not running. During
# shutdown do the reverse
# X-Required: true
### END INIT INFO
. /lib/lsb/init-functions
case "$UTC" in
0|n|no)
ZONE="--localtime"
;;
*)
ZONE="--utc"
;;
esac
case "$1" in
start)
if [ ! -f /etc/adjtime ]; then
printf "0.0 0 0.0\n0\nUTC\n" > /etc/adjtime
fi
if [ -d /run/udev ] || [ -d /dev/.udev ]; then
exit 0;
fi
log_init_msg "Setting the system clock"
hwclock --hctosys $ZONE >/dev/null && log_success_msg || log_failure_msg
;;
stop|restart)
log_init_msg "Setting hardware clock"
hwclock --systohc $ZONE >/dev/null && log_success_msg || log_failure_msg
;;
status)
echo -n "System clock: "
date +'%Y-%m-%d %H:%M:%S'
echo -n "Hardware clock: "
hwclock --show $ZONE
;;
*)
echo "Usage: $0 [start|stop|restart]"
exit 1
;;
esac
exit 0