Skip to content

Commit

Permalink
fix datastore permissions crontab and script --no-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
OriHoch committed Oct 4, 2018
1 parent 934e721 commit 3fc7397
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.2.17
0.2.19
2 changes: 1 addition & 1 deletion db/datastore-permissions-cron.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
echo "Setting up datastore permissions cron" &&\
mkdir -p /datastore-permissions-crontabs &&\
echo "* * * * * bash /db-scripts/datastore-permissions-update.sh" > /datastore-permissions-crontabs/root
echo '* * * * * bash /db-scripts/datastore-permissions-update.sh' > /datastore-permissions-crontabs/root
[ "$?" != "0" ] && echo failed to initialize datastore permissions cron && exit 1
exec crond -f -L /dev/stdout -c /datastore-permissions-crontabs
4 changes: 4 additions & 0 deletions db/datastore-permissions-update.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
cd /
while ! su postgres -c "pg_isready"; do echo waiting for DB..; sleep 1; done
[ `su postgres -c "psql -c \"select count(1) from pg_roles where rolname='publicreadonly'\" -tA"` == "0" ] &&\
echo creating role publicreadonly &&\
! su postgres -c "psql -c \"create role publicreadonly with login password '${DATASTORE_PUBLIC_RO_PASSWORD}';\"" \
&& echo failed to create publicreadonly role && exit 1
echo getting all datastore resource ids
! DATASTORE_RESOURCES=`su postgres -c 'psql datastore -c "select tablename from pg_tables where schemaname='"'public'"';" -tA'` \
&& echo failed to get datastore tables && exit 1
echo updating datastore table permissions
for RESOURCE in $DATASTORE_RESOURCES; do
if wget -qO /dev/null http://ckan:5000/api/3/action/resource_show?id=${RESOURCE} 2>/dev/null; then
! su postgres -c "psql datastore -c 'grant select on \"${RESOURCE}\" to publicreadonly;'" >/dev/null &&\
Expand Down

0 comments on commit 3fc7397

Please sign in to comment.