#!/bin/sh
#
# linbo_seed
# thomas@linuxmuster.net
# 20250425
#

# no cache, do nothing
[ -e /tmp/linbo-cache.done ] || exit 0

# get environment
source /usr/share/linbo/shell_functions
echo "### $timestamp $(basename "$0") ###"

linbo_mountcache &> /dev/null || exit 1

source /torrent-client.conf || exit 1

cd /cache

RC=0
for torrent in *.torrent; do
    ps w | grep -v grep | grep -q "$torrent" && continue
    ctorrent -e $SEEDHOURS $CTOPTS -f -d "$torrent" || RC=1
    ps w | grep -v grep | grep -q "$torrent" && echo "Started linbo seeder for $torrent."
done

cd

exit $RC
