summaryrefslogtreecommitdiff
path: root/hwclock
blob: d9de9e16ed914b3c07af57ffb9f96f5947f48eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case $HARDWARECLOCK in
	UTC) HWCLOCK_PARAMS="--utc";;
	localtime) HWCLOCK_PARAMS="--localtime";;
	*) HWCLOCK_PARAMS="";;
esac

case "$1" in
	start)
		if [[ $HWCLOCK_PARAMS ]]; then
			status "Adjusting Hardware Clock" \
				/sbin/hwclock --adjust
			stat_busy "Setting System Clock"
			/sbin/hwclock --hctosys $HWCLOCK_PARAMS || stat_die
			stat_done
			# Note: This also enables /etc/cron.hourly/adjtime
			add_daemon hwclock
		fi
		;;
	stop)
		if [[ $HWCLOCK_PARAMS ]]; then
			stat_busy "Saving System Clock"
			/sbin/hwclock --systohc $HWCLOCK_PARAMS || stat_die
			stat_done
		fi
		rm_daemon hwclock
		;;
	restart)
		$0 stop
		sleep 1
		$0 start
		;;
	*)
		echo "usage: $0 {start|stop|restart}"
esac