From fc1cb0c203c85b33b2f78696916a7230cb8fe37f Mon Sep 17 00:00:00 2001 From: gpunathilell Date: Tue, 13 Aug 2024 15:47:21 +0000 Subject: [PATCH] Restart NTP only if there is server information present in configuration --- files/image_config/ntp/ntp-config.sh | 11 ++++++++++- files/image_config/ntp/sonic-target.conf | 1 - 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/files/image_config/ntp/ntp-config.sh b/files/image_config/ntp/ntp-config.sh index 13469c58966b..3286baddfc59 100755 --- a/files/image_config/ntp/ntp-config.sh +++ b/files/image_config/ntp/ntp-config.sh @@ -31,4 +31,13 @@ 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 +#Check for NTP_KEYS or NTP_SERVERS in CONFIG_DB +ntp_config=$(redis-cli -n 4 keys *NTP_*) +if [ -n "$ntp_config" ]; then + echo "Server information present in CONFIG_DB, NTP is restarted" + systemctl --no-block restart ntp +else + echo "No server information present in CONFIG_DB, NTP is not restarted" +fi + + diff --git a/files/image_config/ntp/sonic-target.conf b/files/image_config/ntp/sonic-target.conf index 83dd118fe5e9..7f0de350a61d 100644 --- a/files/image_config/ntp/sonic-target.conf +++ b/files/image_config/ntp/sonic-target.conf @@ -1,3 +1,2 @@ [Unit] -BindsTo=sonic.target After=sonic.target