From 044f14371b60d9a85a48822d940bac89cd644ba1 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sat, 24 Dec 2022 18:12:50 +0100
Subject: [PATCH] Improve microblog.pub setup.

---
 bullseye/apt-mark/microblogpub               | 10 ++++++++++
 bullseye/setup_scripts/setup_microblogpub.sh | 16 ++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/bullseye/apt-mark/microblogpub b/bullseye/apt-mark/microblogpub
index feeff57..e2688e8 100644
--- a/bullseye/apt-mark/microblogpub
+++ b/bullseye/apt-mark/microblogpub
@@ -1,4 +1,14 @@
 # to get python3.11 tgz
 wget
+build-essential
+zlib1g-dev
+libncurses5-dev
+libgdbm-dev
+libnss3-dev
+libssl-dev
+libreadline-dev
+libffi-dev
+libsqlite3-dev
+libbz2-dev
 # to set up poetry
 curl
diff --git a/bullseye/setup_scripts/setup_microblogpub.sh b/bullseye/setup_scripts/setup_microblogpub.sh
index 5bc6830..60f3c57 100755
--- a/bullseye/setup_scripts/setup_microblogpub.sh
+++ b/bullseye/setup_scripts/setup_microblogpub.sh
@@ -11,8 +11,9 @@ mail="$2"
 
 # Install configs, set up firewall.
 config_tree_prefix="${HOME}/config/bullseye"
-./install_for_target.sh web
+./install_for_target.sh web microblogpub
 ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" web microblogpub
+apt update  # since we just updated /etc/apt/sources.list
 nft -f /etc/nftables.conf
 
 # Set up letsencrypt certificate. TODO: Is it auto-renewed?
@@ -20,16 +21,23 @@ ln -sf /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
 certbot --nginx --agree-tos --redirect --no-eff-email -m "${mail}" -d "${domain}"
 rm /etc/nginx/sites-enabled/default
 
-# Install Python 3.10 from source (Bullseye only has 3.9).
-apt build-dep python3
+# Install Python >=3.10 from source (Bullseye only has 3.9).
 python_version=3.11.1
 python_dirname="Python-${python_version}"
 su -lc "wget https://www.python.org/ftp/python/${python_version}/${python_dirname}.tgz" plom
 su -lc "tar -xvf ${python_dirname}.tgz" plom
-su -lc "cd ${python_dirname} && ./configure && make && make test"
+su -lc "cd /home/plom/${python_dirname} && ./configure --enable-optimizations && make && make test"
 cd /home/plom/${python_dirname}/
 make altinstall
 cd
+# TODO delete python build dir
+su -lc "curl -sSL https://install.python-poetry.org | python3" - plom
+su -lc "git clone https://git.sr.ht/~tsileo/microblog.pub testing.microblog.pub" - plom
+su -lc "poetry config installer.parallel false" - plom
+su -lc "cd testing.microblog.pub && poetry install" - plom
+su -lc "cd testing.microblog.pub && poetry run inv configuration-wizard" - plom
+su -lc "cd testing.microblog.pub && poetry run inv migrate-db" - plom
+# VENV_DIR=/home/ubuntu/.cache/pypoetry/virtualenvs/microblogpub-chx-y1oE-py3.10 poetry run supervisord -c misc/supervisord.conf -n
 
 # Prepare and start NGINX config.
 sed -i "s/REPLACE_fqdn_ECALPER/${domain}/g" /etc/nginx/sites-available/microblogpub.nginx
-- 
2.30.2