#!/usr/bin/sh #---------------------------------------------------------------------------- # /var/install/bin/ntp-set-time - set time # # Copyright (c) 2003-2004 Albert Steiner # Copyright (c) 2005-2024 The Eisfair Team, team(at)eisfair(dot)org # # Creation: 2003-12-27 as # Last Update: $Id$ # # 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; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # read eislib . /var/install/include/eislib pgmname=`basename $0` module_name=`basename -s .sh ${pgmname} | cut -d- -f1` . /etc/config.d/ntp clrhome if [ ${NTP_SET_SERVER_N} -eq 0 ] then mecho mecho --error "No Server's defined to set the Time ..." mecho anykey else if /var/install/bin/ask "Set Time via other NTP Server" then mecho /usr/sbin/service stop ${module_name} mecho sleep 2 idx=1 while [ ${idx} -le ${NTP_SET_SERVER_N} ] do eval server='$NTP_SET_SERVER_'${idx} mecho --info "Try to set Time via ${server} ..." if [ -f /usr/bin/ntpdig ] then # -4 - force IPv4 DNS name resolution. # -6 - force IPv6 DNS name resolution. # -j - enable output in json format # -s - adjust time by slewing the clock # -t NN - number of seconds to wait for responses /usr/bin/ntpdig -s -j -t 1 ${server} 2>&1 | sed 's/,ip:/,"ip":/' | jq else /usr/bin/ntpdate ${server} fi if [ $? -eq 0 ] then idx=${NTP_SET_SERVER_N} fi idx=`expr ${idx} + 1` done sleep 1 echo /usr/sbin/hwclock -uw mecho --info "Hardware Clock Time is now ..." hwclock --show --localtime mecho --info "Software Clock Time is now ..." date mecho sleep 1 /usr/sbin/service start ${module_name} mecho anykey fi fi exit 0