Script WIP

This commit is contained in:
Joey Hafner 2024-12-31 10:49:33 -08:00
parent 466aac913a
commit 0f53134dba
Signed by: Jafner
GPG Key ID: 6D9A24EF2F389E55

View File

@ -0,0 +1,31 @@
{ pkgs, ... }: {
home.packages = with pkgs; [
( writeShellApplication {
name = "init-keys";
runtimeInputs = [
ssh-to-age
];
text = ''
#!/bin/bash
# Asserts all keys are where they belong.
assert() {
TEST_FILE="$1"
FILE_HASH="$2"
if [ ! -f "$1" ]; then
echo "Error: Missing file $1"
exit 1
fi
TEST_HASH="$(sha256sum "$TEST_FILE" | cut -d' ' -f1)"
if [ ! "$HASH" == "$FILE_HASH" ]; then
echo "Error: File hash mismatch $1"
exit 1
fi
}
'';
} )
];
}