installer: wait for onion hostname to be available

This commit is contained in:
lassulus
2023-07-24 11:31:52 +02:00
parent d99060695f
commit 930f1660e9
2 changed files with 18 additions and 9 deletions

View File

@@ -7,18 +7,21 @@
];
services.openssh.settings.PermitRootLogin = "yes";
system.activationScripts.root-password = ''
mkdir -p /var/shared
${pkgs.pwgen}/bin/pwgen -s 16 1 > /var/shared/root-password
echo "root:$(cat /var/shared/root-password)" | chpasswd
'';
hidden-announce = {
enable = true;
script = pkgs.writers.writeDash "write-hostname" ''
mkdir -p /var/shared
echo "$1" > /var/shared/onion-hostname
'';
};
services.getty.autologinUser = lib.mkForce "root";
programs.bash.interactiveShellInit = ''
if [ "$(tty)" = "/dev/tty1" ]; then
until test -e /var/shared/onion-hostname; do sleep 1; done
echo "ssh://root:$(cat /var/shared/root-password)@$(cat /var/shared/onion-hostname)"
fi
'';