##-----------------------------------------------------------------------------
## check/chrony.ext - fli4l extended configuration check          3.0.1
##
##        P L E A S E   R E A D   T H E   D O C U M E N T A T I O N ,
##
##        B I T T E  U N B E D I N G T   D I E   D O K U M E N T A T I O N
##
## Creation:     2004-06-06  abe
## Last Update:  $Id: chrony.ext 11025 2006-02-19 20:33:10Z abe $
##
## 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.
##-----------------------------------------------------------------------------

if (opt_chrony)
then
  provides TIME version 3.0.1

  if (kernel_version =~ "xen")
  then
    error "OPT_CHRONY: sorry, time adjustment belongs only to the XEN-Host (dom0). CHRONY doesn't work within a domU."
  fi

  if ((opt_pppoe && !pppoe_filter && pppoe_hup_timeout != "never") || (opt_fritzdsl && !fritzdsl_filter && fritzdsl_hup_timeout != "never") || (opt_pptp && !pptp_filter && pptp_hup_timeout != "never"))
  then
      error "CHRONY: to ensure secure hangup while chrony is running active filter has to be enabled. Set xxx_FILTER='yes' in <config>/dsl.txt. To run CHRONY without active filter set xxx_HUP_TIMEOUT='never'"
  fi
  
  if (opt_isdn)
  then
     foreach i in isdn_circuits_n
     do
       set ir=isdn_circ_%_route_n[i]
       foreach n in ir
       do
	 set i_route=isdn_circ_%_route_%[i][n]
         if (i_route == "0.0.0.0")
         then
           set ippp_used
         fi
       done
     done
    
    if(!isdn_filter && ippp_used)
    then
       error "CHRONY: to ensure secure hangup while chrony is running active filter has to be enabled. Set ISDN_FILTER='yes' in <config>/isdn.txt."
    fi
  fi

  if (opt_modem)
  then
    warning "CHRONY: automatic hangup isn't guaranteed, especially while chrony is running. Please disconnect manually."
  fi

  stat("$config_dir/etc/chrony.conf", chronyconf)
  if(chronyconf_res == "OK")
  then
    add_to_opt "etc/chrony.conf" "flags=utxt"
  fi
fi
