Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ntp] enable/disable NTP long jump according to reboot type #4577

Merged
merged 4 commits into from
May 20, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions files/image_config/ntp/ntp-config.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#!/bin/bash

reboot_type='cold'

function get_databaes_reboot_type()
jleveque marked this conversation as resolved.
Show resolved Hide resolved
{
SYSTEM_WARM_START=`/usr/bin/redis-cli -n 6 hget "WARM_RESTART_ENABLE_TABLE|system" enable`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use sonic-db-cli for multi-db support.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Changed.

SYSTEM_FAST_START=`/usr/bin/redis-cli -n 6 get "FAST_REBOOT|system"`

if [[ x"${SYSTEM_WARM_START}" == x"true" ]]; then
reboot_type='warm'
elif [[ x"${SYSTEM_FAST_START}" == x"1" ]]; then
reboot_type='fast'
fi
}

sonic-cfggen -d -t /usr/share/sonic/templates/ntp.conf.j2 >/etc/ntp.conf

get_databaes_reboot_type
jleveque marked this conversation as resolved.
Show resolved Hide resolved
if [[ x"${reboot_type}" == x"cold" ]]; then
echo "Enabling NTP long jump for reboot type ${reboot_type} ..."
sed -i "s/NTPD_OPTS='-x'/NTPD_OPTS='-g'/" /etc/default/ntp
else
echo "Disabling NTP long jump for reboot type ${reboot_type} ..."
sed -i "s/NTPD_OPTS='-g'/NTPD_OPTS='-x'/" /etc/default/ntp
fi

systemctl restart ntp