make sure source is available before deleting config

This commit is contained in:
echtnurich 2024-08-08 20:11:42 +02:00
parent c9967f73c0
commit c62f722899
Signed by: echtnurich
SSH key fingerprint: SHA256:1eIkxME0VPeXC2WMl9Haus+q0SLFymSAWU7f6Z+A8Aw

View file

@ -34,13 +34,18 @@
wantedBy = [ "default.target" ];
requiredBy = [ "network.target" ];
preStart = "echo \"\n\" >> /run/secrets/git_clone_key
sleep 1
SSH_SUCCESS=1
${pkgs.openssh}/bin/ssh -q -i /run/secrets/git_clone_key forgejo@git.hamburg.ccc.de || SSH_SUCCESS=0
if [ $SSH_SUCCESS = 1 ]; then
rm -rf /var/lib/yate/*
rm -rf /var/lib/yate/.*
${pkgs.git}/bin/git init /var/lib/yate
${pkgs.git}/bin/git -C /var/lib/yate config --add safe.directory \"/var/lib/yate\"
${pkgs.git}/bin/git -C /var/lib/yate remote add origin forgejo@git.hamburg.ccc.de:echtnurich/yate-config.git
env GIT_SSH_COMMAND=\"${pkgs.openssh}/bin/ssh -i /run/secrets/git_clone_key\" ${pkgs.git}/bin/git -C /var/lib/yate fetch --all
${pkgs.git}/bin/git -C /var/lib/yate checkout --track -f origin/master";
${pkgs.git}/bin/git -C /var/lib/yate checkout --track -f origin/master
fi";
# ...
};