#!/bin/sh

# If we didn't get a name, comment out the NTP line.
if test -z "$1"; then
    # Comment the line.
    sed -i -e '/^NTP=/s/^/#/' /etc/systemd/timesyncd.conf
else
    # Uncomment the line, if it's commented.
    sed -i -e '/#NTP=/s/^#//' /etc/systemd/timesyncd.conf

    # Replace the old server with the new.
    sed -i -e 's/^NTP=[A-Za-x0-9\.]*$/NTP='"$1"'/' /etc/systemd/timesyncd.conf
fi

# Restart time synchronization.
systemctl restart systemd-timesyncd.service 
