summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-06 11:20:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-10-06 11:21:03 +0000
commit2159c740616f8e1f0aff12788192e4572a48df7c (patch)
tree34e3b8a1fb3d6e536beb2b51e7106c53cb30a247
parentAdding Makefile. (diff)
downloadbfh-tools-2159c740616f8e1f0aff12788192e4572a48df7c.tar.xz
bfh-tools-2159c740616f8e1f0aff12788192e4572a48df7c.zip
Adding dns tools.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--dns/Makefile78
-rwxr-xr-xdns/bin/bfh-dns-clear30
-rwxr-xr-xdns/bin/bfh-list-systems33
3 files changed, 141 insertions, 0 deletions
diff --git a/dns/Makefile b/dns/Makefile
new file mode 100644
index 0000000..41e9755
--- /dev/null
+++ b/dns/Makefile
@@ -0,0 +1,78 @@
+# Copyright (C) 2013-2022 Daniel Baumann <daniel@debian.org>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+SHELL := sh -e
+
+SCRIPTS = bin/*
+
+all: build
+
+test:
+ @echo -n "Checking for syntax errors with sh... "
+ @for SCRIPT in $(SCRIPTS); \
+ do \
+ sh -n $${SCRIPT}; \
+ echo -n "."; \
+ done
+ @echo " done."
+
+ @echo -n "Checking for bashisms... "
+ @if [ -x /usr/bin/checkbashisms ]; \
+ then \
+ for SCRIPT in $(SCRIPTS); \
+ do \
+ checkbashisms -f -x $${SCRIPT}; \
+ echo -n "."; \
+ done; \
+ else \
+ echo "Note: devscripts not installed, skipping checkbashisms."; \
+ fi
+ @echo " done."
+
+ @echo -n "Checking with shellcheck... "
+ @if [ -x /usr/bin/shellcheck ]; \
+ then \
+ for SCRIPT in $(SCRIPTS); \
+ do \
+ shellcheck -e SC2039 $${SCRIPT}; \
+ echo -n "."; \
+ done; \
+ else \
+ echo "Note: shellcheck not installed, skipping shellcheck."; \
+ fi
+ @echo " done."
+
+build:
+
+install: build
+ mkdir -p $(DESTDIR)/usr/bin
+ cp -r bin/* $(DESTDIR)/usr/bin
+
+uninstall:
+ for FILE in bin/*; \
+ do \
+ rm -f $(DESTDIR)/usr/bin/$$(basename $${FILE}); \
+ done
+ rmdir --ignore-fail-on-non-empty --parents $(DESTDIR)/usr/bin || true
+
+ rmdir --ignore-fail-on-non-empty --parents $(DESTDIR) || true
+
+clean:
+
+distclean:
+
+reinstall: uninstall install
diff --git a/dns/bin/bfh-dns-clear b/dns/bin/bfh-dns-clear
new file mode 100755
index 0000000..f8a7c2a
--- /dev/null
+++ b/dns/bin/bfh-dns-clear
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+HOSTS="${*}"
+
+if [ -z "${HOSTS}" ]
+then
+ echo "Usage: ${0} {bfh.info|bfh.ch|HOST}"
+ exit 1
+fi
+
+case "${HOSTS}" in
+ bfh.info)
+ HOSTS="node1.dns.bfh.info node2.dns.bfh.info node3.dns.bfh.info node4.dns.bfh.info"
+ ;;
+
+ bfh.ch)
+ HOSTS="dns1.bfh.ch dns2.bfh.ch dns3.bfh.ch dns4.bfh.ch"
+ ;;
+esac
+
+for HOST in ${HOSTS}
+do
+ echo "################################################################################"
+ echo "# Flushing DNS cache on ${HOST}"
+ echo "################################################################################"
+
+ ssh "${HOST}" sudo kresd-cache-clear
+done
diff --git a/dns/bin/bfh-list-systems b/dns/bin/bfh-list-systems
new file mode 100755
index 0000000..eb50be8
--- /dev/null
+++ b/dns/bin/bfh-list-systems
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# Copyright (C) 2013-2021 Daniel Baumann <daniel@debian.org>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+case "${1}" in
+ network)
+ ssh ssh.bfh.info kdig @ns.bfh.info axfr bfh.network | awk '/IN.*CNAME/ { print $1 }' | sed -e 's|.$||g' | sort -uV
+ ;;
+
+ container-server)
+ ssh ssh.bfh.info kdig @ns.bfh.info axfr bfh.host | awk '/IN.*TXT/ { print $1 }' | sed -e 's|.$||g' | sort -uV
+ ;;
+
+ *)
+ echo "Usage: ${0} {container-server|...}"
+ exit 1
+ ;;
+esac