From 03fe8b1d73ebc23b72062d876140717e75cfc795 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 25 Feb 2020 23:39:33 +0100 Subject: [PATCH] Attempt at script to build Pleroma from source. --- buster/setup_scripts/setup_pleroma_source.sh | 69 ++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 buster/setup_scripts/setup_pleroma_source.sh diff --git a/buster/setup_scripts/setup_pleroma_source.sh b/buster/setup_scripts/setup_pleroma_source.sh new file mode 100755 index 0000000..4f7989c --- /dev/null +++ b/buster/setup_scripts/setup_pleroma_source.sh @@ -0,0 +1,69 @@ +#!/bin/sh +set -e +set -x +# Heavily inspired by + +if [ "$#" -ne 2 ]; then + echo 'Need domain name, mail_address as arguments.' + false +fi +domain="$1" +mail="$2" + +# Install dependencies, set up firewall. +config_tree_prefix="${HOME}/config/buster" +./install_for_target.sh pleroma +./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web +nft -f /etc/nftables.conf + +# Set up letsencrypt certificate. TODO: Is it auto-renewed? +ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default +certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}" +rm /etc/nginx/sites-enabled/default + +# Prepare user. +adduser --system --shell /bin/false --home /opt/pleroma pleroma + +# TODO: integrate this into apt-mark/pleroma +apt -y install elixir erlang-dev erlang-tools erlang-parsetools erlang-eldap erlang-ssh erlang-xmerl build-essential + +mkdir -p /opt/pleroma +chown -R pleroma:pleroma /opt/pleroma +su pleroma -s $SHELL -lc 'git clone -b develop https://git.pleroma.social/pleroma/pleroma /opt/pleroma' +su pleroma -s $SHELL -lc 'mix deps.get' +su pleroma -s $SHELL -lc "mix pleroma.instance gen \ +'--output /etc/pleroma/config.exs \ +--output-psql /tmp/setup_db.psql \ +--domain ${domain} \ +--instance-name plom-roma \ +--admin-email ${mail} \ +--notify-email ${mail} \ +--dbhost localhost \ +--dbname pleroma \ +--dbuser pleroma \ +--rum N \ +--indexable N \ +--uploads-dir /var/lib/pleroma/uploads \ +--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}' +su postgrs -s $SHELL -lc 'psql -f /opt/pleroma/config/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' + +# TODO: config customization, single-pixel hack, info panel, TOS + +# Prepare NGINX config for Pleroma. +cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.nginx +sed -i "s/example\.tld/${domain}/g" /etc/nginx/sites-available/pleroma.nginx +ln -s /etc/nginx/sites-available/pleroma.nginx /etc/nginx/sites-enabled/pleroma.nginx + +# Systemd integration. +cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service +systemctl start pleroma +systemctl enable pleroma + +# Only restart NGINX with Pleroma running. +service nginx restart -- 2.30.2