From 31bee430fb2848e39cd98f8273f1ba9a2efe84e4 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 14 Dec 2019 18:02:52 +0300 Subject: [PATCH] Fix(adjtimex): Call `adjtimex` without `-h` In debian 10 `adjtimex` is buggy (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=944867) so we have to run it without `-h`. Ok, `adjtimex -l` + `ntpdate` + `hwclock` is enough. Fix Debian package name. --- playbooks/roles/adjtimex/tasks/main.yml | 2 +- .../roles/adjtimex/templates/adjtimex.sh | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/playbooks/roles/adjtimex/tasks/main.yml b/playbooks/roles/adjtimex/tasks/main.yml index a7864a8..ba1f744 100644 --- a/playbooks/roles/adjtimex/tasks/main.yml +++ b/playbooks/roles/adjtimex/tasks/main.yml @@ -5,7 +5,7 @@ autoremove: yes cache_valid_time: 3600 install_recommends: no - name: ['adjtimex', 'ntpdate-debian'] + name: ['adjtimex', 'ntpdate'] state: latest update_cache: yes when: ansible_facts.os_family == 'Debian' diff --git a/playbooks/roles/adjtimex/templates/adjtimex.sh b/playbooks/roles/adjtimex/templates/adjtimex.sh index 98e1135..4ee2a4b 100755 --- a/playbooks/roles/adjtimex/templates/adjtimex.sh +++ b/playbooks/roles/adjtimex/templates/adjtimex.sh @@ -1,15 +1,24 @@ #! /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 + +{ echo; echo; } | adjtimex -l && +ntpdate{% if ansible_facts.os_family == 'Debian' %}-debian{% endif %} && +{ echo; echo; } | adjtimex -l && + +hwclock --systohc && +{ 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{% if ansible_facts.os_family == 'Debian' %}-debian{% endif %} && -hwclock --systohc && -{ echo; echo; } | adjtimex -h {% if inventory_hostname == 'phdru.name' %}nl{% else %}ru{% endif %}.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 -- 2.39.5