about summary refs log tree commit diff stats
path: root/scripts
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-09 14:31:45 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-03-09 14:31:45 +0100
commitaaca929782720c266fe21778a55d744101f83a04 (patch)
treedc00329340a4e6e7912e8793d2f14b6b977bb677 /scripts
parenthosts/server2: Use new back config (diff)
downloadnixos-server-aaca929782720c266fe21778a55d744101f83a04.zip
{modules/system-info,scripts/system_info}: Init HEAD main
This collects relevant information for each host in an informative
markdown file.

An example (generated via `./scripts/system_info.sh`):

    # server2

    ## Virtual Hosts

    etebase.vhack.eu: dav.vhack.eu
    gallery.s-schoeffel.de
    git.foss-syndicate.org
    invidious-router.vhack.eu: video.fosswelt.org invidious-router.sils.li
    issues.foss-syndicate.org
    libreddit.vhack.eu
    redlib.vhack.eu
    source.foss-syndicate.org
    source.vhack.eu

    ## Open ports

    TCP 22: ssh
    TCP 25: mail-smtp
    TCP 80: http
    TCP 443: https
    TCP 465: mail-smtp-tls
    TCP 993: mail-imap-tls
    TCP 995: mail-pop3-tls

    # server3

    ## Virtual Hosts

    b-peetz.de
    mastodon.vhack.eu
    matrix.vhack.eu
    miniflux.foss-syndicate.org: rss.foss-syndicate.org rss.vhack.eu miniflux.vhack.eu
    openpgpkey.b-peetz.de
    openpgpkey.s-schoeffel.de
    openpgpkey.sils.li
    openpgpkey.vhack.eu
    peertube.vhack.eu
    trinitrix.vhack.eu
    vhack.eu

    ## Open ports

    TCP 22: ssh
    TCP 80: http
    TCP 443: https
    TCP 64738: ???

    UDP 64738: ???
Diffstat (limited to '')
-rwxr-xr-xscripts/system_info.sh25
1 files changed, 25 insertions, 0 deletions
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