From 64d3e26d5b4c43ac90f73f28442a4adeb7574c08 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sat, 17 May 2025 23:59:56 +0200 Subject: [PATCH] Fix. --- bookworm/aptmark/seedbox | 2 +- bookworm/copy/all/home/plom/.bashrc | 1 - .../copy/seedbox/etc/systemd/system/rtorrent.service | 12 ++++++------ bookworm/copy/seedbox/home/plom/.bashrc.seedbox | 1 + .../copy/seedbox/home/plom/.local/bin/kill_rtorrent | 11 +++++++++++ testing/copy/desktop/home/plom/.bashrc.desktop | 3 +++ 6 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 bookworm/copy/seedbox/home/plom/.bashrc.seedbox create mode 100755 bookworm/copy/seedbox/home/plom/.local/bin/kill_rtorrent diff --git a/bookworm/aptmark/seedbox b/bookworm/aptmark/seedbox index bf62354..8742dfc 100644 --- a/bookworm/aptmark/seedbox +++ b/bookworm/aptmark/seedbox @@ -1,5 +1,5 @@ # needed for torrenting rtorrent # needed for torrenting session -tmux +dtach # diff --git a/bookworm/copy/all/home/plom/.bashrc b/bookworm/copy/all/home/plom/.bashrc index e748315..e8c939e 100644 --- a/bookworm/copy/all/home/plom/.bashrc +++ b/bookworm/copy/all/home/plom/.bashrc @@ -5,7 +5,6 @@ export VISUAL=vim export EDITOR="${VISUAL}" # Some helpful aliases. -alias curlpost='curl -H "Content-Type: application/json" -X POST' alias ls="ls --color=auto" # Colored prompt with username, hostname, date/time, directory. diff --git a/bookworm/copy/seedbox/etc/systemd/system/rtorrent.service b/bookworm/copy/seedbox/etc/systemd/system/rtorrent.service index a8a91f3..a62e124 100644 --- a/bookworm/copy/seedbox/etc/systemd/system/rtorrent.service +++ b/bookworm/copy/seedbox/etc/systemd/system/rtorrent.service @@ -1,15 +1,15 @@ [Unit] -Description=rtorrent in tmux session +Description=rtorrent dtached After=network.target [Service] -Type=forking +Type=simple User=plom WorkingDirectory=/home/plom -ExecStartPre=-/bin/rm -f /home/plom/session/rtorrent.lock -ExecStart=/usr/bin/tmux new-session -d -s rtorrent_tmux /usr/bin/rtorrent -ExecStop=/usr/bin/tmux kill-session -t rtorrent_tmux -Restart=always +ExecStart=/bin/sh -lc "rm -rf session/rtorrent.lock && dtach -n /tmp/dtach_rtorrent rtorrent && while true; do sleep 1; test ! -e /tmp/dtach_rtorrent && break; done" +ExecStop=/bin/sh -lc kill_rtorrent +Environment=TERM=linux +Restart=on-success RestartSec=10 [Install] diff --git a/bookworm/copy/seedbox/home/plom/.bashrc.seedbox b/bookworm/copy/seedbox/home/plom/.bashrc.seedbox new file mode 100644 index 0000000..e9f3dc6 --- /dev/null +++ b/bookworm/copy/seedbox/home/plom/.bashrc.seedbox @@ -0,0 +1 @@ +alias attach_rtorrent='dtach -a /tmp/dtach_rtorrent -e "^t"' diff --git a/bookworm/copy/seedbox/home/plom/.local/bin/kill_rtorrent b/bookworm/copy/seedbox/home/plom/.local/bin/kill_rtorrent new file mode 100755 index 0000000..79bbdaa --- /dev/null +++ b/bookworm/copy/seedbox/home/plom/.local/bin/kill_rtorrent @@ -0,0 +1,11 @@ +#!/bin/sh +set -e + +PIDs=$(ps hao 'pid comm' | grep -E '^[[:blank:]]*[[:digit:]]+ rtorrent$' | sed -E 's/^[[:blank:]]+([[:digit:]]+).*$/\1/g') +if [ ! -z "${PIDs}" ]; then + echo "Killing $(echo ${PIDs} | wc -w) instance(s)." + kill -9 "${PIDs}" +else + echo 'Nothing to kill.' +fi +rm -rf /tmp/dtach_rtorrent diff --git a/testing/copy/desktop/home/plom/.bashrc.desktop b/testing/copy/desktop/home/plom/.bashrc.desktop index baa8d8b..e793719 100644 --- a/testing/copy/desktop/home/plom/.bashrc.desktop +++ b/testing/copy/desktop/home/plom/.bashrc.desktop @@ -2,3 +2,6 @@ # a non-existing "en" layout alias kb_de="swaymsg 'input * xkb_layout de'" alias kb_us="swaymsg 'input * xkb_layout us'" + +# miscellaneaous +alias curlpost='curl -H "Content-Type: application/json" -X POST' -- 2.30.2