f78cb9c55c
* Add NTP YANG model Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Extend NTP config generation mechanism Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Add NTP YANG nodel tests Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Add test for NTP Jinja templates Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Add ntpdate package Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Fix 'bad' when auth disabled Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * [NTP] Changed owner for ntp keys config file to root and remove read access for other. Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Fix NTP warnings after restarting the service Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Add ability to encrypt/decrypt NTP keys Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Update Configuration reference Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Fix NTP configuration template * Align the description for setting interface * Fix the usage of scoped variable Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Fix YANG model description and tests Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Align NTP test according to fixed condition Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Allow eth0 to be as source ifc without defining it Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> * Update sample config with NTP config Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com> --------- Signed-off-by: Yevhen Fastiuk <yfastiuk@nvidia.com>
37 lines
1010 B
Bash
Executable File
37 lines
1010 B
Bash
Executable File
#!/bin/bash
|
|
|
|
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`
|
|
SYSTEM_FAST_START=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
|
|
|
|
if [[ x"${SYSTEM_WARM_START}" == x"true" ]]; then
|
|
reboot_type='warm'
|
|
elif [[ x"${SYSTEM_FAST_START}" == x"true" ]]; then
|
|
reboot_type='fast'
|
|
fi
|
|
}
|
|
|
|
function modify_ntp_default
|
|
{
|
|
cp ${ntp_default_file} ${ntp_temp_file}
|
|
sed -e "$1" ${ntp_temp_file} >${ntp_default_file}
|
|
}
|
|
|
|
sonic-cfggen -d -t /usr/share/sonic/templates/ntp.conf.j2 >/etc/ntp.conf
|
|
sonic-cfggen -d -t /usr/share/sonic/templates/ntp.keys.j2 >/etc/ntp.keys
|
|
|
|
chown root:ntp /etc/ntp.keys
|
|
chmod o-r /etc/ntp.keys
|
|
|
|
get_database_reboot_type
|
|
echo "Disabling NTP long jump for reboot type ${reboot_type} ..."
|
|
modify_ntp_default "s/NTPD_OPTS='-g'/NTPD_OPTS='-x'/"
|
|
|
|
systemctl --no-block restart ntp
|