chrony: rework loading of configuration
authorMiroslav Lichvar <redacted>
Fri, 30 Oct 2020 16:02:49 +0000 (17:02 +0100)
committerMiroslav Lichvar <redacted>
Fri, 30 Oct 2020 19:02:11 +0000 (20:02 +0100)
Instead of loading /etc/chrony/chrony.conf from the file generated from
the chrony UCI configuration, use the confdir directive in the main
config to load the generated file. This should make it obvious that
chrony is configured in UCI and it can also be easily disabled.

Signed-off-by: Miroslav Lichvar <redacted>
net/chrony/files/chrony.conf
net/chrony/files/chronyd.init

index 410e63b948a187288a0fb0324a03294636d05567..4ad195c3e806d099711abe0d1eac89c69029ddb8 100644 (file)
@@ -1,4 +1,5 @@
-# This file is included from config file generated from /etc/config/chrony
+# Load UCI configuration
+confdir /var/etc/chrony.d
 
 # Log clock errors above 0.5 seconds
 logchange 0.5
index 492f755ff1d5073cadbc80788eb6eb5838c26b41..42b052d8bcbc1e6da5fd2c2a40084357d98a8f22 100644 (file)
@@ -4,8 +4,8 @@
 START=15
 USE_PROCD=1
 PROG=/usr/sbin/chronyd
-CONFIGFILE=/var/etc/chrony.conf
-INCLUDEFILE=/etc/chrony/chrony.conf
+CONFIGFILE=/etc/chrony/chrony.conf
+INCLUDEFILE=/var/etc/chrony.d/10-uci.conf
 
 handle_source() {
        local cfg=$1 sourcetype=$2 hostname minpoll maxpoll iburst
@@ -57,20 +57,19 @@ start_service() {
        . /lib/functions/network.sh
 
        procd_open_instance
-       procd_set_param command $PROG -n -f $CONFIGFILE
+       procd_set_param command $PROG -n
        procd_set_param file $CONFIGFILE
        procd_set_param file $INCLUDEFILE
        procd_close_instance
 
        config_load chrony
-       mkdir -p $(dirname $CONFIGFILE)
+       mkdir -p $(dirname $INCLUDEFILE)
 
        (
-               echo include $INCLUDEFILE
                config_foreach handle_source server server
                config_foreach handle_source pool pool
                config_foreach handle_source peer peer
                config_foreach handle_allow allow
                config_foreach handle_makestep makestep
-       ) > $CONFIGFILE
+       ) > $INCLUDEFILE
 }
git clone https://git.99rst.org/PROJECT