mirror of
https://github.com/hassio-addons/addon-chrony.git
synced 2025-05-05 11:41:38 +00:00
🔨 Refactor of init scripts (#15)
This commit is contained in:
parent
f6b98735e0
commit
465a6156f7
2 changed files with 15 additions and 20 deletions
|
@ -1,19 +0,0 @@
|
||||||
#!/usr/bin/with-contenv bashio
|
|
||||||
# ==============================================================================
|
|
||||||
# Community Hass.io Add-ons: chrony
|
|
||||||
# This file configures the conf file from the options set
|
|
||||||
# ==============================================================================
|
|
||||||
readonly CHRONY_CONF='/etc/chrony/chrony.conf'
|
|
||||||
declare mode
|
|
||||||
declare -a serverlist
|
|
||||||
|
|
||||||
mode=$(bashio::config 'mode')
|
|
||||||
bashio::log.debug "Running in NTP mode: ${mode}"
|
|
||||||
|
|
||||||
for server in $(bashio::config "ntp_${mode}"); do
|
|
||||||
bashio::log.debug "Adding server ${server}"
|
|
||||||
echo "${mode} ${server} iburst" >> ${CHRONY_CONF}
|
|
||||||
serverlist+=("${server}")
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "initstepslew 10 ${serverlist[*]}" >> ${CHRONY_CONF}
|
|
|
@ -1,8 +1,11 @@
|
||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Community Hass.io Add-ons: chrony
|
# Community Hass.io Add-ons: chrony
|
||||||
# This files check if all user configuration requirements are met
|
# Configures chrony
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
readonly CHRONY_CONF='/etc/chrony/chrony.conf'
|
||||||
|
declare mode
|
||||||
|
declare -a serverlist
|
||||||
|
|
||||||
# Check running mode
|
# Check running mode
|
||||||
if bashio::config.equals 'mode' 'pool' \
|
if bashio::config.equals 'mode' 'pool' \
|
||||||
|
@ -36,3 +39,14 @@ then
|
||||||
bashio::log.fatal
|
bashio::log.fatal
|
||||||
bashio::exit.nok
|
bashio::exit.nok
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Write configuration file
|
||||||
|
mode=$(bashio::config 'mode')
|
||||||
|
bashio::log.debug "Running in NTP mode: ${mode}"
|
||||||
|
for server in $(bashio::config "ntp_${mode}"); do
|
||||||
|
bashio::log.debug "Adding server ${server}"
|
||||||
|
echo "${mode} ${server} iburst" >> ${CHRONY_CONF}
|
||||||
|
serverlist+=("${server}")
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "initstepslew 10 ${serverlist[*]}" >> ${CHRONY_CONF}
|
Loading…
Add table
Add a link
Reference in a new issue