From 49ed478edc083618b5bde047bb055d9f1fb77bae Mon Sep 17 00:00:00 2001
From: pierreozoux <pierre@ozoux.net>
Date: Fri, 16 Jan 2015 17:13:33 +0100
Subject: [PATCH] Hotfixes backup and DRY

---
 .../2015-01-16-moves-backup-to-duplicity.sh   | 29 ++++++++++
 hotfixes/2015-01-16-ultimate-DRY.sh           | 55 +++++++++++++++++++
 2 files changed, 84 insertions(+)
 create mode 100644 hotfixes/2015-01-16-moves-backup-to-duplicity.sh
 create mode 100644 hotfixes/2015-01-16-ultimate-DRY.sh

diff --git a/hotfixes/2015-01-16-moves-backup-to-duplicity.sh b/hotfixes/2015-01-16-moves-backup-to-duplicity.sh
new file mode 100644
index 0000000..56d4cfa
--- /dev/null
+++ b/hotfixes/2015-01-16-moves-backup-to-duplicity.sh
@@ -0,0 +1,29 @@
+# START
+docker pull pierreozoux/duplicity
+
+gpg --gen-key
+gpg --list-keys
+
+echo ENCRYPT_KEY="" >> /etc/environment
+echo BACKUP_DESTINATION="backup@backup" >> /etc/environment
+
+cd /data/indiehosters
+git pull
+cp /data/indiehosters/unit-files/* /etc/systemd/system && sudo systemctl daemon-reload
+
+for domain in "${domains[@]}"
+do
+  systemctl start backup@$domain
+  systemctl status backup@$domain
+done
+
+# STOP
+
+# CLEAN START
+rm -rf /data/import
+rm /data/BACKUP_DESTINATION
+su backup
+cd
+mkdir old_backups
+mv ./* old_backups
+# CLEAN STOP
diff --git a/hotfixes/2015-01-16-ultimate-DRY.sh b/hotfixes/2015-01-16-ultimate-DRY.sh
new file mode 100644
index 0000000..dc87a55
--- /dev/null
+++ b/hotfixes/2015-01-16-ultimate-DRY.sh
@@ -0,0 +1,55 @@
+static_domains=( domain1 domain2 )
+wordpress_domains=( domain1 domain2 )
+
+# START
+cd /data/indiehosters
+git pull
+cp /data/indiehosters/unit-files/* /etc/systemd/system && sudo systemctl daemon-reload
+docker pull pierreozoux/wordpress
+
+for domain in "${static_domains[@]}"
+do
+  folder=/data/domains/${domain}
+  echo "EMAIL=test@test.org" > ${folder}/.env
+  echo "APPLICATION=nginx"  >> ${folder}/.env
+  echo DOCKER_ARGUMENTS="-v ${folder}/static/www-content:/app" >> ${folder}/.env
+  systemctl restart static@$domain
+  systemctl status static@$domain
+  systemctl status web@$domain
+done  
+
+for domain in "${wordpress_domains[@]}"
+do
+  folder=/data/domains/${domain}
+  echo "EMAIL=test@test.org" > ${folder}/.env
+  echo "APPLICATION=wordpress"  >> ${folder}/.env
+  echo DOCKER_ARGUMENTS="--link mysql-${domain}:db \
+-v /data/domains/${domain}/wordpress/data:/app/wp-content \
+-v /data/domains/${domain}/wordpress/.htaccess:/app/.htaccess \
+--env-file /data/domains/${domain}/wordpress/.env" >> ${folder}/.env
+  systemctl restart lamp@$domain
+  systemctl status lamp@$domain
+  systemctl status web@$domain
+done  
+
+# STOP
+
+# ROLLBACK START
+cd /data/indiehosters
+git checkout 65d6486005e3d96e3ad9d5ab17f99d8910cc5e70 
+cp /data/indiehosters/unit-files/* /etc/systemd/system && sudo systemctl daemon-reload
+cd dockerfiles/services/wordpress/
+docker build -t pierreozoux/wordpress .
+
+for domain in "${wordpress_domains[@]}"
+do
+  systemctl restart lamp@$domain
+done
+for domain in "${static_domains[@]}"
+do
+  systemctl restart static@$domain
+done
+# ROLLBACK STOP
+
+# CLEAN START
+# CLEAN STOP
-- 
GitLab