"Fossies" - the Fresh Open Source Software Archive

Member "htpdate-1.3.4/scripts/adjtimex_parameters.sh" (18 Apr 2022, 781 Bytes) of package /linux/www/htpdate-1.3.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "adjtimex_parameters.sh": 1.2.3_vs_1.2.4.

    1 #! /bin/sh
    2 #
    3 # In daemon mode htpdate writes the systematic drift of the clock to syslog.
    4 # With this script you can convert the PPM drift values into adjtimex
    5 # parameters. Only use this script when you know what you are doing.
    6 #
    7 # Consult adjtimex man page for more information.
    8 
    9 if [ ! $1 ]; then
   10     echo "Usage: $0 <PPM> [current TICK] [current FREQ]"
   11     echo "By default TICK=10000 and FREQ=0"
   12     echo
   13     exit 1
   14 fi
   15 
   16 PPM=$1
   17 TICK=10000
   18 FREQ=0
   19 
   20 if [ $2 ]; then
   21     TICK=$2
   22 fi
   23     
   24 if [ $3 ]; then
   25     FREQ=$3
   26 fi
   27 
   28 FREQTOT=`echo "$PPM * 65536 + $TICK * 6553600 + $FREQ" | bc`
   29 
   30 TICK=`echo "$FREQTOT / 6553600" | bc`
   31 FREQ=`echo "$FREQTOT % 6553600" | bc | awk -F. '{print $1}'`
   32 
   33 echo "TICK=$TICK"
   34 echo "FREQ=$FREQ"
   35 echo "Suggested command: adjtimex -tick $TICK -frequency $FREQ"