8e07c618b1ce477c88a1342ac2598032251e23c3
[lhc/ateliers.git] / etc / nginx / site.d / lhc-remorque / configure.sh
1 local hint="run vm_remote nginx_configure before"
2 assert "sudo getent passwd wiki-\"$site\" >/dev/null" hint
3 assert "sudo test -f ~wiki-$site/etc/ssh/id_rsa" hint
4
5 rule apt_get_install ikiwiki \
6 libsearch-xapian-perl
7
8 rule adduser fcgi-"$site" \
9 --disabled-login \
10 --disabled-password \
11 --group \
12 --home /home/www/pub/"$site" \
13 --shell /bin/false \
14 --system
15 rule adduser www-"$site" \
16 --disabled-login \
17 --disabled-password \
18 --group \
19 --home /home/www/pub/"$site" \
20 --shell /bin/false \
21 --system
22 sudo adduser fcgi-"$site" www-"$site"
23 sudo adduser fcgi-"$site" wiki-"$site"
24 #sudo adduser www-"$site"-tls www-"$site"
25 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
26 /home/lhc/var/ikiwiki/remorque
27
28 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
29 /home/lhc/var/ikiwiki/remorque
30 sudo install -d -m 2750 -o wiki-"$site" -g git \
31 /home/git/hooks/remorque
32 sudo install -m 3771 -o git -g git /dev/stdin \
33 /home/git/pub/remorqueatelier.git/hooks/post-update <<-EOF
34 #!/bin/sh -efux
35
36 # The cd below is why we must use this script.
37 # The current directory may not be accessible
38 # by the user running the ikiwiki.
39 # the execution of the ikiwiki wrapper would fail with :
40 # "E: Failed to change to directory '...': Permission denied"
41 cd /
42
43 exec /home/git/hooks/remorque/post-update.ikiwiki
44 EOF
45
46 if sudo test -d /home/lhc/var/ikiwiki/remorque/.git
47 then sudo -u wiki-"$site" \
48 sh -c 'cd /home/lhc/var/ikiwiki/remorque && git pull -v'
49 else
50 sudo -u wiki-"$site" \
51 git clone \
52 git@localhost:remorqueatelier \
53 /home/lhc/var/ikiwiki/remorque/git
54 set +f
55 sudo mv -i \
56 /home/lhc/var/ikiwiki/remorque/git/.git* \
57 /home/lhc/var/ikiwiki/remorque/git/* \
58 /home/lhc/var/ikiwiki/remorque/
59 sudo rmdir /home/lhc/var/ikiwiki/remorque/git
60 fi
61
62 sudo install -m 400 -o wiki-"$site" -g wiki-"$site" \
63 "$tool"/etc/nginx/site.d/"$site"/ikiwiki.setup \
64 /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup
65 sudo adduser wiki-"$site" www-"$site"
66 sudo install -d -m 2770 -o wiki-"$site" -g fcgi-"$site" \
67 /home/www/pub/"$site"/cgi
68 cd /
69 sudo -u wiki-"$site" ikiwiki \
70 --verbose \
71 --setup /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup \
72 --refresh \
73 --wrappers