From d1deed435c878b0b04ced778df8687b064d75465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 22 Oct 2024 17:33:04 +0200 Subject: [PATCH] deploy-docs: improve tempdir handling for ssh key --- docs/nix/deploy-docs.nix | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/nix/deploy-docs.nix b/docs/nix/deploy-docs.nix index d02a30e7b..2455f7d9e 100644 --- a/docs/nix/deploy-docs.nix +++ b/docs/nix/deploy-docs.nix @@ -22,11 +22,13 @@ writeShellScriptBin "deploy-docs" '' # DO NOT PRINT THE SSH KEY TO THE LOGS # # # ######################################### - set +x - if [ -n "''${SSH_HOMEPAGE_KEY:-}" ]; then - echo "$SSH_HOMEPAGE_KEY" > ./ssh_key - chmod 600 ./ssh_key - sshExtraArgs="-i ./ssh_key" + tmpdir=$(mktemp -d) + trap "rm -rf $tmpdir" EXIT + + if [ -n "$SSH_HOMEPAGE_KEY" ]; then + echo "$SSH_HOMEPAGE_KEY" > "$tmpdir/ssh_key" + chmod 600 "$tmpdir/ssh_key" + sshExtraArgs="-i $tmpdir/ssh_key" else sshExtraArgs= fi @@ -37,7 +39,6 @@ writeShellScriptBin "deploy-docs" '' # # ########################### - rsync \ -e "ssh -o StrictHostKeyChecking=no $sshExtraArgs" \ -a ${docs}/ \