Ajout : wiki.cyclocoop.org .
[lhc/ateliers.git] / etc / nginx / site.d / cyclo-wiki / 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/wiki.cyclocoop.org/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/data/"$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/data/"$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/cyclo/var/ikiwiki/"$site"
31 sudo install -d -m 3771 -o git -g git \
32 /home/git/hooks/cyclo
33 sudo install -d -m 750 -o wiki-"$site" -g git \
34 /home/git/hooks/cyclo/"$site"
35 sudo install -m 771 -o git -g git /dev/stdin \
36 /home/git/data/cyclowiki.git/hooks/post-update <<-EOF
37 #!/bin/sh -efux
38
39 # The cd below is why we must use this script.
40 # The current directory may not be accessible
41 # by the user running the ikiwiki.
42 # the execution of the ikiwiki wrapper would fail with :
43 # "E: Failed to change to directory '...': Permission denied"
44 cd /
45
46 exec /home/git/hooks/cyclo/$site/post-update.ikiwiki
47 EOF
48
49 if sudo test -d /home/cyclo/var/ikiwiki/"$site"/src/.git
50 then sudo -u wiki-"$site" sh -$-c \
51 'cd /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
52 git pull -v &&
53 git submodule update --recursive --init'
54 else
55 sudo -u wiki-"$site" git clone \
56 git@localhost:cyclowiki \
57 /home/cyclo/var/ikiwiki/"$site"/src
58 sudo -u wiki-"$site" sh -$-c \
59 'cd /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
60 git submodule update --recursive --init'
61 fi
62
63 sudo adduser wiki-"$site" www-"$site"
64 sudo install -d -m 2770 -o wiki-"$site" -g fcgi-"$site" \
65 /home/www/data/"$site"/cgi
66 cd /
67 sudo -u wiki-"$site" ikiwiki \
68 --verbose \
69 --setup /home/cyclo/var/ikiwiki/"$site"/src/ikiwiki.setup \
70 --refresh \
71 --wrappers
72 sudo chown wiki-"$site":www-"$site" \
73 /home/git/hooks/cyclo/"$site"/post-update.ikiwiki
74 sudo chmod 6755 \
75 /home/git/hooks/cyclo/"$site"/post-update.ikiwiki
76 sudo chmod g+w \
77 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki
78
79 sudo cat /etc/gitweb/gitweb.conf - <<-EOF |
80 \$export_ok = "cyclo-wiki-export-ok";
81 \$favicon = "/gitweb/static/git-favicon.png";
82 \$home_link = "/";
83 \$home_link_str = 'wiki';
84 \$home_text = "/etc/gitweb/cyclo.home_text.html";
85 \$javascript = "/gitweb/static/gitweb.js";
86 \$logo = "/gitweb/static/git-logo.png";
87 \$my_uri = "/gitweb/";
88 \$my_url = "/gitweb/";
89 \$projects_list = "/etc/gitweb/cyclo-wiki.projects.list";
90 \$site_footer = "/etc/gitweb/cyclo.site_footer.html";
91 \$site_header = "/etc/gitweb/cyclo.site_header.html";
92 \$site_name = "wiki.cyclowiki.org";
93 @stylesheets = ("/gitweb/static/gitweb.css");#
94 EOF
95 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
96 /etc/gitweb/cyclo-wiki.conf
97 sudo install -m 640 -o root -g fcgi-gitweb \
98 "$tool"/etc/gitweb/cyclo.home_text.html \
99 /etc/gitweb/cyclo.home_text.html
100 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
101 /etc/gitweb/cyclo-wiki.projects.list <<-EOF
102 cyclowiki.git
103 EOF