#!/bin/sh if [ "$(id -u)" -ne 0 ]; then [ -x "$(which su-to-root)" ] && exec su-to-root -X -c "$0" "$@" printf "ERROR: $0 needs root capabilities, please start it as root.\n\n" >&2 exit 1 fi # get time servers from /etc/default/ntpdate . /etc/default/ntpdate [ -z "$NTPSERVER" ] && NTPSERVER="pool.ntp.org" # assume the hw clock being in local time hwclock --hctosys --localtime # let the user set their time zone dpkg-reconfigure tzdata # sync with time servers for i in $NTPSERVER; do if ntpdate -u -b "$i"; then hwclock --systohc break fi done