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} \
56 --uploads-dir /var/lib/pleroma/uploads \
57 --static-dir /var/lib/pleroma/static \
58 --listen-ip 127.0.0.1 \
60 --dbpass $(pwgen -s 100 1)"
61 su postgres -s $SHELL -lc "psql -f /tmp/setup_db.psql"
62 su pleroma -s $SHELL -lc "./bin/pleroma_ctl migrate"
64 # Since the OTP release does not support .secret.exs configuration
65 # files, we hack our own alternative by simply appending custom
66 # configurations to /etc/config.exs.
67 cat "${config_tree_prefix}/other_files/append_pleroma_config" >> /etc/pleroma/config.exs
69 # Single-pixel picture hack for removing Pleroma FE images.
70 cp "${config_tree_prefix}/other_files/pixel.png" /var/lib/pleroma/static/
71 chown pleroma:nogroup /var/lib/pleroma/static/pixel.png
74 #mkdir -p /var/lib/pleroma/static/instance
75 #mkdir -p /var/lib/pleroma/static/static
76 #cp "${config_tree_prefix}/other_files/pleroma_panel.html" /var/lib/pleroma/static/instance/panel.html
77 #cp "${config_tree_prefix}/other_files/pleroma_terms-of-service.html" /var/lib/pleroma/static/static/terms-of-service.html
78 #cp "${config_tree_prefix}/other_files/pleroma_robots.txt" /var/lib/pleroma/static/robots.txt
80 # Hack to fix <https://git.pleroma.social/pleroma/pleroma/issues/1616>
81 curl https://git.pleroma.social/pleroma/pleroma/-/raw/4271cfb81a8983f5ec6a878cab1fb3fbd164245d/priv/static/static/static-fe.css?inline=false >> /var/lib/pleroma/static/static/static-fe.css
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.