we have bash script that configured the chrony.conf
script check if ping is ok on ntp1 and ntp2 ( ntp servers )
and then script insert the ntp servers to /etc/chrony.conf ( only if ping success )
example from bash script:
ping -c 1 ntp1
if [[ $? -eq 0 ]];then
echo "server ntp1 iburst" >> /etc/chrony.conf
else
echo "sorry so much but no ping to ntp1 server , /etc/chrony.conf will not configured "
exit 1
fi
ping -c 1 ntp2
if [[ $? -eq 0 ]];then
echo "server ntp2 iburst" >> /etc/chrony.conf
else
echo "sorry so much but no ping to ntp2 server , /etc/chrony.conf will not configured "
exit 1
fi
the problem is that sometimes the user decided to disable the ping or icmp
then in that case the scenario that we checked the ping isn't relevant , and we cant add the lines to /etc/chrony.conf
so we want to know how to test the ntp1 and ntp2 servers in order to add ntp1 and ntp2 to chrony configuration
for example if ntp1 and ntp2 not seems to be as ntp servers , then we will not add them to chrony configuration