#! /bin/sh #---------------------------------------------------------------------------- # rc450.chrony - configure and start chrony # # Creation: 2004-06-06 abe # Last Update: $Id$ # #---------------------------------------------------------------------------- case $OPT_CHRONY in yes) begin_script CHRONY "starting chrony NTP-Service" # When running inside a Xen DomU, make sure we are actually doing something. if [ -f /proc/sys/xen/independent_wallclock ] then echo 1 > /proc/sys/xen/independent_wallclock echo 1 > /var/run/broken_rtc fi chrony_conf="/etc/chrony.conf" chrony_key="/etc/chrony.keys" chrony_log="/var/run" chrony_default_server="pool.ntp.org" chrony_serverlist="/etc/chrony_server.conf" [ -n "$CHRONY_LOG" ] && chrony_log=`echo $CHRONY_LOG | sed -e 's#/$##'` [ ! -d $chrony_log ] && mkdir -p $chrony_log # create file etc/chrony.keys if [ ! -f $chrony_key ] # already existing? then # yes, don't overwrite cat <<-EOF > $chrony_key #---------------------------------------------------------------------- # /etc/chrony.keys # Automatically created by rc920.chrony #---------------------------------------------------------------------- 1 dummy EOF fi # create file etc/chrony_server.conf if [ ! -f $chrony_serverlist ] # already existing? then # yes, don't overwrite [ ${CHRONY_TIMESERVER_N:=3} -eq 0 ] || { prefix=0 for idx in `seq 1 $CHRONY_TIMESERVER_N` do eval chrony_server='$CHRONY_TIMESERVER_'$idx chrony_server=${chrony_server:-$prefix.$chrony_default_server} echo "server $chrony_server maxpoll 14 offline" serverlist="$serverlist$chrony_server " [ $prefix -lt 2 ] && prefix=`expr $prefix + 1` || prefix=0 done } >> $chrony_serverlist fi # create file etc/chrony.conf if [ ! -f $chrony_conf ] # already existing? then # yes, don't overwrite cat <<-EOF > $chrony_conf #---------------------------------------------------------------------- # /etc/chrony.conf # Automatically created by rc920.chrony #---------------------------------------------------------------------- keyfile /etc/chrony.keys driftfile $chrony_log/chrony.drift rtcfile $chrony_log/chrony.rtc commandkey 1 allow cmdallow localhost cmdallow 127.0.0.1 maxupdateskew 100 local stratum 8 EOF [ "$CHRONY_BIOS_TIME" != local ] && echo rtconutc >> $chrony_conf cp $chrony_conf $chrony_conf.first echo "initstepslew 30 $serverlist" >> $chrony_conf.first cat $chrony_serverlist >> $chrony_conf.first fi if [ "$OPT_IPV6" = "yes" ] then CHRONYDOPTIONS="-r" else CHRONYDOPTIONS="-r -4" > /var/run/chronyd_ipv4.only fi # use initstepslew to correct time difference grater than 30sec. at once # only during first ip-up event (see chrony ip-up and ip-down scripts) # start chrony in first ip-up event log_info "start of chronyd with '$CHRONYDOPTIONS' as options - chronyd will be restarted by ip-up" chronyd $CHRONYDOPTIONS case $CHRONY_TIMESERVICE in yes) srv868 log_info " timeservice on port 37 is now activated" ;; esac # Activation of chronyd watchdog - avoids chronyd 100% cpu-useage - check every hour /usr/bin/service-restart.sh 3595 /usr/bin/chrony-wd.sh & log_info " watchdog for chrony is now activated" if [ "$OPT_HTTPD" = "yes" ] then httpd-menu.sh add -p 109 status_chrony.cgi '$_MP_timesync' '$_MT_stat' status fi end_script ;; esac