From 6afd802003de473c7adc5e7e0ff860e220c70031 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 24 Oct 2023 21:15:47 +0200 Subject: [PATCH] Add soju_setup --- scripts/p7s/soju.py | 45 ++++++++++++++++++++++++++++++++++++++++++ scripts/pyproject.toml | 1 + 2 files changed, 46 insertions(+) create mode 100644 scripts/p7s/soju.py diff --git a/scripts/p7s/soju.py b/scripts/p7s/soju.py new file mode 100644 index 0000000..1b45c70 --- /dev/null +++ b/scripts/p7s/soju.py @@ -0,0 +1,45 @@ +import pathlib +import textwrap + + +def setup_soju(): + home = pathlib.Path.home() + config = home / ".config" / "containers" / "systemd" + config.mkdir(parents=True, exist_ok=True) + (config / "soju.container").write_text(textwrap.dedent(""" + [Unit] + Description=IRC Bouncer + + [Container] + Image=quay.io/alexpdp7/workstation:latest + Volume=/home/alex/.config/containers/systemd/soju_config:/etc/soju/config + Volume=/home/alex/.local/lib/soju:/var/lib/soju/ + SecurityLabelDisable=true + Network=host + + Exec=soju + + [Service] + # Extend Timeout to allow time to pull the image + TimeoutStartSec=900 + + [Install] + # Start by default on boot + WantedBy=multi-user.target default.target + """).lstrip()) + + (config / "soju_config").write_text(textwrap.dedent(""" + db sqlite3 /var/lib/soju/main.db + message-store fs /var/lib/soju/logs/ + listen irc+insecure://0.0.0.0:6667 + """).lstrip()) + + (home / ".local" / "lib" / "soju").mkdir(parents=True, exist_ok=True) + + sojudb_wrapper = (home / ".local" / "bin" / "sojudb") + sojudb_wrapper.write_text(textwrap.dedent(""" + #!/bin/sh + + podman run -it --rm --security-opt label=disable -v ~/.config/containers/systemd/soju_config:/etc/soju/config -v ~/.local/lib/soju/:/var/lib/soju quay.io/alexpdp7/workstation:latest sojudb "$@" + """).lstrip()) + sojudb_wrapper.chmod(0o755) diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml index 2adaf4e..51aa351 100644 --- a/scripts/pyproject.toml +++ b/scripts/pyproject.toml @@ -21,3 +21,4 @@ mbsync_config = 'p7s.mail:generate_config' db-create = 'p7s.distrobox:create' db-enter = 'p7s.distrobox:enter' nextcloud_setup = 'p7s.nextcloud:setup_nextcloud' +soju_setup = 'p7s.soju:setup_soju' -- 2.47.3