home · contact · privacy
60f3c5798e4b5e336083fe65efddb9bbfdcaeb37
[config] / bullseye / setup_scripts / setup_microblogpub.sh
1 #!/bin/sh
2 set -e
3 set -x
4
5 if [ "$#" -ne 2 ]; then
6     echo 'Need domain name and mail.'
7     false
8 fi
9 domain="$1"
10 mail="$2"
11
12 # Install configs, set up firewall.
13 config_tree_prefix="${HOME}/config/bullseye"
14 ./install_for_target.sh web microblogpub
15 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web microblogpub
16 apt update  # since we just updated /etc/apt/sources.list
17 nft -f /etc/nftables.conf
18
19 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
20 ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
21 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
22 rm /etc/nginx/sites-enabled/default
23
24 # Install Python >=3.10 from source (Bullseye only has 3.9).
25 python_version=3.11.1
26 python_dirname="Python-${python_version}"
27 su -lc "wget https://www.python.org/ftp/python/${python_version}/${python_dirname}.tgz" plom
28 su -lc "tar -xvf ${python_dirname}.tgz" plom
29 su -lc "cd /home/plom/${python_dirname} && ./configure --enable-optimizations && make && make test"
30 cd /home/plom/${python_dirname}/
31 make altinstall
32 cd
33 # TODO delete python build dir
34 su -lc "curl -sSL https://install.python-poetry.org | python3" - plom
35 su -lc "git clone https://git.sr.ht/~tsileo/microblog.pub testing.microblog.pub" - plom
36 su -lc "poetry config installer.parallel false" - plom
37 su -lc "cd testing.microblog.pub && poetry install" - plom
38 su -lc "cd testing.microblog.pub && poetry run inv configuration-wizard" - plom
39 su -lc "cd testing.microblog.pub && poetry run inv migrate-db" - plom
40 # VENV_DIR=/home/ubuntu/.cache/pypoetry/virtualenvs/microblogpub-chx-y1oE-py3.10 poetry run supervisord -c misc/supervisord.conf -n
41
42 # Prepare and start NGINX config.
43 sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/microblogpub.nginx
44 ln -s /etc/nginx/sites-available/microblogpub.nginx /etc/nginx/sites-enabled/microblogpub.nginx
45 service nginx restart