3 # Heavily inspired by <https://docs.pleroma.social/otp_en.html>
5 if [ "$#" -ne 2 ]; then
6 echo 'Need domain name, mail_address as arguments.'
12 # Install dependencies, set up firewall.
13 config_tree_prefix="${HOME}/config/buster"
14 ./install_for_target.sh pleroma
15 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" pleroma
16 nft -f /etc/nftables.conf
18 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
19 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
22 adduser --system --shell /bin/false --home /opt/pleroma pleroma
24 # Download and unzip latest stable release, set up Pleroma dirs.
25 export FLAVOUR='amd64'
26 su pleroma -s $SHELL -lc "
27 curl 'https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=$FLAVOUR' -o /tmp/pleroma.zip
28 unzip /tmp/pleroma.zip -d /tmp/
30 su pleroma -s $SHELL -lc "
31 mv /tmp/release/* /opt/pleroma
35 mkdir -p /var/lib/pleroma/uploads
36 chown -R pleroma /var/lib/pleroma
38 chown -R pleroma /etc/pleroma
40 # Configure and set up DB.
41 su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen \
42 --output /etc/pleroma/config.exs \
43 --output-psql /tmp/setup_db.psql \
45 --instance-name plom-roma \
46 --admin-email ${mail} \
47 --notify-email ${mail} \
53 --uploads-dir /var/lib/pleroma/uploads \
54 --static-dir /var/lib/pleroma/static \
55 --listen-ip 127.0.0.1 \
57 --dbpass $(pwgen -s 100 1)"
58 su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
59 su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
61 # Since the OTP release does not support .secret.exs configuration
62 # files, we hack our own alternative by simply appending custom
63 # configurations to /etc/config.exs.
64 cat "${config_tree_prefix}/other_files/append_pleroma_config" >> /etc/config.exs
66 # Prepare NGINX config for Pleroma.
67 cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.nginx
68 sed -i "s/example\.tld/${domain}/g" /etc/nginx/sites-available/pleroma.nginx
69 ln -s /etc/nginx/sites-available/pleroma.nginx /etc/nginx/sites-enabled/pleroma.nginx
70 rm /etc/nginx/sites-enabled/default
72 # Systemd integration.
73 cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
74 systemctl start pleroma
75 systemctl enable pleroma
77 # Only restart NGINX with Pleroma running.