1bf5045b93a4d617935dc947145114849375e3f3
[lhc/ateliers.git] / etc / nginx / site.d / lhc-remorque / configure.sh
1 local hint="run before: ./vm_remote runit_configure nginx -- $site"
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/lhc \
32 /home/git/hooks/lhc/remorque
33 sudo install -m 771 -o git -g git /dev/stdin \
34 /home/git/pub/lhc/remorque.git/hooks/post-update <<-EOF
35 #!/bin/sh -efux
36
37 # The cd below is why we must use this script.
38 # The current directory may not be accessible
39 # by the user running the ikiwiki.
40 # the execution of the ikiwiki wrapper would fail with :
41 # "E: Failed to change to directory '...': Permission denied"
42 cd /
43
44 exec /home/git/hooks/lhc/remorque/post-update.ikiwiki
45 EOF
46
47 if sudo test -d /home/lhc/var/ikiwiki/remorque/.git
48 then sudo -u wiki-"$site" \
49 sh -c 'cd /home/lhc/var/ikiwiki/remorque && git pull -v'
50 else
51 sudo -u wiki-"$site" \
52 git clone \
53 git@localhost:lhc/remorque \
54 /home/lhc/var/ikiwiki/remorque/git
55 set +f
56 sudo mv -i \
57 /home/lhc/var/ikiwiki/remorque/git/.git* \
58 /home/lhc/var/ikiwiki/remorque/git/* \
59 /home/lhc/var/ikiwiki/remorque/
60 sudo rmdir /home/lhc/var/ikiwiki/remorque/git
61 fi
62
63 sudo install -m 400 -o wiki-"$site" -g wiki-"$site" \
64 "$tool"/etc/nginx/site.d/"$site"/ikiwiki.setup \
65 /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup
66 sudo adduser wiki-"$site" www-"$site"
67 sudo install -d -m 2770 -o wiki-"$site" -g fcgi-"$site" \
68 /home/www/pub/"$site"/cgi
69 cd /
70 sudo -u wiki-"$site" ikiwiki \
71 --verbose \
72 --setup /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup \
73 --refresh \
74 --wrappers