Installation script enchansements

master
Illia Chub 2020-09-14 10:53:57 +03:00
parent e31c7ae8cd
commit 30171b8d5a
2 changed files with 14 additions and 4 deletions

View File

@ -11,10 +11,10 @@
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
User = "restic"; 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 = '' 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
''; '';
}; };
}; };

View File

@ -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 # Create records
CreateARecord() 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 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" 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() PerformTests()
@ -321,9 +329,11 @@ then
exit -1 exit -1
fi fi
printf "Purging records..." printf "Purging records..."
GetZoneID
PurgeDNSRecords PurgeDNSRecords
printf "done" printf "done"
CreateARecord CreateARecord
WaitDNSPropagation
ApplyConfig ApplyConfig
if [ $RESTORE_MAILBACKUP == "y" ] if [ $RESTORE_MAILBACKUP == "y" ]
then then