5efb123ede
hld [#1296](https://github.com/sonic-net/SONiC/pull/1296) closes [#1254](https://github.com/sonic-net/SONiC/issues/1254) depends-on [#60](https://github.com/sonic-net/sonic-host-services/pull/60), [#781](https://github.com/sonic-net/sonic-swss-common/pull/781), [#2835](https://github.com/sonic-net/sonic-utilities/pull/2835), [#10749](https://github.com/sonic-net/sonic-mgmt/pull/10749) #### Why I did it To cover the next AIs: * Configure NTP global parameters * Add/remove new NTP servers * Change the configuration for NTP servers * Show NTP status * Show NTP configuration ### How I did it * Add YANG model for a new configuration * Extend configuration templates to support new knobs ### Description for the changelog * Add ability to configure NTP global parameters such as authentication, dhcp, admin state * Change the configuration for NTP servers * Add an ability to show NTP configuration #### Link to config_db schema for YANG module changes [NTP configuration](https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/doc/Configuration.md#ntp-and-syslog-servers)
35 lines
1007 B
Bash
Executable File
35 lines
1007 B
Bash
Executable File
#!/bin/bash
|
|
|
|
ntp_default_file='/etc/default/ntpsec'
|
|
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/ntpsec/ntp.conf
|
|
sonic-cfggen -d -t /usr/share/sonic/templates/ntp.keys.j2 >/etc/ntpsec/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 -N\"/NTPD_OPTS=\"-x -N\"/"
|
|
|
|
systemctl --no-block restart ntp
|