]> git.phdru.name Git - ansible.git/blobdiff - playbooks/roles/adjtimex/templates/adjtimex.sh
Feat(adjtimex): Use `hwclock --update-drift`
[ansible.git] / playbooks / roles / adjtimex / templates / adjtimex.sh
index 1a4d1c159de52947be957cd07e9d753fe584d788..8721907b97381c5446af6d90fd64025c5cb1dfa2 100755 (executable)
@@ -1,15 +1,34 @@
 #! /bin/sh
 
-{ echo; echo; } | adjtimex -h {% if inventory_hostname == 'phdru.name' %}nl{% else %}ru{% endif %}.pool.ntp.org &&
+# Stole some ideas from
+# http://support.ntp.org/bin/view/Support/ManualCalibration
+
+# Warm up DNS
+host -t ns pool.ntp.org
+host pool.ntp.org
+{% if ansible_facts.os_family == 'Debian' %}
+host 0.debian.pool.ntp.org
+host 1.debian.pool.ntp.org
+host 2.debian.pool.ntp.org
+host 3.debian.pool.ntp.org
+{% endif %}
+
+{ echo; echo; } | adjtimex -l &&
+ntpdate{% if ansible_facts.os_family == 'Debian' %}-debian{% endif %} &&
+{ echo; echo; } | adjtimex -l &&
+
+hwclock --systohc --update-drift &&
+{ echo; echo; } | adjtimex -l &&
+hwclock --hctosys &&
+
+{ echo; echo; } | adjtimex -l &&
 adjtimex -r --adjust &&
+{ echo; echo; } | adjtimex -l &&
 
 freq=`adjtimex -p | awk '/frequency:/ {print $2}'` &&
 tick=`adjtimex -p | awk '/tick:/ {print $2}'` &&
 #adjtimex -f "$freq" -t "$tick" &&
 
-sed -i "s/^FREQ=.\+$/FREQ=$freq/" /etc/default/adjtimex &&
-sed -i "s/^TICK=.\+$/TICK=$tick/" /etc/default/adjtimex &&
-
-ntpdate-debian &&
-hwclock --systohc &&
-{ echo; echo; } | adjtimex -h ru.pool.ntp.org
+tail -2 /etc/default/adjtimex &&
+sed -i -e "s/^FREQ=.\+$/FREQ=$freq/" -e "s/^TICK=.\+$/TICK=$tick/" /etc/default/adjtimex &&
+exec tail -2 /etc/default/adjtimex