#!/bin/sh
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../clockspeed/clockspeed-adjust.sh
# Copyright (C) 2008 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License. A copy of the
# GNU General Public License can be found in the file COPYING.
# --- SDE-COPYRIGHT-NOTE-END ---

# clock_adjust.sh
# periodically get timing mark for clockspeed service
# taken from http://www.thedjbway.org/clocksd/index.html
#
# initialize WAIT, WAIT_MAX:
WAIT=541
WAIT_MAX=2617923

# loop indefinitely
while :
do
    echo "Waiting ${WAIT} seconds until next adjustment..."
    sleep ${WAIT}
    # obtain timing mark for calibrating clockspeed adjust:
    clockctl mark
    # log current "attoseconds":
    clockctl atto
    echo "==="
    # increment $WAIT:
    WAIT=`expr ${WAIT} + ${WAIT} + ${WAIT}`
    if [ ${WAIT} -gt ${WAIT_MAX} ] ; then
        WAIT=${WAIT_MAX}
    fi
done
# that's all, folks!