Move pleroma to production config

This commit is contained in:
Bob Mottram 2018-01-09 18:19:28 +00:00
parent 5fc93dfe25
commit 0982180705
1 changed files with 12 additions and 3 deletions

View File

@ -227,11 +227,12 @@ function pleroma_create_database {
echo $"Missing directory $PLEROMA_DIR/config" echo $"Missing directory $PLEROMA_DIR/config"
exit 7835393 exit 7835393
fi fi
pleroma_secret=$PLEROMA_DIR/config/dev.secret.exs pleroma_secret=$PLEROMA_DIR/config/prod.secret.exs
if [ ! -f $PLEROMA_DIR/config/dev.exs ]; then if [ ! -f $PLEROMA_DIR/config/dev.exs ]; then
echo $"Did not find $PLEROMA_DIR/config/dev.exs" echo $"Did not find $PLEROMA_DIR/config/dev.exs"
exit 78923528 exit 78923528
fi fi
cp $PLEROMA_DIR/config/dev.exs $pleroma_secret cp $PLEROMA_DIR/config/dev.exs $pleroma_secret
sed -i "s|username:.*|username: \"pleroma\",|g" $pleroma_secret sed -i "s|username:.*|username: \"pleroma\",|g" $pleroma_secret
sed -i "s|password:.*|password: \"$PLEROMA_ADMIN_PASSWORD\",|g" $pleroma_secret sed -i "s|password:.*|password: \"$PLEROMA_ADMIN_PASSWORD\",|g" $pleroma_secret
@ -272,13 +273,20 @@ function pleroma_create_database {
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_ENV=prod 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 NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;" run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
echo $'mix ecto.migrate failed' echo $'mix ecto.migrate failed'
exit 73752573 exit 73752573
fi fi
sudo -u pleroma MIX_ENV=prod mix phx.digest --force
if [ ! "$?" = "0" ]; then
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
run_system_query_postgresql "ALTER USER pleroma NOCREATEDB;"
echo $'mix phx.digest failed'
exit 783529235
fi
# revoke the ability to create databases for this user # revoke the ability to create databases for this user
run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;" run_system_query_postgresql "ALTER USER pleroma NOSUPERUSER;"
@ -878,7 +886,7 @@ function install_pleroma {
# We need to set up the url option again because it somehow gets # We need to set up the url option again because it somehow gets
# lost during mix compile # lost during mix compile
pleroma_secret=$PLEROMA_DIR/config/dev.secret.exs pleroma_secret=$PLEROMA_DIR/config/prod.secret.exs
if ! grep -q 'watchers: [],' $pleroma_secret; then if ! grep -q 'watchers: [],' $pleroma_secret; then
sed -i 's|watchers: []|watchers: [],|g' $pleroma_secret sed -i 's|watchers: []|watchers: [],|g' $pleroma_secret
fi fi
@ -899,6 +907,7 @@ function install_pleroma {
echo 'User=pleroma' >> /etc/systemd/system/pleroma.service echo 'User=pleroma' >> /etc/systemd/system/pleroma.service
echo "WorkingDirectory=$PLEROMA_DIR" >> /etc/systemd/system/pleroma.service echo "WorkingDirectory=$PLEROMA_DIR" >> /etc/systemd/system/pleroma.service
echo "Environment=\"HOME=$PLEROMA_DIR\"" >> /etc/systemd/system/pleroma.service echo "Environment=\"HOME=$PLEROMA_DIR\"" >> /etc/systemd/system/pleroma.service
echo "Environment=\"MIX_ENV=prod\"" >> /etc/systemd/system/pleroma.service
echo 'ExecStart=/usr/local/bin/mix phx.server' >> /etc/systemd/system/pleroma.service echo 'ExecStart=/usr/local/bin/mix phx.server' >> /etc/systemd/system/pleroma.service
echo 'ExecReload=/bin/kill $MAINPID' >> /etc/systemd/system/pleroma.service echo 'ExecReload=/bin/kill $MAINPID' >> /etc/systemd/system/pleroma.service
echo 'KillMode=process' >> /etc/systemd/system/pleroma.service echo 'KillMode=process' >> /etc/systemd/system/pleroma.service