From 84d8727eefc95327ea1dd79f76f4967f0ca4b0dc Mon Sep 17 00:00:00 2001 From: pierreozoux Date: Mon, 12 Jan 2015 23:15:15 +0100 Subject: [PATCH] Fixes nasty bug, where in specific condition, it could erase backup --- unit-files/init@.service | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/unit-files/init@.service b/unit-files/init@.service index e0f796e..c21b524 100644 --- a/unit-files/init@.service +++ b/unit-files/init@.service @@ -1,5 +1,6 @@ [Unit] Description=Initializer +After=network-online.target [Service] Type=oneshot @@ -11,7 +12,12 @@ ExecStartPre=/bin/bash -euxc ' \ git clone $BACKUP_DESTINATION:%i /data/domains/%i; \ cd /data/domains/%i; \ else \ - ssh $BACKUP_DESTINATION "mkdir -p %i;cd %i;git init --bare;"; \ + ssh $BACKUP_DESTINATION " \ + if [ ! -d %i ]; then \ + mkdir -p %i; \ + cd %i; \ + git init --bare; \ + fi"; \ if [ ! -d /data/domains/%i ]; then \ mkdir /data/domains/%i; \ fi; \