sample-config/deploy.sh

30 lines
1.1 KiB
Bash
Raw Permalink Normal View History

2024-11-23 20:28:47 -08:00
#!/usr/bin/env bash
echo 'Installation steps:'
echo ''
echo ' - Make sure configuration has your SSH key authorized for root so you can change your password, e.g.'
echo ' users.users.root.openssh.authorizedKeys.keys = ['
echo ' "ssh-rsa blahblah"'
echo ' ];'
echo ' - Boot minimal NixOS image on target, e.g. using a USB stick'
echo ' - Do NOT use Ventoy, as it doesnt work on some devices. Use a direct image on a USB stick'
echo ' - On target: Change password with `passwd`'
echo ' - On source: `scp ~/.ssh/authorized_keys nixos@<address>:/home/nixos`'
echo ' - On target: `mkdir -p ~/.ssh; mv ~/authorized_keys ~/.ssh/authorized_keys'
echo ' - Then continue by entering the values below'
echo ''
read -p "Enter IP Address: " ADDRESS
if [[ $ADDRESS =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "IP: ${ADDRESS}"
echo ""
else
echo "Invalid IP Address"
exit
fi
read -p "ARE YOU SURE? This will DESTROY the target (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
NIX_SSHOPTS=-tt nix run github:nix-community/nixos-anywhere -- --flake ../#homefree nixos@$ADDRESS