Merge pull request #144 from nix-community/machine-id
also copy machine-id into installer
This commit is contained in:
commit
fc531304e2
3 changed files with 10 additions and 1 deletions
|
@ -58,5 +58,8 @@
|
||||||
fi
|
fi
|
||||||
install -m 400 ssh/ssh_host_* /mnt-root/etc/ssh
|
install -m 400 ssh/ssh_host_* /mnt-root/etc/ssh
|
||||||
cp *.json /mnt-root/root/network/
|
cp *.json /mnt-root/root/network/
|
||||||
|
if [[ -f machine-id ]]; then
|
||||||
|
cp machine-id /mnt-root/etc/machine-id
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,8 @@ done
|
||||||
"$SCRIPT_DIR/ip" -4 --json route > routes-v4.json
|
"$SCRIPT_DIR/ip" -4 --json route > routes-v4.json
|
||||||
"$SCRIPT_DIR/ip" -6 --json route > routes-v6.json
|
"$SCRIPT_DIR/ip" -6 --json route > routes-v6.json
|
||||||
|
|
||||||
|
[ -f /etc/machine-id ] && cp /etc/machine-id machine-id
|
||||||
|
|
||||||
find . | cpio -o -H newc | gzip -9 >> "$SCRIPT_DIR/initrd"
|
find . | cpio -o -H newc | gzip -9 >> "$SCRIPT_DIR/initrd"
|
||||||
|
|
||||||
if ! "$SCRIPT_DIR/kexec" --load "$SCRIPT_DIR/bzImage" \
|
if ! "$SCRIPT_DIR/kexec" --load "$SCRIPT_DIR/bzImage" \
|
||||||
|
|
|
@ -101,7 +101,7 @@ makeTest' {
|
||||||
node1.succeed("ip -6 route >&2")
|
node1.succeed("ip -6 route >&2")
|
||||||
node1.succeed("networkctl status eth0 >&2")
|
node1.succeed("networkctl status eth0 >&2")
|
||||||
|
|
||||||
def ssh(cmd: list[str], check: bool = True, stdout: Optional[int] = None) -> subprocess.CompletedProcess:
|
def ssh(cmd: list[str], check: bool = True, stdout: Optional[int] = None) -> subprocess.CompletedProcess[str]:
|
||||||
ssh_cmd = [
|
ssh_cmd = [
|
||||||
"${pkgs.openssh}/bin/ssh",
|
"${pkgs.openssh}/bin/ssh",
|
||||||
"-o", "StrictHostKeyChecking=no",
|
"-o", "StrictHostKeyChecking=no",
|
||||||
|
@ -128,6 +128,7 @@ makeTest' {
|
||||||
|
|
||||||
# Kexec node1 to the toplevel of node2 via the kexec-boot script
|
# Kexec node1 to the toplevel of node2 via the kexec-boot script
|
||||||
node1.succeed('touch /run/foo')
|
node1.succeed('touch /run/foo')
|
||||||
|
old_machine_id = node1.succeed("cat /etc/machine-id").strip()
|
||||||
node1.fail('parted --version >&2')
|
node1.fail('parted --version >&2')
|
||||||
node1.succeed('tar -xf ${kexecTarball}/nixos-kexec-installer-noninteractive-${pkgs.system}.tar.gz -C /root')
|
node1.succeed('tar -xf ${kexecTarball}/nixos-kexec-installer-noninteractive-${pkgs.system}.tar.gz -C /root')
|
||||||
node1.succeed('/root/kexec/ip -V >&2')
|
node1.succeed('/root/kexec/ip -V >&2')
|
||||||
|
@ -153,6 +154,9 @@ makeTest' {
|
||||||
print(ssh(["ip", "-6", "route"]))
|
print(ssh(["ip", "-6", "route"]))
|
||||||
print(ssh(["networkctl", "status"]))
|
print(ssh(["networkctl", "status"]))
|
||||||
|
|
||||||
|
new_machine_id = ssh(["cat", "/etc/machine-id"], stdout=subprocess.PIPE).stdout.strip()
|
||||||
|
assert old_machine_id == new_machine_id, f"{old_machine_id} != {new_machine_id}, machine-id changed"
|
||||||
|
|
||||||
assert ssh(["ls", "-la", "/run/foo"], check=False).returncode != 0, "kexeced node1 still has /run/foo"
|
assert ssh(["ls", "-la", "/run/foo"], check=False).returncode != 0, "kexeced node1 still has /run/foo"
|
||||||
print(ssh(["parted", "--version"]))
|
print(ssh(["parted", "--version"]))
|
||||||
host = ssh(["hostname"], stdout=subprocess.PIPE).stdout.strip()
|
host = ssh(["hostname"], stdout=subprocess.PIPE).stdout.strip()
|
||||||
|
|
Loading…
Reference in a new issue