From 6797c7010cdf48a198f14463fe33578733e63a7b Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Tue, 3 Jan 2023 00:23:08 +0100
Subject: [PATCH] Improve microblog.pub setup.

---
 .../microblogpub/etc/systemd/system/microblogpub.service       | 2 +-
 bullseye/setup_scripts/setup_microblogpub.sh                   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub.service b/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub.service
index 7a64014..441129d 100644
--- a/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub.service
+++ b/bullseye/etc_files/microblogpub/etc/systemd/system/microblogpub.service
@@ -6,7 +6,7 @@ Type=simple
 User=plom
 WorkingDirectory=/home/plom/testing.microblog.pub/
 ExecStart=/bin/sh -c 'poetry run supervisord -c misc/supervisord.conf -n'
-Environment=VENV_DIR=REPLACE_venv_dir_ECALPER
+Environment=VENV_DIR=/home/plom/.cache/pypoetry/virtualenvs/REPLACE_venv_dir_ECALPER
 Restart=always
 
 [Install]
diff --git a/bullseye/setup_scripts/setup_microblogpub.sh b/bullseye/setup_scripts/setup_microblogpub.sh
index 2c057af..67c7262 100755
--- a/bullseye/setup_scripts/setup_microblogpub.sh
+++ b/bullseye/setup_scripts/setup_microblogpub.sh
@@ -41,7 +41,8 @@ su -lPc "cd testing.microblog.pub && poetry run inv configuration-wizard" - plom
 su -lPc "cd testing.microblog.pub && poetry run inv migrate-db" - plom
 
 # Set up microblog.pub daemon service.
-venv_dir=$( su -lPc "cd testing.microblog.pub && poetry env info" - plom | grep 'Path' | head -1 | awk '{print $2}')
+venv_dir_path=$( su -lPc "cd testing.microblog.pub && poetry env info" - plom | grep 'Path' | head -1 | awk '{print $2}')
+venv_dir=$(basename ${venv_dir_path})
 sed -i "s/REPLACE_venv_dir_ECALPER/${venv_dir}/g" /etc/systemd/system/microblogpub.service
 systemctl enable microblogpub.service
 service microblogpub start
-- 
2.30.2