3ccb68cf01f505736db2bfd01adc4efbbbbd3da4
[lhc/ateliers.git] / etc / nginx / site.d / agendav / local.sh
1 sudo adduser www-"$site"-tls www-"$site"
2 sudo adduser php5_"$site" www-"$site"
3 sudo adduser php5_"$site" postgres-data
4 sudo adduser php5_"$site" log-php5-"$site"
5
6 hint="run before: remote/runit-configure nginx -- $site"
7 assert "sudo test -f /etc/$site/config.php" hint
8 sudo chgrp php5_$site /etc/"$site"/config.php
9
10 sudo sv start postgres
11 while ! sudo -u postgres psql </dev/null
12 do sleep 1; done
13
14 "$tool"/local/postgresql-user-create "$site"
15 "$tool"/local/postgresql-database-create "$site"
16
17 eval home="~www-$site"
18 if test ! shared = "$(sudo -u postgres psql -AqtX "$site" <<-EOF
19 SELECT c.relname
20 FROM pg_catalog.pg_class c
21 LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
22 WHERE c.relkind = 'r'
23 AND c.relname = 'shared'
24 AND n.nspname = 'public';
25 EOF
26 )"
27 then
28 sudo cat "$home"/sql/pgsql.schema.sql |
29 sudo -u php5_"$site" psql -f - -U "$site" --set ON_ERROR_STOP=1 "$site"
30 fi
31
32 sudo install -d -m 750 -o root -g php5_"$site" \
33 /etc/"$site"
34 sudo find "$tool"/etc/"$site" -type f \
35 -not -name config.php \
36 -exec install -m 640 -o root -g php5_"$site" \
37 -t /etc/"$site"/ {} +