51 lines
1.3 KiB
Bash
51 lines
1.3 KiB
Bash
# ------------------------------------------------------------------------------
|
|
# NTP
|
|
# ------------------------------------------------------------------------------
|
|
# Variable:
|
|
# * NTPSERVERS: list of NTP servers
|
|
# ------------------------------------------------------------------------------
|
|
|
|
export VER_conf_ntp="0.0.6"
|
|
|
|
conf_ntp()
|
|
{
|
|
if [[ $(pidof systemd) ]]; then
|
|
prnt I "Désactivation de Systemd-timesyncd..."
|
|
systemctl disable systemd-timesyncd || true
|
|
fi
|
|
|
|
prnt I "Installation du démon ntp..."
|
|
pkginst ntp
|
|
prnt I "Arrêt du service ntp..."
|
|
svc_stop ntp
|
|
|
|
prnt I "Installation du fichier de configuration de NTP."
|
|
local dest="/etc/ntp.conf.work"
|
|
backupdist /etc/ntp.conf
|
|
installfile ntp.conf $dest
|
|
local line=""
|
|
for srv in $NTPSERVERS; do
|
|
line="${line}server $srv iburst\n"
|
|
done
|
|
sed -i -e "s/@SERVERLIST@/$line/" $dest &&
|
|
echo "# Generated on $(stdtime)" >> $dest &&
|
|
mv -fv $dest /etc/ntp.conf
|
|
|
|
prnt I "Démarrage du service ntp..."
|
|
svc_start ntp
|
|
}
|
|
|
|
# NTP
|
|
precheck_conf_ntp()
|
|
{
|
|
if [[ -z $NTPSERVERS ]]; then
|
|
prnt E "Pas de serveur NTP configuré !"
|
|
die 151
|
|
else
|
|
prnt m "Les serveurs ntp utilisés seront : $NTPSERVERS"
|
|
fi
|
|
}
|
|
|
|
export -f conf_ntp
|
|
export -f precheck_conf_ntp
|