aboutsummaryrefslogtreecommitdiff
path: root/hwclock
diff options
context:
space:
mode:
Diffstat (limited to 'hwclock')
-rwxr-xr-xhwclock39
1 files changed, 39 insertions, 0 deletions
diff --git a/hwclock b/hwclock
new file mode 100755
index 0000000..d9de9e1
--- /dev/null
+++ b/hwclock
@@ -0,0 +1,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