From e2c8d980f86b420d4540883b470210f3520e8a82 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sat, 26 Jul 2025 18:07:58 +1000 Subject: [PATCH 1/5] chmod -x .gitignore (why is it executable??) --- .gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 .gitignore diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 From c9899c797e3dc086cb1fa68bff659aa9622823aa Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sat, 26 Jul 2025 18:14:04 +1000 Subject: [PATCH 2/5] added script that lists store paths referencing the current nix profile --- scripts/nix-list-installed | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 scripts/nix-list-installed diff --git a/scripts/nix-list-installed b/scripts/nix-list-installed new file mode 100755 index 0000000..5a253b9 --- /dev/null +++ b/scripts/nix-list-installed @@ -0,0 +1,3 @@ +#!/usr/bin/env sh +nix-store -q --references /var/run/current-system/sw \ + | cut -d'-' -f2- From e0174e669c5a609d81164eb3cf7c6dedd0c5a325 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sat, 26 Jul 2025 18:14:35 +1000 Subject: [PATCH 3/5] sisyphus (updated home-manager hash) --- hosts/lolcathost/default.nix | 2 +- hosts/myputer/default.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hosts/lolcathost/default.nix b/hosts/lolcathost/default.nix index a90cfbd..599e295 100755 --- a/hosts/lolcathost/default.nix +++ b/hosts/lolcathost/default.nix @@ -6,7 +6,7 @@ }: let home-manager = builtins.fetchTarball { url = "https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz"; - sha256 = "0z94i2ig7wcm63fp1wkpp6r4458g2bj3r7ijlfapxihqybpgvng5"; + sha256 = "1kk5qzfb87mkgy6vzm7x8z8akxr3k8k7839yjdy48z034pvidhsr"; }; in { imports = [ diff --git a/hosts/myputer/default.nix b/hosts/myputer/default.nix index 1143a0d..bd85eb5 100755 --- a/hosts/myputer/default.nix +++ b/hosts/myputer/default.nix @@ -7,7 +7,7 @@ }: let home-manager = builtins.fetchTarball { url = "https://github.com/nix-community/home-manager/archive/release-24.11.tar.gz"; - sha256 = "0z94i2ig7wcm63fp1wkpp6r4458g2bj3r7ijlfapxihqybpgvng5"; + sha256 = "1kk5qzfb87mkgy6vzm7x8z8akxr3k8k7839yjdy48z034pvidhsr"; }; in { imports = [ From 9fd929ae7bb54eef9a1f49c9c127ae22a5cce1f3 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sat, 26 Jul 2025 18:17:51 +1000 Subject: [PATCH 4/5] add extendable script to test hyrule's critical systemd services --- scripts/testvps | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/testvps diff --git a/scripts/testvps b/scripts/testvps new file mode 100755 index 0000000..4382b7d --- /dev/null +++ b/scripts/testvps @@ -0,0 +1,82 @@ +#!/usr/bin/env bash +# Requires: systemctl + +set -u + +function match { + [[ "$1" =~ $2 ]] +} + +function padlen { + local MAX=0 + for KEY in "$@"; do + local LEN=${#KEY} + ((LEN > MAX)) && MAX=$LEN + done + echo $MAX +} + +function pad { + local PAD="$1" + if [ -z "$PAD" ]; then + exit 1 + fi + + for ((i=0; i/dev/null) + if [ -z "$STAT" ]; then + fmt_print "$SERVICE" "$LPAD" "NOTFOUND" + exit 1 + fi + + local STAT_LOADED=$(head -n2 <<< "$STAT" | tail -n1) + # NOTE: "active " intentionally contains right padding + local ENABLED=$(match "$STAT_LOADED" "^\s*Loaded: loaded \(.*; enabled; .*\)" && echo "enabled" || echo "disabled") + local ACTIVE=$(match "$STAT" "\s*Active: active \(running\)" && echo "active " || echo "inactive") + fmt_print "$SERVICE" "$LPAD" "$ACTIVE" "$ENABLED" +) + +function test_services { + local PAD_ALIGN=$(padlen $@) + # fmt_test_service + for SERVICE in "$@"; do + local LPAD=$((PAD_ALIGN - ${#SERVICE})) + fmt_test_service "$SERVICE" $LPAD + done +} + +test_services nginx forgejo vaultwarden From 65d6c36c3e97df1be92b5b9e86d4334e5a2c9326 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Sat, 26 Jul 2025 18:18:15 +1000 Subject: [PATCH 5/5] add script to run command and temp open a port --- scripts/openport | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 scripts/openport diff --git a/scripts/openport b/scripts/openport new file mode 100755 index 0000000..dd6222f --- /dev/null +++ b/scripts/openport @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Credit: u/boxofrox https://discourse.nixos.org/u/boxofrox +# Ref: https://discourse.nixos.org/t/how-to-temporarily-open-a-tcp-port-in-nixos/12306/3 +USAGE="[Usage] sudo withport " + +set -ueo pipefail + +open-port() { + local port=$1 + iptables -A INPUT -p tcp --dport $port -j ACCEPT +} + +close-port() { + local port=${1:-0} + iptables -D INPUT -p tcp --dport $port -j ACCEPT +} + +PORT=$1 +if [[ -z "$PORT" ]]; then + echo -e "[!] Port not given\n$USAGE" >&2 + exit 1 +fi +shift; # Drop port argument + +if [[ 0 -eq $# ]]; then + echo -e "[!] Command not given\n$USAGE" >&2 + exit 1 +fi + +open-port $PORT +# Ensure port closes if error occurs. +trap "close-port $PORT" EXIT +# Run the command as user, not root. +runuser -u $SUDO_USER -- "$@" +# Trap will close port.