Revert pleroma user permissions if an error occurs

This commit is contained in:
Bob Mottram 2017-11-06 18:52:19 +00:00
parent 5a6669c033
commit 99fddf5f21
1 changed files with 8 additions and 0 deletions

View File

@ -201,6 +201,8 @@ function pleroma_create_database {
if [ ${#PLEROMA_SECRET_KEY} -lt 50 ]; then if [ ${#PLEROMA_SECRET_KEY} -lt 50 ]; then
PLEROMA_SECRET_KEY="$(create_password 30)$(create_password 30)" PLEROMA_SECRET_KEY="$(create_password 30)$(create_password 30)"
if [ ${#PLEROMA_SECRET_KEY} -lt 50 ]; then if [ ${#PLEROMA_SECRET_KEY} -lt 50 ]; then
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
echo $'Pleroma secret key not created' echo $'Pleroma secret key not created'
exit 6782352 exit 6782352
fi fi
@ -224,6 +226,8 @@ function pleroma_create_database {
chown -R pleroma:pleroma * chown -R pleroma:pleroma *
sudo -u pleroma mix local.rebar --force sudo -u pleroma mix local.rebar --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
echo $'mix local.rebar failed' echo $'mix local.rebar failed'
exit 73528562 exit 73528562
fi fi
@ -231,11 +235,15 @@ function pleroma_create_database {
sudo -u pleroma mix deps.compile mimerl sudo -u pleroma mix deps.compile mimerl
sudo -u pleroma mix ecto.create --force sudo -u pleroma mix ecto.create --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
echo $'mix ecto.create failed' echo $'mix ecto.create failed'
exit 83653582 exit 83653582
fi fi
sudo -u pleroma mix ecto.migrate --force sudo -u pleroma mix ecto.migrate --force
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
echo $'mix ecto.migrate failed' echo $'mix ecto.migrate failed'
exit 73752573 exit 73752573
fi fi