decided that adding key for further editing should not be handled by the bootstrap process
This commit is contained in:
+32
-12
@@ -58,17 +58,6 @@ function sops_generate_host_age_key() {
|
|||||||
sops updatekeys secrets/*
|
sops updatekeys secrets/*
|
||||||
}
|
}
|
||||||
|
|
||||||
# ---HELPER FUNCTIONS END---
|
|
||||||
|
|
||||||
# Create a temporary directory
|
|
||||||
temp=$(mktemp -d)
|
|
||||||
|
|
||||||
# Function to cleanup temporary directory on exit
|
|
||||||
cleanup() {
|
|
||||||
rm -rf "$temp"
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
function help_and_exit() {
|
function help_and_exit() {
|
||||||
echo
|
echo
|
||||||
echo "Remotely installs NixOS on a target machine using this nix-config."
|
echo "Remotely installs NixOS on a target machine using this nix-config."
|
||||||
@@ -88,6 +77,36 @@ function help_and_exit() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to cleanup temporary directory on exit
|
||||||
|
cleanup() {
|
||||||
|
rm -rf "$temp"
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
await_boot() {
|
||||||
|
local host=$1
|
||||||
|
local user=${2:-root} # default to root if not provided
|
||||||
|
local timeout=${3:-2} # default SSH connect timeout (seconds)
|
||||||
|
|
||||||
|
if [[ -z "$host" ]]; then
|
||||||
|
echo "Usage: await_boot <host> [user] [timeout]"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Waiting for SSH to become available at ${user}@${host}..."
|
||||||
|
|
||||||
|
until ssh -o ConnectTimeout=$timeout -o StrictHostKeyChecking=no -o BatchMode=yes "${user}@${host}" 'exit' 2>/dev/null; do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "SSH is now available at ${user}@${host}."
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---HELPER FUNCTIONS END---
|
||||||
|
|
||||||
|
# Create a temporary directory
|
||||||
|
temp=$(mktemp -d)
|
||||||
|
|
||||||
# Handle command-line arguments
|
# Handle command-line arguments
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@@ -144,4 +163,5 @@ sops_generate_host_age_key "$target_key"
|
|||||||
# Install NixOS to the host system with our secrets
|
# Install NixOS to the host system with our secrets
|
||||||
nix run github:nix-community/nixos-anywhere --extra-experimental-features "nix-command flakes" -- --ssh-port "$ssh_port" --post-kexec-ssh-port "$ssh_port" --extra-files "$temp" --generate-hardware-config nixos-generate-config ./hardware-configuration.nix --disko-mode disko --build-on local --flake .#"$target_hostname" --target-host "$target_user"@"$target_destination"
|
nix run github:nix-community/nixos-anywhere --extra-experimental-features "nix-command flakes" -- --ssh-port "$ssh_port" --post-kexec-ssh-port "$ssh_port" --extra-files "$temp" --generate-hardware-config nixos-generate-config ./hardware-configuration.nix --disko-mode disko --build-on local --flake .#"$target_hostname" --target-host "$target_user"@"$target_destination"
|
||||||
|
|
||||||
echo "Success"
|
echo "\nConfig Successfully Deployed\n"
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
2. Create a sudo password for root ```sudo passwd```
|
2. Create a sudo password for root ```sudo passwd```
|
||||||
3. Get IP address with ```ip addr```
|
3. Get IP address with ```ip addr```
|
||||||
4. From the nixos directory, run the bash script ```bootstrap.sh``` using IP address from step 3 (```./bootstrap.sh -h``` for options)
|
4. From the nixos directory, run the bash script ```bootstrap.sh``` using IP address from step 3 (```./bootstrap.sh -h``` for options)
|
||||||
|
5. If you want to make changes/rebuild the machine from the machine, you'll need to add an ssh key to the user, and then put that public key into github to authorize the server to read from your secrets repository
|
||||||
|
|
||||||
### Random
|
### Random
|
||||||
- Any time the quasiSecret repository is updated, run ```nix flake lock --update-input quasiSecrets``` to ensure you're using the most recent pushed commit
|
- Any time the quasiSecret repository is updated, run ```nix flake lock --update-input quasiSecrets``` to ensure you're using the most recent pushed commit
|
||||||
|
|||||||
Reference in New Issue
Block a user