From 1002e5f311ba1711c9929f94031f1ca4734304cf Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 7 Dec 2025 12:33:49 +0100 Subject: [PATCH] fix: only attempt to create file if it doesn't exist yet On self-hosted runners it can happen that an action (docker container) is cached, resulting in aborting this script because the know_hosts file already exists. This if clause fixes it. Setting permissions is intentionally outside the if clause because in all cases we want to reset perms. --- docker-rsync/hosts-init | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-rsync/hosts-init b/docker-rsync/hosts-init index fa4dbe3..0208e08 100755 --- a/docker-rsync/hosts-init +++ b/docker-rsync/hosts-init @@ -2,5 +2,8 @@ set -eu -touch $HOME/.ssh/known_hosts +if [ ! -f "$HOME/.ssh/known_hosts" ]; then + touch $HOME/.ssh/known_hosts +fi + chmod 600 $HOME/.ssh/known_hosts