From d90b97acaff16a751d0b0153dc4a405bfceb462c Mon Sep 17 00:00:00 2001 From: Aki Date: Fri, 19 Jan 2024 23:19:11 +0100 Subject: Created target marking readiness of a net DNS resolver The whole purpose is to have something that can recognize if systemd-resolved is ready, because it complained before it. I was unable to determine better method so here we are. The dependency on host(1) from bind9/named is annoying and writing a simple getaddrinfo(3) checker could be a good step forward. --- Makefile | 19 +++++++++++++++++++ dns-ready-check.service | 12 ++++++++++++ dns-ready.target | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 Makefile create mode 100644 dns-ready-check.service create mode 100644 dns-ready.target diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d26ccb9 --- /dev/null +++ b/Makefile @@ -0,0 +1,19 @@ +DESTDIR= +PREFIX=/usr/local +LIBDIR=$(PREFIX)/lib +SYSDDIR=$(LIBDIR)/systemd/system + + +all: + @echo no-op + + +install: + install -m644 -Dt $(DESTDIR)$(SYSDDIR) dns-ready{-check.service,.target} + + +uninstall: + rm -f $(DESTDIR)$(SYSDDIR)/dns-ready{-check.service,.target} + + +.PHONY: all install uninstall diff --git a/dns-ready-check.service b/dns-ready-check.service new file mode 100644 index 0000000..a945739 --- /dev/null +++ b/dns-ready-check.service @@ -0,0 +1,12 @@ +[Unit] +Description=Check if Domain Name System resolver is ready +DefaultDependencies=no +Requires=network-online.target +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/host example.com +Restart=on-failure +RestartSec=1 +StandardOutput=null diff --git a/dns-ready.target b/dns-ready.target new file mode 100644 index 0000000..44b21c8 --- /dev/null +++ b/dns-ready.target @@ -0,0 +1,4 @@ +[Unit] +Description=Domain Name System resolver is ready +Requires=dns-ready-check.service +After=dns-ready-check.service -- cgit v1.1