diff --git a/configuration/closed-install.nix b/configuration/closed-install.nix index 2a1f1c89ab79..db02ddd4d8cb 100644 --- a/configuration/closed-install.nix +++ b/configuration/closed-install.nix @@ -1,4 +1,7 @@ -{platform ? __currentSystem} : +{ + platform ? __currentSystem + ,hostConnectPort ? "3737" +} : let isoFun = import ./rescue-cd-configurable.nix; in @@ -33,6 +36,7 @@ in pkgs.wpa_supplicant pkgs.emacs pkgs.vimHugeX + pkgs.socat ]; /* @@ -48,4 +52,17 @@ in target = "/root/.ssh/authorized_keys"; } ]; + + additionalJobs = [ + { + name = "Socat-ssh-proxy"; + job = '' + start on sshd/started + script + sleep 5 + /var/run/current-system/sw/bin/socat tcp:10.0.2.2:${hostConnectPort} tcp:127.0.0.1:22 + end script + ''; + } + ]; }).rescueCD diff --git a/configuration/remote-install-scripts/install-script.sh b/configuration/remote-install-scripts/install-script.sh index 2c1d116533af..b6becd432f8d 100755 --- a/configuration/remote-install-scripts/install-script.sh +++ b/configuration/remote-install-scripts/install-script.sh @@ -39,15 +39,45 @@ cat > /mnt/etc/nixos/configuration.nix </dev/null; do + sleep 1; + done + echo -e "Installation finished\nOK" | /var/run/current-system/sw/bin/socat stdio tcp:10.0.2.2:4424 | { + read; + if [ "\\\$REPLY" = "reboot" ] ; then + /var/run/current-system/sw/sbin/start ctrl-alt-delete; + fi; + } + end script + ''; + } + ]; }; fonts = { enableFontConfig = false; }; + environment = { + extraPackages = pkgs: [ + pkgs.socat + ]; + }; } EOF nixos-install +echo Installation finished + +start ctrl-alt-delete + diff --git a/configuration/remote-install-scripts/install-start.sh b/configuration/remote-install-scripts/install-start.sh index 6deb806cfd05..a8cb4baa422d 100755 --- a/configuration/remote-install-scripts/install-start.sh +++ b/configuration/remote-install-scripts/install-start.sh @@ -2,6 +2,10 @@ nohup bash -c 'NIX_REMOTE= ./install-script.sh &>/dev/tty11' & +sleep 1; + +chvt 11 || true; + disown exit diff --git a/configuration/remote-install-scripts/install-test.sh b/configuration/remote-install-scripts/install-test.sh new file mode 100755 index 000000000000..0d7d553a81a8 --- /dev/null +++ b/configuration/remote-install-scripts/install-test.sh @@ -0,0 +1,69 @@ +#! /bin/sh -i + +if test -z "$INSTALL_TEST_RUNNING" ; then + export INSTALL_TEST_RUNNING=1; + export ORIGINAL_NAME="$0"; + sh -i < "$ORIGINAL_NAME"; + exit; +fi; + +if ! eval ' ( sleep 0.1; exit 0; ) & fg ' ; then + echo "Failing job control test"; + exit; +fi; + +set -x + +echo "Installation starting.." > report + +nix-build -o socat /etc/nixos/nixpkgs -A socat +nix-build -o qemu /etc/nixos/nixpkgs -A qemu + +echo "reboot" | ./socat/bin/socat tcp-listen:4424 stdio >> report & + +if ( ! [ -d dvd/iso ] ) || ( [ -z "$USE_LEFTOVER_DVD" ] ); then + rm dvd + nix-build -o dvd /etc/nixos/nixos/configuration/closed-install.nix +fi; + +if ( ! [ -f install-test.img ] ) || ( [ -z "$JUST_BOOT" ] ); then + rm install-test.img + ./qemu/bin/qemu-img create -f qcow2 install-test.img 5G + + ./qemu/bin/qemu --kernel-kqemu -m 512 -cdrom dvd/iso/nixos-*.iso -hda install-test.img -boot d -no-reboot & + ./socat/bin/socat tcp-listen:4425 tcp-listen:3737 & + sleep 1; + + sed -e '/^127[.]0[.]0[.]1/d; /^\[127[.]0[.]0[.]1/d' -i ~/.ssh/known_hosts || true; + + ( + echo "cat > install-script.sh < install-start.sh <