#!/bin/bash set -e [[ -z $1 ]] && echo country_code? && exit 1 country_code=$1 [[ ! -x `which systemctl` ]] && echo error: systemctl executable not found && exit 1 export DEBIAN_FRONTEND=noninteractive export SYSTEMD_COLORS=0 export SYSTEMD_URLIFY=0 export LANG=en_US.UTF-8 export LANGUAGE=en_US:en export LC_ALL=en_US.UTF-8 # strangely enough, pgrep finds systemd-time but not systemd-timesyncd echo -n "is some ntpd running? " tmp=`pgrep -a ntpd | head -1; pgrep -a systemd-time | head -1; pgrep -a chronyd | head -1` || true if [[ -n $tmp ]]; then echo $tmp else echo no fi echo -n checking for openntpd ... if dpkg -s openntpd >/dev/null 2>&1; then echo already there else echo missing # disable legacy ntp no matter what systemctl stop ntp >/dev/null 2>&1 || true systemctl disable ntp >/dev/null 2>&1 || true echo -n update package cache \(/var/tmp/debian-time.log\) ... apt-get -q -y update > /var/tmp/debian-time.log 2>&1 && echo done || echo FAIL echo '' >> /var/tmp/debian-time.log echo -n purge legacy ntp tools \(/var/tmp/debian-time.log\) ... apt-get -q -y purge ntp ntpdate ntpsec ntpsec-ntpdate ntpsec-ntpdig python3-ntp \ >> /var/tmp/debian-time.log 2>&1 && echo done || echo FAIL echo '' >> /var/tmp/debian-time.log echo -n install openntpd \(/var/tmp/debian-time.log\) ... apt-get -q -y install openntpd >> /var/tmp/debian-time.log 2>&1 && echo done || echo FAIL echo '' >> /var/tmp/debian-time.log mv -f /etc/openntpd/ntpd.conf /etc/openntpd/ntpd.conf.dist grep -vE '^#|^$' /etc/openntpd/ntpd.conf.dist > /etc/openntpd/ntpd.conf.clean grep -vE '^#|^$' /etc/openntpd/ntpd.conf.dist > /etc/openntpd/ntpd.conf changed=1 fi (( changed == 1 )) && echo changed - all done && exit 0 echo all done - nothing changed