4 # Heavily inspired by <https://docs-develop.pleroma.social/backend/installation/debian_based_en/>
6 if [ "$#" -ne 2 ]; then
7 echo 'Need domain name, mail_address as arguments.'
13 # Install dependencies, set up firewall.
14 config_tree_prefix="${HOME}/config/buster"
15 ./install_for_target.sh pleroma
16 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web
17 nft -f /etc/nftables.conf
20 adduser --system --group --shell /bin/false --home /var/lib/pleroma pleroma
22 # TODO: integrate this into apt-mark/pleroma
23 apt -y install build-essential #elixir erlang-dev erlang-tools erlang-parsetools erlang-eldap erlang-ssh erlang-xmerl build-essential
25 apt -y install wget gnupg #erlang-inets erlnag-erlware-commons
27 wget -P /tmp/ https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
28 dpkg -i /tmp/erlang-solutions_1.0_all.deb
30 apt -y install elixir erlang-dev erlang-tools erlang-parsetools erlang-eldap erlang-ssh erlang-xmerl
33 chown -R pleroma:pleroma /opt/pleroma
34 su pleroma -s $SHELL -lc 'git clone -b develop https://git.pleroma.social/pleroma/pleroma /opt/pleroma'
35 su pleroma -s $SHELL -lc 'mix local.hex --force'
36 su pleroma -s $SHELL -lc 'mix local.rebar --force'
37 su pleroma -s $SHELL -lc "cd /opt/pleroma &&\
39 mix pleroma.instance gen \
40 --output config/generated_config.exs \
41 --output-psql /tmp/setup_db.psql \
43 --instance-name plom-roma \
44 --admin-email ${mail} \
45 --notify-email ${mail} \
52 --uploads-dir /var/lib/pleroma/uploads \
53 --static-dir /var/lib/pleroma/static \
54 --listen-ip 127.0.0.1 \
56 --dbpass $(pwgen -s 100 1) &&\
57 mv config/{generated_config.exs,prod.secret.exs}"
58 su postgres -s $SHELL -lc 'psql -f /tmp/setup_db.psql'
59 su pleroma -s $SHELL -lc 'cd /opt/pleroma && MIX_ENV=prod mix ecto.migrate'
61 # TODO: config customization, prod.secret.exs
63 # Single-pixel picture hack for removing Pleroma FE images.
64 cp "${config_tree_prefix}/other_files/pixel.png" /var/lib/pleroma/static/
65 chown pleroma:nogroup /var/lib/pleroma/static/pixel.png
68 mkdir -p /var/lib/pleroma/static/instance
69 mkdir -p /var/lib/pleroma/static/static
70 cp "${config_tree_prefix}/other_files/pleroma_panel.html" /var/lib/pleroma/static/instance/panel.html
71 cp "${config_tree_prefix}/other_files/pleroma_terms-of-service.html" /var/lib/pleroma/static/static/terms-of-service.html
73 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
74 ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
75 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
76 rm /etc/nginx/sites-enabled/default
78 # Prepare NGINX config for Pleroma.
79 cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.nginx
80 sed -i "s/example\.tld/${domain}/g" /etc/nginx/sites-available/pleroma.nginx
81 ln -s /etc/nginx/sites-available/pleroma.nginx /etc/nginx/sites-enabled/pleroma.nginx
83 # Systemd integration.
84 cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
85 systemctl start pleroma
86 systemctl enable pleroma
88 # Only restart NGINX with Pleroma running.