Merge ~ltrager/maas:lp1768534_2.3 into maas:2.3

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: 7765de309bdb9f108ba950d256409600e876c3eb
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ltrager/maas:lp1768534_2.3
Merge into: maas:2.3
Diff against target: 53 lines (+20/-6)
1 file modified
src/metadataserver/builtin_scripts/ntp.sh (+20/-6)
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+345150@code.launchpad.net

Commit message

Backport of 8005dd8 LP: #1768534 - Fix NTP test when run with chrony or timesyncd

To post a comment you must log in.
Revision history for this message
Lee Trager (ltrager) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/src/metadataserver/builtin_scripts/ntp.sh b/src/metadataserver/builtin_scripts/ntp.sh
index 879669b..a72e3a9 100644
--- a/src/metadataserver/builtin_scripts/ntp.sh
+++ b/src/metadataserver/builtin_scripts/ntp.sh
@@ -1,4 +1,4 @@
1#!/bin/bash1#!/bin/bash -e
2#2#
3# ntp - Run ntp clock set to verify NTP connectivity.3# ntp - Run ntp clock set to verify NTP connectivity.
4#4#
@@ -35,9 +35,13 @@
3535
36source /etc/os-release36source /etc/os-release
3737
38function has_bin() {
39 which $1 >/dev/null
40 echo $?
41}
42
38if [ $VERSION_ID == "14.04" ]; then43if [ $VERSION_ID == "14.04" ]; then
39 which ntpq >/dev/null44 if [ $(has_bin ntpd) -ne 0 ]; then
40 if [ $? -ne 0 ]; then
41 echo -en 'Warning: NTP configuration is not supported in Trusty. ' 1>&245 echo -en 'Warning: NTP configuration is not supported in Trusty. ' 1>&2
42 echo -en 'Running with the default NTP configuration.\n\n' 1>&246 echo -en 'Running with the default NTP configuration.\n\n' 1>&2
43 sudo -n apt-get install -q -y ntp47 sudo -n apt-get install -q -y ntp
@@ -45,13 +49,23 @@ if [ $VERSION_ID == "14.04" ]; then
45 ntpq -np49 ntpq -np
46 sudo -n service ntp stop50 sudo -n service ntp stop
47 sudo -n timeout 10 ntpd -gq51 sudo -n timeout 10 ntpd -gq
48 ret=$?
49 sudo -n service ntp start52 sudo -n service ntp start
50else53elif [ $(has_bin ntpd) -eq 0 ]; then
54 echo -en 'INFO: ntpd detected.\n\n' 1>&2
51 ntpq -np55 ntpq -np
52 sudo -n systemctl stop ntp.service56 sudo -n systemctl stop ntp.service
53 sudo -n timeout 10 ntpd -gq57 sudo -n timeout 10 ntpd -gq
54 ret=$?58 ret=$?
55 sudo -n systemctl start ntp.service59 sudo -n systemctl start ntp.service
60elif [ $(has_bin chronyc) -eq 0 ]; then
61 echo -en 'INFO: chrony detected.\n\n' 1>&2
62 chronyc status
63 chronyc sources
64elif [ $(has_bin timedatectl) -eq 0 ]; then
65 echo -en 'INFO: timesyncd detected.\n\n' 1>&2
66 timedatectl status
67 sudo -n systemctl status systemd-timesyncd.service
68else
69 echo -en 'ERROR: Unable to detect NTP service!\n\n' 1>&2
70 exit 1
56fi71fi
57exit $ret

Subscribers

People subscribed via source and target branches