summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2019-06-01 06:05:03 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2019-06-01 06:05:03 (GMT)
commit4f116fcdebe1b70391214c54fa6e79006f7baed9 (patch)
tree9166ef75b46ed7c161f06afc45ce249b29a61155
parent6f8ec32943d16c2451d3fa03e7d958b3afbaf387 (diff)
downloadpublik-client-scripts-4f116fcdebe1b70391214c54fa6e79006f7baed9.zip
publik-client-scripts-4f116fcdebe1b70391214c54fa6e79006f7baed9.tar.gz
publik-client-scripts-4f116fcdebe1b70391214c54fa6e79006f7baed9.tar.bz2
montpellier: run cron job as postgres user (#33577)
-rwxr-xr-xclients/montpellier/pg_copy_bijoe_schema17
-rw-r--r--debian/publik-montpellier-scripts.cron.d2
2 files changed, 9 insertions, 10 deletions
diff --git a/clients/montpellier/pg_copy_bijoe_schema b/clients/montpellier/pg_copy_bijoe_schema
index 03b9776..a102fb2 100755
--- a/clients/montpellier/pg_copy_bijoe_schema
+++ b/clients/montpellier/pg_copy_bijoe_schema
@@ -14,15 +14,14 @@ origin=bijoe
schema=$1
destination=montpellier3m_bijoe
owner=montpellier3m
-psql='sudo -u postgres psql'
-$psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='$owner'" | grep -q 1 || $psql -c "CREATE ROLE $owner;"
+psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='$owner'" | grep -q 1 || psql -c "CREATE ROLE $owner;"
-$psql -c "DROP DATABASE IF EXISTS $destination;" >/dev/null
-$psql -c "CREATE DATABASE $destination WITH OWNER '$owner';" >/dev/null
-sudo -u postgres pg_dump --no-owner --schema $schema $origin | $psql $destination >/dev/null
+psql -c "DROP DATABASE IF EXISTS $destination;" >/dev/null
+psql -c "CREATE DATABASE $destination WITH OWNER '$owner';" >/dev/null
+pg_dump --no-owner --schema $schema $origin | psql $destination >/dev/null
-$psql -c "ALTER ROLE $owner WITH LOGIN;" >/dev/null
-$psql -c "GRANT CONNECT ON DATABASE $destination TO $owner;" >/dev/null
-$psql $destination -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO $owner;" >/dev/null
-$psql $destination -c "GRANT SELECT ON ALL TABLES IN SCHEMA $schema TO $owner;" >/dev/null
+psql -c "ALTER ROLE $owner WITH LOGIN;" >/dev/null
+psql -c "GRANT CONNECT ON DATABASE $destination TO $owner;" >/dev/null
+psql $destination -c "GRANT SELECT ON ALL TABLES IN SCHEMA public TO $owner;" >/dev/null
+psql $destination -c "GRANT SELECT ON ALL TABLES IN SCHEMA $schema TO $owner;" >/dev/null
diff --git a/debian/publik-montpellier-scripts.cron.d b/debian/publik-montpellier-scripts.cron.d
index 7f6acf0..5b65a6f 100644
--- a/debian/publik-montpellier-scripts.cron.d
+++ b/debian/publik-montpellier-scripts.cron.d
@@ -1 +1 @@
-1 4 * * * root /usr/lib/publik/clients/montpellier/pg_copy_bijoe_schema.task
+1 4 * * * postgres /usr/lib/publik/clients/montpellier/pg_copy_bijoe_schema.task