Ajout : DAViCal + CalDavZAP + AgenDAV .
[lhc/ateliers.git] / etc / nginx / site.d / agendav / local.sh
diff --git a/etc/nginx/site.d/agendav/local.sh b/etc/nginx/site.d/agendav/local.sh
new file mode 100644 (file)
index 0000000..2afed4a
--- /dev/null
@@ -0,0 +1,43 @@
+sudo adduser www-"$site"-tls www-"$site"
+sudo adduser php5_"$site" www-"$site"
+sudo adduser php5_"$site" postgres-data
+sudo adduser php5_"$site" log-php5-"$site"
+
+hint="run before: remote/runit-configure nginx -- $site"
+assert "sudo test -f /etc/agendav/config.php" hint
+sudo chgrp php5_$site /etc/agendav/config.php
+
+sudo sv start postgres
+while ! sudo -u postgres psql </dev/null
+do sleep 1; done
+
+"$tool"/local/postgresql-user-create     "$site"
+"$tool"/local/postgresql-database-create "$site"
+sudo -u postgres psql -AqtX "$site" <<-EOF
+       \set ON_ERROR_STOP on
+       GRANT USAGE ON SCHEMA pg_catalog TO $site;
+       EOF
+
+eval home="~www-$site"
+if test ! shared = "$(sudo -u postgres psql -AqtX "$site" <<-EOF
+       SELECT c.relname
+               FROM pg_catalog.pg_class c
+               LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
+               WHERE c.relkind = 'r'
+               AND c.relname = 'shared'
+               AND n.nspname = 'public';
+       EOF
+ )"
+ then
+       sudo -u php5_"$site" psql -f - -U "$site" "$site" <<-EOF
+               \set ON_ERROR_STOP on
+               $(sudo cat "$home"/sql/pgsql.schema.sql)
+               EOF
+ fi
+
+sudo install -d -m 750 -o root -g php5_"$site" \
+ /etc/agendav
+sudo find "$tool"/etc/agendav -type f \
+ -not -name config.php \
+ -exec install -m 640 -o root -g php5_"$site" \
+ -t /etc/agendav/ {} +