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, configs, set up firewall.
14 config_tree_prefix="${HOME}/config/buster"
15 ./install_for_target.sh web pleroma pleroma_source
16 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web pleroma
17 nft -f /etc/nftables.conf
20 adduser --system --group --shell /bin/false --home /var/lib/pleroma pleroma
23 wget -P /tmp/ https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb
24 dpkg -i /tmp/erlang-solutions_1.0_all.deb
26 apt -y install elixir erlang-dev erlang-tools erlang-parsetools erlang-eldap erlang-ssh erlang-xmerl
29 chown -R pleroma:pleroma /opt/pleroma
30 su pleroma -s $SHELL -lc 'git clone -b develop https://git.pleroma.social/pleroma/pleroma /opt/pleroma'
31 su pleroma -s $SHELL -lc 'mix local.hex --force'
32 su pleroma -s $SHELL -lc 'mix local.rebar --force'
33 su pleroma -s $SHELL -lc "cd /opt/pleroma &&\
35 mix pleroma.instance gen \
36 --output config/generated_config.exs \
37 --output-psql /tmp/setup_db.psql \
39 --instance-name plomroma \
40 --admin-email ${mail} \
41 --notify-email ${mail} \
48 --uploads-dir /var/lib/pleroma/uploads \
49 --static-dir /var/lib/pleroma/static \
50 --listen-ip 127.0.0.1 \
52 --dbpass $(pwgen -s 100 1) &&\
53 mv config/{generated_config.exs,prod.secret.exs}"
54 su postgres -s $SHELL -lc 'psql -f /tmp/setup_db.psql'
55 su pleroma -s $SHELL -lc 'cd /opt/pleroma && MIX_ENV=prod mix ecto.migrate'
57 # Add our own plom.exs and import it to prod.secret.exs
58 echo '' >> /opt/pleroma/config/prod.secret.exs
59 echo 'import_config "plom.exs"' >> /opt/pleroma/config/prod.secret.exs
60 echo 'import Config' > /opt/pleroma/config/plom.exs
61 cat "${config_tree_prefix}/other_files/append_pleroma_config" >> /opt/pleroma/config/plom.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
72 #cp "${config_tree_prefix}/other_files/pleroma_robots.txt" /var/lib/pleroma/static/robots.txt
74 # Upload directory. For some reason this does not exist yet here.
75 mkdir -p /var/lib/pleroma/uploads
76 chown pleroma:nogroup /var/lib/pleroma/uploads
78 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
79 ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
80 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
81 rm /etc/nginx/sites-enabled/default
83 # Prepare NGINX config for Pleroma.
84 cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.nginx
85 sed -i "s/example\.tld/${domain}/g" /etc/nginx/sites-available/pleroma.nginx
86 ln -s /etc/nginx/sites-available/pleroma.nginx /etc/nginx/sites-enabled/pleroma.nginx
88 # Systemd integration.
89 cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
90 systemctl start pleroma
91 systemctl enable pleroma
93 # Only restart NGINX with Pleroma running.