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 web pleroma pleroma_otp
15 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web pleroma
16 nft -f /etc/nftables.conf
18 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
19 ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
20 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
21 rm /etc/nginx/sites-enabled/default
24 adduser --system --shell /bin/false --home /opt/pleroma pleroma
26 # Download and unzip latest stable release, set up Pleroma dirs.
27 export FLAVOUR='amd64'
28 su pleroma -s $SHELL -lc "
29 curl 'https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=$FLAVOUR' -o /tmp/pleroma.zip
30 unzip /tmp/pleroma.zip -d /tmp/
32 su pleroma -s $SHELL -lc "
33 mv /tmp/release/* /opt/pleroma
37 mkdir -p /var/lib/pleroma/uploads
38 chown -R pleroma /var/lib/pleroma
40 chown -R pleroma /etc/pleroma
42 # Configure and set up DB.
43 su pleroma -s $SHELL -lc "./bin/pleroma_ctl instance gen \
44 --output /etc/pleroma/config.exs \
45 --output-psql /tmp/setup_db.psql \
47 --instance-name plom-roma \
48 --admin-email ${mail} \
49 --notify-email ${mail} \
55 --uploads-dir /var/lib/pleroma/uploads \
56 --static-dir /var/lib/pleroma/static \
57 --listen-ip 127.0.0.1 \
59 --dbpass $(pwgen -s 100 1)"
60 su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
61 su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
63 # Since the OTP release does not support .secret.exs configuration
64 # files, we hack our own alternative by simply appending custom
65 # configurations to /etc/config.exs.
66 cat "${config_tree_prefix}/other_files/append_pleroma_config" >> /etc/pleroma/config.exs
68 # Single-pixel picture hack for removing Pleroma FE images.
69 cp "${config_tree_prefix}/other_files/pixel.png" /var/lib/pleroma/static/
70 chown pleroma:nogroup /var/lib/pleroma/static/pixel.png
73 #mkdir -p /var/lib/pleroma/static/instance
74 #mkdir -p /var/lib/pleroma/static/static
75 #cp "${config_tree_prefix}/other_files/pleroma_panel.html" /var/lib/pleroma/static/instance/panel.html
76 #cp "${config_tree_prefix}/other_files/pleroma_terms-of-service.html" /var/lib/pleroma/static/static/terms-of-service.html
77 #cp "${config_tree_prefix}/other_files/pleroma_robots.txt" /var/lib/pleroma/static/robots.txt
79 # Prepare NGINX config for Pleroma.
80 cp /opt/pleroma/installation/pleroma.nginx /etc/nginx/sites-available/pleroma.nginx
81 sed -i "s/example\.tld/${domain}/g" /etc/nginx/sites-available/pleroma.nginx
82 ln -s /etc/nginx/sites-available/pleroma.nginx /etc/nginx/sites-enabled/pleroma.nginx
84 # Systemd integration.
85 cp /opt/pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
86 systemctl start pleroma
87 systemctl enable pleroma
89 # Only restart NGINX with Pleroma running.