From: Oleg Broytman Date: Sun, 4 Aug 2019 18:49:27 +0000 (+0300) Subject: Feat(adjtimex): Convert script `adjtimex.sh` to a template X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=9ab8bc5456fc7a83b9263e6a33e11c0dd1eec7b9;p=ansible.git Feat(adjtimex): Convert script `adjtimex.sh` to a template --- diff --git a/playbooks/debian/roles/adjtimex/tasks/main.yml b/playbooks/debian/roles/adjtimex/tasks/main.yml index 0585334..fb720c7 100644 --- a/playbooks/debian/roles/adjtimex/tasks/main.yml +++ b/playbooks/debian/roles/adjtimex/tasks/main.yml @@ -1,6 +1,7 @@ - name: Copy the script adjtimex.sh - copy: - src: ~/admin/prog/adjtimex.sh + become: true + template: + src: adjtimex.sh dest: /usr/local/sbin/adjtimex.sh owner: root group: root diff --git a/playbooks/debian/roles/adjtimex/templates/adjtimex.sh b/playbooks/debian/roles/adjtimex/templates/adjtimex.sh new file mode 100755 index 0000000..1a4d1c1 --- /dev/null +++ b/playbooks/debian/roles/adjtimex/templates/adjtimex.sh @@ -0,0 +1,15 @@ +#! /bin/sh + +{ echo; echo; } | adjtimex -h {% if inventory_hostname == 'phdru.name' %}nl{% else %}ru{% endif %}.pool.ntp.org && +adjtimex -r --adjust && + +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