2017-01-29 13:33:33 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-05-20 12:57:21 -05:00
|
|
|
ntp_default_file='/etc/default/ntp'
|
|
|
|
ntp_temp_file='/tmp/ntp.orig'
|
|
|
|
|
|
|
|
reboot_type='cold'
|
|
|
|
|
|
|
|
function get_database_reboot_type()
|
|
|
|
{
|
|
|
|
SYSTEM_WARM_START=`sonic-db-cli STATE_DB hget "WARM_RESTART_ENABLE_TABLE|system" enable`
|
2023-04-09 08:59:15 -05:00
|
|
|
SYSTEM_FAST_START=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
|
2020-05-20 12:57:21 -05:00
|
|
|
|
|
|
|
if [[ x"${SYSTEM_WARM_START}" == x"true" ]]; then
|
|
|
|
reboot_type='warm'
|
2023-04-09 08:59:15 -05:00
|
|
|
elif [[ x"${SYSTEM_FAST_START}" == x"true" ]]; then
|
2020-05-20 12:57:21 -05:00
|
|
|
reboot_type='fast'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function modify_ntp_default
|
|
|
|
{
|
|
|
|
cp ${ntp_default_file} ${ntp_temp_file}
|
|
|
|
sed -e "$1" ${ntp_temp_file} >${ntp_default_file}
|
|
|
|
}
|
|
|
|
|
2017-09-12 16:13:27 -05:00
|
|
|
sonic-cfggen -d -t /usr/share/sonic/templates/ntp.conf.j2 >/etc/ntp.conf
|
2017-11-07 16:51:07 -06:00
|
|
|
|
2020-05-20 12:57:21 -05:00
|
|
|
get_database_reboot_type
|
2020-06-11 15:01:21 -05:00
|
|
|
echo "Disabling NTP long jump for reboot type ${reboot_type} ..."
|
|
|
|
modify_ntp_default "s/NTPD_OPTS='-g'/NTPD_OPTS='-x'/"
|
2020-05-20 12:57:21 -05:00
|
|
|
|
2020-12-04 10:49:20 -06:00
|
|
|
systemctl --no-block restart ntp
|