#!/bin/bash # Build dns-monitor, check config.toml against live DNS, then install and restart the service. # Aborts before touching the running service if the build, tests or config check fail. set -euo pipefail cd "$(dirname "$(readlink -f "$0")")" . "$HOME/.cargo/env" cargo test -q cargo build --release -q # Parse the config and print the DNS changes it would make, without making them. ( set -a; . /etc/dns-monitor/env; set +a ./target/release/dns-monitor --config config.toml --once --dry-run ) install -m755 target/release/dns-monitor /usr/local/bin/dns-monitor install -m644 dns-monitor.service /etc/systemd/system/dns-monitor.service ln -sfn "$PWD/config.toml" /etc/dns-monitor/config.toml systemctl daemon-reload systemctl enable -q dns-monitor systemctl restart dns-monitor systemctl is-active dns-monitor