9ec7bdb04fe3c1d0994482c9c9e3245a232cb667
[lhc/ateliers.git] / etc / nginx / site.d / lhc-remorque / local.sh
1 hint="run before: remote/runit-configure nginx -- $site"
2 assert "sudo test -f /etc/nginx/x509.d/\"$site\"/key.pem" hint
3 assert "sudo test -f ~wiki-$site/etc/ssh/id_rsa" hint
4
5 sudo install -m 664 -o www -g www \
6 "$tool"/var/pub/x509/remorque."$local_domainname"/crt+ca.pem \
7 /etc/nginx/x509.d/"$site"/crt.pem
8
9 "$tool"/local/apt-get-install ikiwiki \
10 libsearch-xapian-perl
11
12 "$tool"/local/adduser fcgi-"$site" \
13 --disabled-login \
14 --disabled-password \
15 --group \
16 --home /home/www/pub/"$site" \
17 --shell /bin/false \
18 --system
19 "$tool"/local/adduser www-"$site" \
20 --disabled-login \
21 --disabled-password \
22 --group \
23 --home /home/www/pub/"$site" \
24 --shell /bin/false \
25 --system
26 sudo adduser fcgi-"$site" www-"$site"
27 sudo adduser fcgi-"$site" wiki-"$site"
28 #sudo adduser www-"$site"-tls www-"$site"
29 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
30 /home/lhc/var/ikiwiki/remorque
31
32 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
33 /home/lhc/var/ikiwiki/remorque
34 sudo install -d -m 3771 -o git -g git \
35 /home/git/hooks/lhc
36 sudo install -d -m 750 -o wiki-"$site" -g git \
37 /home/git/hooks/lhc/remorque
38 sudo install -m 771 -o git -g git /dev/stdin \
39 /home/git/pub/lhc/remorque.git/hooks/post-update <<-EOF
40 #!/bin/sh -efux
41
42 # The cd below is why we must use this script.
43 # The current directory may not be accessible
44 # by the user running the ikiwiki.
45 # the execution of the ikiwiki wrapper would fail with :
46 # "E: Failed to change to directory '...': Permission denied"
47 cd /
48
49 exec /home/git/hooks/lhc/remorque/post-update.ikiwiki
50 EOF
51
52 if sudo test -d /home/lhc/var/ikiwiki/remorque/.git
53 then sudo -u wiki-"$site" \
54 sh -c 'cd /home/lhc/var/ikiwiki/remorque && git pull -v'
55 else
56 sudo -u wiki-"$site" \
57 git clone \
58 git@localhost:lhc/remorque \
59 /home/lhc/var/ikiwiki/remorque/git
60 set +f
61 sudo mv -i \
62 /home/lhc/var/ikiwiki/remorque/git/.git* \
63 /home/lhc/var/ikiwiki/remorque/git/* \
64 /home/lhc/var/ikiwiki/remorque/
65 sudo rmdir /home/lhc/var/ikiwiki/remorque/git
66 fi
67
68 sudo install -m 400 -o wiki-"$site" -g wiki-"$site" \
69 "$tool"/etc/nginx/site.d/"$site"/ikiwiki.setup \
70 /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup
71 sudo adduser wiki-"$site" www-"$site"
72 sudo install -d -m 2770 -o wiki-"$site" -g fcgi-"$site" \
73 /home/www/pub/"$site"/cgi
74 cd /
75 sudo -u wiki-"$site" ikiwiki \
76 --verbose \
77 --setup /home/lhc/var/ikiwiki/remorque/etc/ikiwiki.setup \
78 --refresh \
79 --wrappers
80 sudo chown wiki-"$site":www-"$site" \
81 /home/git/hooks/lhc/remorque/post-update.ikiwiki
82 sudo chmod 6755 \
83 /home/git/hooks/lhc/remorque/post-update.ikiwiki
84
85 sudo cat /etc/gitweb/gitweb.conf - <<-EOF |
86 \$export_ok = "lhc-remorque-export-ok";
87 \$favicon = "/gitweb/static/git-favicon.png";
88 \$home_link = "/";
89 \$home_link_str = 'wiki';
90 \$home_text = "/etc/gitweb/lhc.home_text.html";
91 \$javascript = "/gitweb/static/gitweb.js";
92 \$logo = "/gitweb/static/git-logo.png";
93 \$my_uri = "/gitweb/";
94 \$projects_list = "/etc/gitweb/lhc-remorque.projects.list";
95 \$site_footer = "/etc/gitweb/lhc.site_footer.html";
96 \$site_header = "/etc/gitweb/lhc.site_header.html";
97 \$site_name = "remorque.$local_domainname";
98 @stylesheets = ("/gitweb/static/gitweb.css");#
99 EOF
100 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
101 /etc/gitweb/lhc-remorque.conf
102 sudo install -m 640 -o root -g fcgi-gitweb \
103 "$tool"/etc/gitweb/lhc.home_text.html \
104 /etc/gitweb/lhc.home_text.html
105 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
106 /etc/gitweb/lhc-remorque.projects.list <<-EOF
107 lhc/remorque.git
108 EOF