5 if [ "$#" -ne 2 ]; then
6 echo 'Need domain name and mail.'
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
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
24 # Install Python >=3.10 from source (Bullseye only has 3.9).
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"
30 cd /home/plom/${python_dirname}/
33 rm -rf /home/plom/${python_dirname}
35 # Configure/install Poetry and microblog.pub.
36 su -lc "curl -sSL https://install.python-poetry.org | python3.11" - plom
37 su -lc "git clone https://git.sr.ht/~tsileo/microblog.pub testing.microblog.pub" - plom
38 su -lc "poetry config installer.parallel false" - plom
39 su -lc "cd testing.microblog.pub && poetry install" - plom
40 su -lPc "cd testing.microblog.pub && poetry run inv configuration-wizard" - plom
41 su -lPc "cd testing.microblog.pub && poetry run inv migrate-db" - plom
43 # Set up microblog.pub daemon service.
44 venv_dir_path=$( su -lPc "cd testing.microblog.pub && poetry env info" - plom | grep 'Path' | head -1 | awk '{print $2}')
45 venv_dir=$(basename ${venv_dir_path})
46 sed -i "s/REPLACE_venv_dir_ECALPER/${venv_dir}/g" /etc/systemd/system/microblogpub.service
47 systemctl enable microblogpub.service
48 service microblogpub start
50 # Prepare and start NGINX config.
51 sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/microblogpub.nginx
52 ln -s /etc/nginx/sites-available/microblogpub.nginx /etc/nginx/sites-enabled/microblogpub.nginx