Ajout : 3615.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 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 2770 -o git -g www-"$site" \
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 /home/git/hooks/cyclo/cyclo-3615/post-update.ikiwiki &
50 exec /home/git/hooks/cyclo/$site/post-update.ikiwiki
51 EOF
52
53 if sudo test -d /home/cyclo/var/ikiwiki/"$site"/src/.git
54 then sudo -u wiki-"$site" sh -$-c ' \
55 cd /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
56 git pull -v &&
57 git submodule update --recursive --init'
58 else
59 sudo -u wiki-"$site" sh -$-c ' \
60 umask 007 &&
61 git clone \
62 git@localhost:cyclowiki \
63 /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
64 cd /home/cyclo/var/ikiwiki/'"'$site'"'/src &&
65 git config core.sharedRepository all &&
66 git submodule update --recursive --init
67 '
68 fi
69
70 sudo adduser wiki-"$site" www-"$site"
71 sudo install -d -m 2770 -o wiki-"$site" -g wiki-"$site" \
72 /home/www/data/"$site"/cgi
73 cd /
74 sudo -u wiki-"$site" ikiwiki \
75 --verbose \
76 --setup /home/cyclo/var/ikiwiki/"$site"/src/ikiwiki.setup \
77 --refresh \
78 --wrappers
79 sudo chmod g+w \
80 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki \
81 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki/xapian/wiki # TODO: chmod all database
82
83 sudo install -m 664 -o wiki-"$site" -g wiki-"$site" /dev/stdin \
84 /home/cyclo/var/ikiwiki/"$site"/src/.ikiwiki/xapian/omega.conf <<-EOF
85 database_dir .
86 template_dir ./templates
87 EOF
88
89 sudo cat /etc/gitweb/gitweb.conf - <<-EOF |
90 \$export_ok = "cyclo-wiki-export-ok";
91 \$favicon = "/gitweb/static/git-favicon.png";
92 \$home_link = "/";
93 \$home_link_str = 'wiki';
94 \$home_text = "/etc/gitweb/cyclo.home_text.html";
95 \$javascript = "/gitweb/static/gitweb.js";
96 \$logo = "/gitweb/static/git-logo.png";
97 \$my_uri = "/gitweb/";
98 \$my_url = "/gitweb/";
99 \$projects_list = "/etc/gitweb/cyclo-wiki.projects.list";
100 \$site_footer = "/etc/gitweb/cyclo.site_footer.html";
101 \$site_header = "/etc/gitweb/cyclo.site_header.html";
102 \$site_name = "wiki.cyclocoop.org";
103 @stylesheets = ("/gitweb/static/gitweb.css");#
104 EOF
105 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
106 /etc/gitweb/cyclo-wiki.conf
107 sudo install -m 640 -o root -g fcgi-gitweb \
108 "$tool"/etc/gitweb/cyclo.home_text.html \
109 /etc/gitweb/cyclo.home_text.html
110 sudo install -m 640 -o root -g fcgi-gitweb /dev/stdin \
111 /etc/gitweb/cyclo-wiki.projects.list <<-EOF
112 cyclowiki.git
113 EOF