new script to run nix-anywhere on a victim
This commit is contained in:
parent
af5a52aed3
commit
005382f7a3
1 changed files with 34 additions and 0 deletions
34
deploy-host
Executable file
34
deploy-host
Executable file
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -o errexit
|
||||
set -o errtrace
|
||||
set -o nounset
|
||||
|
||||
debug=echo
|
||||
|
||||
if [ "x" == "x$2" ]
|
||||
then
|
||||
echo "usage: $0 <ip> <host>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nixanywhere=~/src/nixos/nixos-anywhere-examples
|
||||
nixsrc=~/src/nixos/duckland
|
||||
ip="${1}"
|
||||
host="${2}"
|
||||
|
||||
if [ ! -f "${nixsrc}/hosts/${host}/default.nix" ]
|
||||
then
|
||||
echo "Please set up ${nixsrc}/hosts/${host}/default.nix before running"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "${nixanywhere}"
|
||||
${debug} ssh-keygen -R "${ip}"
|
||||
${debug} nix run github:nix-community/nixos-anywhere -- --flake .#${host} root@"${ip}"
|
||||
cd "${nixsrc}"
|
||||
${debug} ssh-keygen -R "${ip}"
|
||||
${debug} ssh root@"${ip}" nixos-generate-config
|
||||
${debug} scp root@"${ip}":/etc/nixos/hardware-configuration.nix hosts/${host}/hardware-configuration.nix
|
||||
${debug} git add hosts/${host}/hardware-configuration.nix
|
||||
${debug} nixos-rebuild switch --flake .#${host} --target-host "root@"${ip}""
|
||||
Loading…
Add table
Add a link
Reference in a new issue