about summary refs log tree commit diff stats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/get_dns.sh55
-rwxr-xr-xscripts/system_info.sh25
-rwxr-xr-xscripts/test_build.sh13
-rwxr-xr-xscripts/test_interactive.sh4
4 files changed, 96 insertions, 1 deletions
diff --git a/scripts/get_dns.sh b/scripts/get_dns.sh
new file mode 100755
index 0000000..2d82925
--- /dev/null
+++ b/scripts/get_dns.sh
@@ -0,0 +1,55 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -p dig -p dash -i dash --impure
+# shellcheck shell=dash
+
+get_dns_types() {
+    cat <<EOF
+    A
+    AAAA
+    CAA
+    CNAME
+    DNAME
+    MX
+    NS
+    SOA
+    SRV
+    TXT
+    PTR
+    DNSKEY
+    DS
+    SSHFP
+    TLSA
+    OPENPGPKEY
+    SVCB
+    HTTPS
+EOF
+}
+
+check_type() {
+    domain="$1"
+    type="$2"
+
+    if [ "$(dig +short -t "$type" "$domain" | wc -c)" -ne 0 ]; then
+        dig +short -t "$type" "$domain" | while IFS="$(printf "\n")" read -r output; do
+            printf "(%s) %s [%s]\n" "$type" "$output" "$domain"
+        done
+    else
+        printf "(%s) <Not set> [%s]\n" "$type" "$domain"
+    fi
+}
+
+get_dns() {
+    original_domain="$1"
+
+    get_dns_types | while read -r type; do
+        check_type "$original_domain" "$type"
+    done
+
+    # DKIM
+    check_type "mail._domainkey.$original_domain" "TXT"
+
+    # DMARC
+    check_type "_dmarc.$original_domain" "TXT"
+}
+
+get_dns "$1"
diff --git a/scripts/system_info.sh b/scripts/system_info.sh
new file mode 100755
index 0000000..940406a
--- /dev/null
+++ b/scripts/system_info.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env sh
+
+# Take a host name and return the nix store path to the host's system info.
+# Type
+# _system_info :: String -> Path
+_system_info() {
+    nix --option warn-dirty false build .#nixosConfigurations."$1".config.vhack.system-info.markdown --print-out-paths --no-link
+}
+
+_glow() {
+    if command -v glow >/dev/null; then
+        glow --width 0
+    else
+        cat
+    fi
+}
+
+# The expression is not meant to be expanded by the shell
+# shellcheck disable=SC2016
+nix eval --expr '"${builtins.concatStringsSep "\n" (builtins.attrNames (builtins.fromTOML (builtins.readFile ./hosts/host-names.toml)))}\n"' --impure --raw | while read -r host; do
+    echo "# $host" | _glow
+    _glow <"$(_system_info "$host")"
+done
+
+# vim: ft=sh
diff --git a/scripts/test_build.sh b/scripts/test_build.sh
new file mode 100755
index 0000000..eeb8572
--- /dev/null
+++ b/scripts/test_build.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env sh
+
+[ "$#" -ne 2 ] && {
+    echo "Usage: test_build <TEST_TARGET> <BUILD_NODE>" 1>&2
+    exit 2
+}
+
+test_target="$1"
+build_node="$2"
+
+nix build .#checks.x86_64-linux."$test_target".nodes."$build_node".system.build.toplevel
+
+# vim: ft=sh
diff --git a/scripts/test_interactive.sh b/scripts/test_interactive.sh
index 3b3fe0d..230f5a0 100755
--- a/scripts/test_interactive.sh
+++ b/scripts/test_interactive.sh
@@ -8,7 +8,9 @@ test_target="$1"
     exit 1
 }
 
-nix build .#checks.x86_64-linux."$test_target".driver
+nix build .#checks.x86_64-linux."$test_target".driverInteractive || {
+    exit 1
+}
 
 ./result/bin/nixos-test-driver --interactive