From 4bed967c3367e601f592a91a9b7cd823b0200da1 Mon Sep 17 00:00:00 2001
From: Daniel Bohrer <Daniel Bohrer@stratum0.org/mediawiki/>
Date: Sun, 14 Aug 2016 19:35:20 +0000
Subject: [PATCH] rsync to regolas

---
 Theodem.mw | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/Theodem.mw b/Theodem.mw
index 18c1d98c2..fc55fb46f 100644
--- a/Theodem.mw
+++ b/Theodem.mw
@@ -46,8 +46,42 @@
 ** <s>Git-Hooks im Admin-Repo: siehe http://gitolite.com/gitolite/gitolite.html#hooks</s>
 ** s0v-finanzen-Hook-Scripte sind in <tt>/var/lib/gitolite3/scripts</tt>
 ** Hook ist manuell im Repository angelegt
-** TODO: Ablage der generierten Dateien auf Webspace, Nightly-Tests integrieren
+** TODO: Nightly-Tests integrieren
 * SSH via Port-Forwarding von [[gandolf]], Port 2222
+* Alle Dateien in <tt>/var/www/html</tt> werden auf [[regolas]] gesynct, sobald die Datei <tt>/var/www/html/.dirty</tt> angelegt wird (z.B. durch Ausführen von <tt>/usr/local/bin/regolas-rsync</tt>). Die Dateien sind damit unter https://data.stratum0.org erreichbar.
+
+=== Skripte etc ===
+/home/regolas-rsync/bin/regolas-rsync:
+ #!/bin/sh
+ rsync \
+   --recursive --delete --stats \
+   --chmod=D2755,F644 \
+   --exclude='.*' \
+   /var/www/html/ theodem-rsync@regolas:/var/www/data.stratum0.org/ | \ 
+   sed 's/^/regolas-rsync: /'  
+
+/etc/systemd/system/regolas-rsync.service:
+ [Unit]
+ Description=rsync everything from /var/www/html to regolas
+ Requires=network.target
+ 
+ [Service]
+ User=regolas-rsync
+ Group=www-data
+ ExecStart=/bin/sh -c '                            \
+   while true; do                                  \
+     if [ -r /var/www/html/.dirty ]; then          \
+       /home/regolas-rsync/bin/regolas-rsync;      \
+       rm -f /var/www/html/.dirty;                 \
+     fi;                                           \
+     sleep 1;                                      \                                                    
+   done'
+ Restart=always
+ 
+ [Install]
+ WantedBy=multi-user.target
+
+
 
 [[Kategorie:Virtuelle Maschine]]
 [[Kategorie:Infrastruktur]]
-- 
2.20.1