Change permissionf for pleroma user during database creation

This commit is contained in:
Bob Mottram 2017-11-06 15:34:46 +00:00
parent 35bd3d34a5
commit cb1b654c7c
1 changed files with 17 additions and 5 deletions

View File

@ -187,6 +187,10 @@ function pleroma_create_database {
fi fi
add_postgresql_user pleroma "$PLEROMA_ADMIN_PASSWORD" encrypted add_postgresql_user pleroma "$PLEROMA_ADMIN_PASSWORD" encrypted
run_system_query_postgresql "create database pleroma;"
# temporarily allow the user to create databases
run_system_query_postgresql "ALTER USER pleroma CREATEDB;"
run_system_query_postgresql "ALTER USER pleroma SUPERUSER;"
run_system_query_postgresql "GRANT ALL ON ALL tables IN SCHEMA public TO pleroma;" run_system_query_postgresql "GRANT ALL ON ALL tables IN SCHEMA public TO pleroma;"
run_system_query_postgresql "GRANT ALL ON ALL sequences IN SCHEMA public TO pleroma;" run_system_query_postgresql "GRANT ALL ON ALL sequences IN SCHEMA public TO pleroma;"
@ -202,21 +206,28 @@ function pleroma_create_database {
sed -i "s|email: .*|email: \"$MY_EMAIL_ADDRESS\",|g" $pleroma_config sed -i "s|email: .*|email: \"$MY_EMAIL_ADDRESS\",|g" $pleroma_config
cd $PLEROMA_DIR cd $PLEROMA_DIR
mix local.rebar --force chown -R pleroma:pleroma *
sudo -u pleroma mix local.rebar --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'mix local.rebar failed' echo $'mix local.rebar failed'
exit 73528562 exit 73528562
fi fi
mix ecto.create --force sudo -u pleroma mix local.hex --force
sudo -u pleroma mix deps.compile mimerl
sudo -u pleroma mix ecto.create --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'mix ecto.create failed' echo $'mix ecto.create failed'
exit 83653582 exit 83653582
fi fi
mix ecto.migrate --force sudo -u pleroma mix ecto.migrate --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'mix ecto.migrate failed' echo $'mix ecto.migrate failed'
exit 73752573 exit 73752573
fi fi
# revoke the ability to create databases for this user
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
} }
function reconfigure_pleroma { function reconfigure_pleroma {
@ -637,12 +648,13 @@ function install_pleroma {
# back end # back end
cd $PLEROMA_DIR cd $PLEROMA_DIR
mix local.hex --force chown -R pleroma:pleroma *
sudo -u pleroma mix local.hex --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'mix local.hex failed' echo $'mix local.hex failed'
exit 1745673 exit 1745673
fi fi
mix deps.get --force sudo -u pleroma mix deps.get --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
echo $'mix deps.get failed' echo $'mix deps.get failed'
exit 7325733 exit 7325733