6920cefee9aa092b20810a4fb0d470a2a190f152
[lhc/ateliers.git] / etc / nginx / site.d / roundcube / 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 hint="run before: remote/runit-configure nginx -- $site"
4 assert "sudo test -f /etc/$site/main.inc.php" hint
5
6 sudo install -m 664 -o www -g www \
7 "$tool"/var/pub/x509/"$site"."$local_domainname"/crt+ca.pem \
8 /etc/nginx/x509.d/"$site"/crt.pem
9
10 sudo adduser php5_"$site" www-"$site"
11 sudo adduser php5_"$site" postgres-data
12 sudo adduser php5_"$site" log-php5-"$site"
13
14 "$tool"/local/runit-sv-configure postgres
15 "$tool"/local/runit-sv-start postgres
16 while ! sudo -u postgres psql </dev/null
17 do sleep 1; done
18
19 "$tool"/local/postgresql-user-create "$site"
20 "$tool"/local/postgresql-database-create "$site"
21 "$tool"/local/postgresql-schema-create "$site"
22 sudo -u postgres psql -AqtX --set ON_ERROR_STOP=1 "$site" <<-EOF
23 GRANT USAGE ON SCHEMA pg_catalog TO $site;
24 EOF
25 #sudo -u postgres psql "$site" -a -f - --set ON_ERROR_STOP=1 <<-EOF
26 # -- GRANT USAGE,CREATE ON SCHEMA public TO $site;
27 # EOF
28
29 eval home="~www-$site"
30 sudo debconf-set-selections <<-EOF || true
31 # Password confirmation:
32 roundcube-core roundcube/password-confirm password
33 # Password of the database's administrative user:
34 roundcube-core roundcube/mysql/admin-pass password
35 # MySQL application password for roundcube:
36 roundcube-core roundcube/mysql/app-pass password
37 # Password confirmation:
38 roundcube-core roundcube/app-password-confirm password
39 # PostgreSQL application password for roundcube:
40 roundcube-core roundcube/pgsql/app-pass password
41 # Password of your database's administrative user:
42 roundcube-core roundcube/pgsql/admin-pass password
43 # Next step for database upgrade:
44 # Choices: abort, retry, retry (skip questions)
45 roundcube-core roundcube/upgrade-error select abort
46 # Method for authenticating PostgreSQL user:
47 # Choices: ident, password
48 roundcube-core roundcube/pgsql/authmethod-user select ident
49 # Do you want to purge the database for roundcube?
50 roundcube-core roundcube/purge boolean false
51 # Configure database for roundcube with dbconfig-common?
52 roundcube-core roundcube/dbconfig-install boolean true
53 # Default language:
54 # Choices: ar_SA, ast, az_AZ, bg_BG, bn_BD, br, bs_BA, ca_ES, cs_CZ, cy_GB, da_DK, de_CH, de_DE, el_GR, en_GB, en_US, eo, es_AR, es_ES, et_EE, eu_ES, fa, fa_AF, fi_FI, fr_FR, ga_IE, gl_ES, he_IL, hi_IN, hr_HR, hu_HU, hy_AM, id_ID, is_IS, it_IT, ja_JP, ka_GE, kh_KH, ko_KR, ku, lt_LT, lv_LV, mk_MK, mr_IN, ms_MY, nb_NO, ne_NP, nl_BE, nl_NL, nn_NO, pl_PL, ps, pt_BR, pt_PT, ro_RO, ru_RU, si_LK, sk_SK, sl_SI, sq_AL, sr_CS, sv_SE, ta_IN, th_TH, tr_TR, uk_UA, vi_VN, zh_CN, zh_TW
55 roundcube-core roundcube/language select fr_FR
56 # PostgreSQL database name for roundcube:
57 roundcube-core roundcube/db/dbname string roundcube
58 # Host running the PostgreSQL server for roundcube:
59 roundcube-core roundcube/remote/newhost string
60 # Change PostgreSQL configuration automatically?
61 roundcube-core roundcube/pgsql/changeconf boolean false
62 # Do you want to back up the database for roundcube before upgrading?
63 roundcube-core roundcube/upgrade-backup boolean true
64 # Next step for database installation:
65 # Choices: abort, retry, retry (skip questions), ignore
66 roundcube-core roundcube/install-error select retry
67 # Name of the database's administrative user:
68 roundcube-core roundcube/mysql/admin-user string root
69 # IMAP server(s) used with RoundCube:
70 roundcube-core roundcube/hosts string imap.heureux-cyclage.org
71 # Method for authenticating the PostgreSQL administrator:
72 # Choices: ident, password
73 roundcube-core roundcube/pgsql/authmethod-admin select ident
74 # Deconfigure database for roundcube with dbconfig-common?
75 roundcube-core roundcube/dbconfig-remove boolean
76 # Name of the database's administrative user:
77 roundcube-core roundcube/pgsql/admin-user string postgres
78 # for internal use.
79 roundcube-core roundcube/internal/skip-preseed boolean false
80 # PostgreSQL username for roundcube:
81 roundcube-core roundcube/db/app-user string php5_$site
82 # Reinstall database for roundcube?
83 roundcube-core roundcube/dbconfig-reinstall boolean false
84 # Connection method for MySQL database of roundcube:
85 # Choices: unix socket, tcp/ip
86 roundcube-core roundcube/mysql/method select unix socket
87 # Next step for database removal:
88 # Choices: abort, retry
89 roundcube-core roundcube/remove-error select abort
90 # Should the webserver(s) be restarted now?
91 roundcube-core roundcube/restart-webserver boolean false
92 # Perform upgrade on database for roundcube with dbconfig-common?
93 roundcube-core roundcube/dbconfig-upgrade boolean true
94 # Port number for the PostgreSQL service:
95 roundcube-core roundcube/remote/port string
96 # Connection method for PostgreSQL database of roundcube:
97 # Choices: unix socket, tcp/ip, tcp/ip + ssl
98 roundcube-core roundcube/pgsql/method select unix socket
99 # Modifications needed in /etc/postgresql/pg_hba.conf
100 roundcube-core roundcube/pgsql/manualconf note
101 # storage directory for roundcube:
102 roundcube-core roundcube/db/basepath string
103 # Empty passwords unsupported with PostgreSQL
104 roundcube-core roundcube/pgsql/no-empty-passwords error
105 # Password mismatch
106 roundcube-core roundcube/passwords-do-not-match error
107 # for internal use.
108 roundcube-core roundcube/internal/reconfiguring boolean false
109 # Web server(s) to configure automatically:
110 # Choices: apache2, lighttpd
111 roundcube-core roundcube/reconfigure-webserver multiselect
112 # Database type to be used by roundcube:
113 # Choices: mysql, pgsql
114 roundcube-core roundcube/database-type select pgsql
115 # Host name of the PostgreSQL database server for roundcube:
116 # Choices:
117 roundcube-core roundcube/remote/host select
118 # Next step:
119 # Choices: abort, retry, ignore
120 roundcube-core roundcube/missing-db-package-error select abort
121 EOF
122 sudo install -d -m 755 -o root -g root \
123 /etc/dbconfig-common
124 sudo install -m 600 -o root -g root /dev/stdin \
125 /etc/dbconfig-common/"$site".conf <<-EOF
126 dbc_authmethod_admin='ident'
127 dbc_authmethod_user='ident'
128 dbc_basepath=''
129 dbc_dbadmin='postgres'
130 dbc_dbname='$site'
131 dbc_dbpass=''
132 dbc_dbport=''
133 dbc_dbserver='/run/postgresql'
134 dbc_dbtype='pgsql'
135 dbc_dbuser='$site'
136 dbc_install='true'
137 dbc_remove=''
138 dbc_ssl=''
139 dbc_upgrade='true'
140 EOF
141
142 ! sudo etckeeper unclean ||
143 sudo etckeeper commit -m "runit-configure nginx -- $site"
144
145 "$tool"/local/apt-get-install \
146 aspell-de \
147 aspell-en \
148 aspell-es \
149 aspell-it \
150 aspell-fr \
151 aspell-pl \
152 roundcube \
153 roundcube-pgsql \
154 roundcube-plugins
155 sudo chgrp php5_$site /var/log/roundcube/
156
157 sudo install -d -m 750 -o root -g php5_"$site" \
158 /etc/"$site"
159 sudo find "$tool"/etc/"$site" -type f \
160 -exec install -m 640 -o root -g php5_"$site" \
161 -t /etc/"$site"/ {} +
162
163 sudo install -m 500 -o php5_"$site" -g root \
164 "$tool"/local/roundcube-chpasswd \
165 /usr/local/bin/roundcube-chpasswd