From 9a02f12dfeb6e96cb6732f7fe33024e42096bb3c Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Thu, 3 Oct 2024 04:34:19 +0200
Subject: [PATCH] Improve seedbox setup.

---
 .../seedbox/etc/systemd/system/rtorrent.service | 17 +++++++++++++++++
 bookworm/home_files/seedbox/.rtorrent.rc        | 11 +++++++++++
 bookworm/setup_scripts/setup_seedbox.sh         |  6 +++++-
 3 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 bookworm/etc_files/seedbox/etc/systemd/system/rtorrent.service
 create mode 100644 bookworm/home_files/seedbox/.rtorrent.rc
 mode change 100644 => 100755 bookworm/setup_scripts/setup_seedbox.sh

diff --git a/bookworm/etc_files/seedbox/etc/systemd/system/rtorrent.service b/bookworm/etc_files/seedbox/etc/systemd/system/rtorrent.service
new file mode 100644
index 0000000..babfd36
--- /dev/null
+++ b/bookworm/etc_files/seedbox/etc/systemd/system/rtorrent.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=rtorrent session
+After=network.target
+
+[Service]
+Type=simple
+User=plom
+Group=plom
+WorkingDirectory=/home/plom
+ExecStartPre=-/bin/rm -f /home/plom/session/rtorrent.lock
+ExecStart=/usr/bin/screen -S rtorrent -Dm /usr/bin/rtorrent
+ExecStop=/usr/bin/screen -S rtorrent -X quit
+Restart=on-failure
+RestartSec=3
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bookworm/home_files/seedbox/.rtorrent.rc b/bookworm/home_files/seedbox/.rtorrent.rc
new file mode 100644
index 0000000..2513748
--- /dev/null
+++ b/bookworm/home_files/seedbox/.rtorrent.rc
@@ -0,0 +1,11 @@
+# where to write downloads into
+directory.default.set = ~/downloads
+
+# rtorrent's memory 
+session.path.set = ~/session
+
+# security and paranoia
+dht.mode.set = disable
+protocol.pex.set = no
+protocol.encryption.set = require,require_RC4,allow_incoming,try_outgoing
+
diff --git a/bookworm/setup_scripts/setup_seedbox.sh b/bookworm/setup_scripts/setup_seedbox.sh
old mode 100644
new mode 100755
index b5f9236..7d0cb8b
--- a/bookworm/setup_scripts/setup_seedbox.sh
+++ b/bookworm/setup_scripts/setup_seedbox.sh
@@ -6,5 +6,9 @@ set -e
 expect_setup_finished_file setup_server_has_been_run setup_server.sh
 
 cd "${setup_scripts_dir}"
-# ./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" seedbox
+./copy_dirtree.sh "${config_tree_prefix}/home_files" "" seedbox
+./copy_dirtree.sh "${config_tree_prefix}/etc_files" "" seedbox
 ./install_for_target.sh seedbox
+mkdir /home/plom/{downloads|session}
+chown plom:plom /home/plom/{downloads|session}
+systemctl enable rtorrent.service --now
-- 
2.30.2