A file of its own reads as a script, says what its output looks like and is checked by a new `shellcheck` lint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
37 lines
1.5 KiB
Bash
Executable File
37 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Compares the profile installed on a node with a new one, before approval: read-only, as the SSH
|
|
# user. The arguments are the profile path and the new closure. The output comes in sections, each
|
|
# started by an `@@<name>` line, which `Changes::parse` in `deploy.rs` reads:
|
|
#
|
|
# - `@@packages`: `nix store diff-closures` (only if the profile exists)
|
|
# - `@@boot`: `kernel` and `initrd`, where they change (only if the profile exists)
|
|
# - `@@old`, `@@new`: the `/etc` entries of each, as `<path><TAB><link target or size>`
|
|
old=$1 new=$2
|
|
|
|
if [ -e "$old" ]; then
|
|
echo @@packages
|
|
nix --extra-experimental-features nix-command store diff-closures "$old" "$new" 2>&1 | head -n 500
|
|
|
|
echo @@boot
|
|
for f in kernel initrd; do
|
|
[ -e "$old/$f" ] && [ -e "$new/$f" ] && [ "$(readlink -f "$old/$f")" != "$(readlink -f "$new/$f")" ] && echo "$f"
|
|
done
|
|
fi
|
|
|
|
# /etc entries are links into the store, so a link's target changes with its contents. Units are
|
|
# one link to a directory of them, so that one is followed.
|
|
list() {
|
|
[ -d "$1/etc" ] && cd "$1/etc" || return 0
|
|
find . -path ./systemd/system -prune -o -type l -printf "%p\t%l\n" -o -type f -printf "%p\t%s\n"
|
|
|
|
[ -d systemd/system ] || return 0
|
|
units=$(find -L systemd/system/ -mindepth 1 -maxdepth 2 -type f | LC_ALL=C sort)
|
|
[ -n "$units" ] || return 0
|
|
paste <(printf "%s\n" "$units" | sed "s|^|./|") <(printf "%s\n" "$units" | xargs -d "\n" realpath --)
|
|
}
|
|
|
|
echo @@old
|
|
[ -e "$old" ] && (list "$old")
|
|
echo @@new
|
|
(list "$new")
|