su pleroma -s $SHELL -lc 'git clone -b develop https://git.pleroma.social/pleroma/pleroma /opt/pleroma'
su pleroma -s $SHELL -lc 'mix local.hex --force'
su pleroma -s $SHELL -lc 'mix local.rebar --force'
-su pleroma -s $SHELL -lc 'mix deps.get'
-su pleroma -s $SHELL -lc "mix pleroma.instance gen \
+su pleroma -s $SHELL -lc "cd /opt/pleroma &&\
+mix deps.get &&\
+mix pleroma.instance gen \
--output config/generated_config.exs \
--output-psql /tmp/setup_db.psql \
--domain ${domain} \
--static-dir /var/lib/pleroma/static \
--listen-ip 127.0.0.1 \
--listen-port 4000 \
---dbpass $(pwgen -s 100 1)"
-su pleroma -s $SHELL -lc 'mv config/{generated_config.exs,prod.secret.exs}'
+--dbpass $(pwgen -s 100 1) &&\
+mv config/{generated_config.exs,prod.secret.exs}"
su postgres -s $SHELL -lc 'psql -f /tmp/setup_db.psql'
-su pleroma -s $SHELL -lc 'MIX_ENV=prod mix ecto.migrate'
-#su pleroma -s $SHELL -lc 'MIX_ENV=prod mix phx.server'
+su pleroma -s $SHELL -lc 'cd /opt/pleroma && MIX_ENV=prod mix ecto.migrate'
-# TODO: config customization, single-pixel hack, info panel, TOS
-# config dev.secret.exs
+# TODO: config customization, prod.secret.exs
+
+# Single-pixel picture hack for removing Pleroma FE images.
+cp "${config_tree_prefix}/other_files/pixel.png" /var/lib/pleroma/static/
+chown pleroma:nogroup /var/lib/pleroma/static/pixel.png
+
+# Info panel and TOS.
+mkdir -p /var/lib/pleroma/static/instance
+mkdir -p /var/lib/pleroma/static/static
+cp "${config_tree_prefix}/other_files/pleroma_panel.html" /var/lib/pleroma/static/instance/panel.html
+cp "${config_tree_prefix}/other_files/pleroma_terms-of-service.html" /var/lib/pleroma/static/static/terms-of-service.html
# Set up letsencrypt certificate. TODO: Is it auto-renewed?
ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default