Ajout : vm_hosted : lhc-remorque .
[lhc/ateliers.git] / etc / nginx / site.d / lhc-remorque / configure.sh
diff --git a/etc/nginx/site.d/lhc-remorque/configure.sh b/etc/nginx/site.d/lhc-remorque/configure.sh
new file mode 100644 (file)
index 0000000..59645ad
--- /dev/null
@@ -0,0 +1,78 @@
+local hint="run vm_remote nginx_configure before"
+assert "sudo getent passwd wiki-\"$site\" >/dev/null" hint
+assert "sudo test -f ~wiki-$site/etc/ssh/id_rsa" hint
+
+rule apt_get_install ikiwiki \
+ libsearch-xapian-perl
+
+rule adduser fcgi-"$site" \
+ --disabled-login \
+ --disabled-password \
+ --group \
+ --home /home/www/pub/"$site" \
+ --shell /bin/false \
+ --system
+rule adduser www-"$site" \
+ --disabled-login \
+ --disabled-password \
+ --group \
+ --home /home/www/pub/"$site" \
+ --shell /bin/false \
+ --system
+sudo adduser fcgi-"$site" www-"$site"
+sudo adduser fcgi-"$site" wiki-"$site"
+#sudo adduser www-"$site"-tls www-"$site"
+sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
+ /home/lhc/var/ikiwiki/remorque
+
+sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
+ /home/lhc/var/ikiwiki/remorque
+sudo install -d -m 2750 -o wiki-"$site" -g git \
+ /home/git/hooks/remorque
+sudo install -m 3771 -o git -g git /dev/stdin \
+ /home/git/pub/remorqueatelier.git/hooks/post-update <<-EOF
+       #!/bin/sh -efux
+       
+       # The cd below is why we must use this script.
+       # The current directory may not be accessible
+       # by the user running the ikiwiki.
+       # the execution of the ikiwiki wrapper would fail with :
+       # "E: Failed to change to directory '...': Permission denied"
+       cd /
+       
+       exec /home/git/hooks/remorque/post-update.ikiwiki
+       EOF
+
+if test -d /home/lhc/var/ikiwiki/remorque/.git
+ then sudo -u wiki-"$site" \
+       sh -c 'cd /home/lhc/var/ikiwiki/remorque && git pull -v'
+ else
+       (
+       eval cd ~wiki-"$site"
+       set +f
+       sudo -u wiki-"$site" \
+               git clone \
+                git@localhost:remorqueatelier \
+                /home/lhc/var/ikiwiki/remorque/git
+       sudo mv -i \
+        /home/lhc/var/ikiwiki/remorque/git/.git* \
+        /home/lhc/var/ikiwiki/remorque/git/* \
+        /home/lhc/var/ikiwiki/remorque/
+       )
+       sudo rmdir /home/lhc/var/ikiwiki/remorque/git
+ fi
+
+sudo install -m 400 -o wiki-"$site" -g wiki-"$site" \
+   "$tool"/etc/nginx/site.d/"$site"/ikiwiki.setup \
+ /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup
+eval cd ~wiki-"$site"
+sudo adduser wiki-"$site" www-"$site"
+
+sudo install -d -m 2770 -o wiki-"$site" -g fcgi-"$site" \
+ /home/www/pub/"$site"/cgi
+
+sudo -u wiki-"$site" ikiwiki \
+ --verbose \
+ --setup /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup \
+ --refresh \
+ --wrappers