machines-config/scripts/update.sh

26 lines
466 B
Bash
Raw Permalink Normal View History

#!/usr/bin/env bash
# Parameters
ip=$1
2025-01-15 23:51:23 +01:00
host=$2
if [ -z "$ip" ] || [ -z "$host" ]; then
echo "Usage: $0 <ip> <host>"
exit 1
fi
# This script is used to bootstrap nixos machine so I can get their ssh keys
nixos-rebuild switch \
--flake ".#$host" \
--fast \
--target-host krop@$ip \
--build-host krop@$ip \
--use-remote-sudo
ret=$?
if [ $ret -ne 0 ]; then
echo "Failed to update $ip"
exit $ret
fi
2025-01-15 23:51:23 +01:00
echo "Successfully updated $ip"