diff --git a/nix/pkgs/openwrt/default.nix b/nix/pkgs/openwrt/default.nix index d02d110..5c43cec 100644 --- a/nix/pkgs/openwrt/default.nix +++ b/nix/pkgs/openwrt/default.nix @@ -11,26 +11,21 @@ let "kmod-ath10k" "ath10k-firmware-qca988x" ]; }; -in -{ - sshScript = hostName: '' - #! ${pkgs.runtimeShell} -e +in rec { + sshScript = hostName: + let + address = config.site.net.mgmt.hosts4.${hostName}; + in '' + #! ${pkgs.runtimeShell} -e - ${if config.site.hosts.${hostName}.firstboot - then '' - ssh-keygen -R 192.168.1.1 - ssh root@192.168.1.1 \ - "ash -e -x" <<__SSH__ - '' else '' - ssh root@${config.site.net.mgmt.hosts4.${hostName}} \ - "ash -e -x" <<__SSH__ - ${uciConfig hostName} - __SSH__ + ssh root@${address} "cat > /tmp/openwrt-image" < ${buildImage hostName}/openwrt-*-${hostName}-*-sysupgrade.bin + ssh root@${address} "sysupgrade -n /tmp/openwrt-image" - echo "Base configuration done \\o/" - echo "Later run: ap_install_collectd.sh ${config.site.net.mgmt.hosts4.${hostName}}" - ''} - ''; + # ssh hostkey will have changed after boot + ssh-keygen -R ${address} + + /run/wrappers/bin/ping ${address} + ''; buildImage = hostName: let