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
1diff --git a/src/metadataserver/builtin_scripts/ntp.sh b/src/metadataserver/builtin_scripts/ntp.sh
2index 879669b..a72e3a9 100644
3--- a/src/metadataserver/builtin_scripts/ntp.sh
4+++ b/src/metadataserver/builtin_scripts/ntp.sh
5@@ -1,4 +1,4 @@
6-#!/bin/bash
7+#!/bin/bash -e
8 #
9 # ntp - Run ntp clock set to verify NTP connectivity.
10 #
11@@ -35,9 +35,13 @@
12
13 source /etc/os-release
14
15+function has_bin() {
16+ which $1 >/dev/null
17+ echo $?
18+}
19+
20 if [ $VERSION_ID == "14.04" ]; then
21- which ntpq >/dev/null
22- if [ $? -ne 0 ]; then
23+ if [ $(has_bin ntpd) -ne 0 ]; then
24 echo -en 'Warning: NTP configuration is not supported in Trusty. ' 1>&2
25 echo -en 'Running with the default NTP configuration.\n\n' 1>&2
26 sudo -n apt-get install -q -y ntp
27@@ -45,13 +49,23 @@ if [ $VERSION_ID == "14.04" ]; then
28 ntpq -np
29 sudo -n service ntp stop
30 sudo -n timeout 10 ntpd -gq
31- ret=$?
32 sudo -n service ntp start
33-else
34+elif [ $(has_bin ntpd) -eq 0 ]; then
35+ echo -en 'INFO: ntpd detected.\n\n' 1>&2
36 ntpq -np
37 sudo -n systemctl stop ntp.service
38 sudo -n timeout 10 ntpd -gq
39 ret=$?
40 sudo -n systemctl start ntp.service
41+elif [ $(has_bin chronyc) -eq 0 ]; then
42+ echo -en 'INFO: chrony detected.\n\n' 1>&2
43+ chronyc status
44+ chronyc sources
45+elif [ $(has_bin timedatectl) -eq 0 ]; then
46+ echo -en 'INFO: timesyncd detected.\n\n' 1>&2
47+ timedatectl status
48+ sudo -n systemctl status systemd-timesyncd.service
49+else
50+ echo -en 'ERROR: Unable to detect NTP service!\n\n' 1>&2
51+ exit 1
52 fi
53-exit $ret

Subscribers

People subscribed via source and target branches