From 30171b8d5aea912a1f4428160305279a664b0787 Mon Sep 17 00:00:00 2001 From: Illia Chub Date: Mon, 14 Sep 2020 10:53:57 +0300 Subject: [PATCH] Installation script enchansements --- static/restic.nix | 4 ++-- static/server.sh | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/static/restic.nix b/static/restic.nix index c0521a7..a068d16 100644 --- a/static/restic.nix +++ b/static/restic.nix @@ -11,10 +11,10 @@ serviceConfig = { Type = "oneshot"; User = "restic"; - Environment = [ "AWS_ACCESS_KEY_ID=AKIAJOVDNQ6FERMIDHKA" "AWS_SECRET_ACCESS_KEY=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" ]; + Environment = [ "AWS_ACCESS_KEY_ID=" "AWS_SECRET_ACCESS_KEY=" ]; }; script = '' - restic -r s3:s3.amazonaws.com/haep9c-backup backup /var/vmail /var/vmail + restic -r s3:s3.amazonaws.com/ backup /var/vmail /var/vmail ''; }; }; diff --git a/static/server.sh b/static/server.sh index c2c2771..b662346 100644 --- a/static/server.sh +++ b/static/server.sh @@ -218,6 +218,16 @@ done } +WaitDNSPropagation() +{ + printf "Waiting for DNS Record to propagate..." + while [[ $( dig A +short ilchub.net ) != $machineip ]] + do + sleep 1 + done + printf "done" +} + # Create records CreateARecord() { @@ -262,8 +272,6 @@ PostInstallation() { ssh -i ~/.nix-ms/id_rsa "root@$machineip" restic -r s3:s3.amazonaws.com/$AWS_BUCKET_NAME init ssh -i ~/.nix-ms/id_rsa "root@$machineip" restic -r s3:s3.amazonaws.com/$AWS_BUCKET_NAME forget --prune --keep-hourly 2 --keep-daily 7 --keep-weekly 4 - #ssh -i ~/.nix-ms/id_rsa "root@$machineip" cp /root/result/bin/goss /root/ - #ssh -i ~/.nix-ms/id_rsa "root@$machineip" /root/goss serve --format json & } PerformTests() @@ -321,9 +329,11 @@ then exit -1 fi printf "Purging records..." +GetZoneID PurgeDNSRecords printf "done" CreateARecord +WaitDNSPropagation ApplyConfig if [ $RESTORE_MAILBACKUP == "y" ] then