|
21 | 21 | cp "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}" xnodeos/bzImage |
22 | 22 | cp "${config.system.build.kexecScript}" xnodeos/install |
23 | 23 | cp "${pkgs.pkgsStatic.kexec-tools}/bin/kexec" xnodeos/kexec |
| 24 | + cp "${pkgs.pkgsStatic.coreutils}/bin/mkdir" xnodeos/mkdir |
| 25 | + cp "${pkgs.pkgsStatic.findutils}/bin/find" xnodeos/find |
24 | 26 | cp "${pkgs.pkgsStatic.iproute2.override { iptables = null; }}/bin/ip" xnodeos/ip |
| 27 | + cp "${pkgs.pkgsStatic.cpio}/bin/cpio" xnodeos/cpio |
25 | 28 | tar -czvf $out/xnodeos-kexec-installer-${pkgs.stdenv.hostPlatform.system}.tar.gz xnodeos |
26 | 29 | ''; |
27 | 30 |
|
|
31 | 34 | pkgs.writeScript "kexec-boot" '' |
32 | 35 | #!/usr/bin/env bash |
33 | 36 | SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
34 | | - NETWORK_CONFIG="{ \"address\": $(''${SCRIPT_DIR}/ip -j address show), \"route\": $(''${SCRIPT_DIR}/ip -j route show) }" |
35 | | - ''${SCRIPT_DIR}/kexec --load ''${SCRIPT_DIR}/bzImage \ |
36 | | - --initrd=''${SCRIPT_DIR}/initrd \ |
37 | | - --command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} && $(cat << EOF |
| 37 | + cd ''${SCRIPT_DIR} |
38 | 38 |
|
| 39 | + ./mkdir -p ./xnode-config |
| 40 | +
|
| 41 | + NETWORK_CONFIG="{ \"address\": $(./ip --json address show), \"route\": $(./ip --json route show) }" |
| 42 | + cat << EOF > ./xnode-config/env |
39 | 43 | export XNODE_OWNER="''${XNODE_OWNER}" && export DOMAIN="''${DOMAIN}" && export ACME_EMAIL="''${ACME_EMAIL}" && export USER_PASSWD="''${USER_PASSWD}" && export ENCRYPTED="''${ENCRYPTED}" && export NETWORK_CONFIG="''${NETWORK_CONFIG}" && export INITIAL_CONFIG="''${INITIAL_CONFIG}" |
40 | 44 | EOF |
41 | | - )" |
42 | | - ''${SCRIPT_DIR}/kexec -e |
| 45 | +
|
| 46 | + # ./find ./xnode-config -print | ./cpio --format newc --create --file ./initrd --append |
| 47 | +
|
| 48 | + ./kexec --load ./bzImage \ |
| 49 | + --initrd=./initrd \ |
| 50 | + --command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams}" |
| 51 | + ./kexec -e |
43 | 52 | '' |
44 | 53 | ); |
45 | 54 |
|
46 | 55 | systemd.services.install-xnodeos.script = lib.mkBefore '' |
47 | 56 | # Extract environmental variables |
48 | | - sed '2q;d' /proc/cmdline > /tmp/xnode-env |
49 | | - source /tmp/xnode-env |
| 57 | + source /xnode-config/env |
50 | 58 | ''; |
51 | 59 |
|
52 | 60 | systemd.services.apply-network-config = { |
|
66 | 74 | ]; |
67 | 75 | script = '' |
68 | 76 | # Extract environmental variables |
69 | | - sed '2q;d' /proc/cmdline > /tmp/xnode-env |
70 | | - source /tmp/xnode-env |
| 77 | + source /xnode-config/env |
71 | 78 |
|
72 | 79 | if [[ $NETWORK_CONFIG ]]; then |
73 | 80 | interfaces=$(echo "$NETWORK_CONFIG" | jq -c '.address.[]') |
|
0 commit comments