Correction : cyclo-wiki : perms.
[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 xapian-omega \
11 libsearch-xapian-perl \
12 libdigest-sha-perl \
13 libhtml-scrubber-perl
14
15 #"$tool"/local/adduser fcgi-"$site" \
16 # --disabled-login \
17 # --disabled-password \
18 # --group \
19 # --home /home/cyclo/var/ikiwiki/'"'$site'"' \
20 # --shell /bin/false \
21 # --system
22 "$tool"/local/adduser www-"$site" \
23 --disabled-login \
24 --disabled-password \
25 --group \
26 --home /home/www/data/"$site" \
27 --shell /bin/false \
28 --system
29 #sudo adduser fcgi-"$site" www-"$site"
30 #sudo adduser fcgi-"$site" wiki-"$site"
31 #sudo adduser www-"$site"-tls www-"$site"
32 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
33 /home/cyclo/var/ikiwiki/"$site"
34 sudo install -d -m 3771 -o git -g git \
35 /home/git/hooks/cyclo
36 sudo install -d -m 750 -o wiki-"$site" -g git \
37 /home/git/hooks/cyclo/"$site"
38 sudo install -m 771 -o git -g git /dev/stdin \
39 /home/git/data/cyclowiki.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/cyclo/$site/post-update.ikiwiki
50 EOF
51
52 if sudo test -d /home/cyclo/var/ikiwiki/"$site"/src/.git
53 then sudo -u wiki-"$site" sh -$-c ' \
54 cd /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
55 git pull -v &&
56 git submodule update --recursive --init'
57 else
58 sudo -u wiki-"$site" sh -$-c ' \
59 umask 007 &&
60 git clone \
61 git@localhost:cyclowiki \
62 /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
63 cd /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
64 git config core.sharedRepository group &&
65 git submodule update --recursive --init
66 '
67 fi
68
69 sudo adduser wiki-"$site" www-"$site"
70 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
71 /home/www/data/"$site"/cgi
72 cd /
73 sudo -u wiki-"$site" ikiwiki \
74 --verbose \
75 --setup /home/cyclo/var/ikiwiki/"$site"/src/ikiwiki.setup \
76 --refresh \
77 --wrappers
78 sudo chown wiki-"$site":www-"$site" \
79 /home/git/hooks/cyclo/"$site"/post-update.ikiwiki
80 sudo chmod 6755 \
81 /home/git/hooks/cyclo/"$site"/post-update.ikiwiki
82 sudo chmod g+w \
83 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki \
84 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki/xapian/default
85 sudo install -m 664 -o wiki-"$site" -g wiki-"$site" /dev/stdin \
86 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki/xapian/omega.conf <<-EOF
87 database_dir .
88 template_dir ./templates
89 EOF
90
91 sudo cat /etc/gitweb/gitweb.conf - <<-EOF |
92 \$export_ok = "cyclo-wiki-export-ok";
93 \$favicon = "/gitweb/static/git-favicon.png";
94 \$home_link = "/";
95 \$home_link_str = 'wiki';
96 \$home_text = "/etc/gitweb/cyclo.home_text.html";
97 \$javascript = "/gitweb/static/gitweb.js";
98 \$logo = "/gitweb/static/git-logo.png";
99 \$my_uri = "/gitweb/";
100 \$my_url = "/gitweb/";
101 \$projects_list = "/etc/gitweb/cyclo-wiki.projects.list";
102 \$site_footer = "/etc/gitweb/cyclo.site_footer.html";
103 \$site_header = "/etc/gitweb/cyclo.site_header.html";
104 \$site_name = "wiki.cyclocoop.org";
105 @stylesheets = ("/gitweb/static/gitweb.css");#
106 EOF
107 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
108 /etc/gitweb/cyclo-wiki.conf
109 sudo install -m 640 -o root -g fcgi-gitweb \
110 "$tool"/etc/gitweb/cyclo.home_text.html \
111 /etc/gitweb/cyclo.home_text.html
112 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
113 /etc/gitweb/cyclo-wiki.projects.list <<-EOF
114 cyclowiki.git
115 EOF