Diese Anleitung erklärt, wie man ctorrent mit ctcs installiert.
Leider läuft der ctorrent nicht ganz rund und verbraucht viele Ressourcen. Sehr gute Erfahrungen habe ich mit Transmission gemacht (siehe Anleitungen).
Installation von ctorrent
Compiler installieren
apt-get install build-essential
Sourcen ziehen und kompilieren
wget http://downloads.sourceforge.net/dtorrent/ctorrent-dnh3.3.2.tar.gztar xzvf ctorrent-dnh3.3.2.tar.gz
apt-get install openssl libssl-dev
cd ctorrent-dnh3.3.2
./configure
make
make install
Installation von ctorrent-control-server
apt-get install psmisc perl cronwget http://downloads.sourceforge.net/dtorrent/ctcs-1.4.1.tar.gz
tar xzvf ctcs-1.4.1.tar.gz
cd ctcs-1.4.1
mv ctcs /usr/local/bin
chmod 755 /usr/local/bin/ctcs
chown root:staff /usr/local/bin/ctcs
In /usr/local/bin/ die torrent.sh erstellen (Inhalt weiter unten in diesem Dokument), dann
chmod 777 /usr/local/bin/torrent.sh
In die crontab
crontab -e
folgendes hinzufügen:
*/5 * * * * /usr/local/bin/torrent.sh
In /etc/init.d/ das Skript ctcs erstellen
Inhalt s.u.
Zum Schluss noch folgendes:
chmod 777 /etc/init.d/ctcscd /etc/rc2.d
ln -s ../init.d/ctcs S99ctcs
/etc/init.d/ctcs start
Dann sollte der ctcs und auch der ctorrent laufen und erreichbar sein: http://sheevaIP:2780
Dateien torrent.sh und ctcs
Daruaf achten, dass unter Windows ein Linux kompatible Editor verwendet wird, wie bspw. EditPad Lite. Die Pfade müssen auch noch angepasst werden.
Inhalt der torrent.sh
#!/bin/bash# ND: Verzeichnis, in das neue .torrent Dateien gespeichert werden:
ND="/home/torrent/new"
# RD: Verzeichnis, in das die Torrent-Daten gespeichert werden
RD="/home/torrent/running"
# FD: Verzeichnis, in das die .torrent Dateien + die Logs nach der Fertigstellung gespeichert werden
FD="/home/torrent/finished"
# CT: voller Pfad zu ctorrent
CT=/usr/local/bin/ctorrent
# CTCS_PORT: Port des CTCS Servers (default: 2780)
CTCS_PORT=2780
# CT_PORT: Port fuer den ctorrent client (default: 6881)
CT_PORT=6881
# CACHE: Groesse des ctorrent Zwischenspeichers in MB (default: 1)
CACHE=2
# Erstelle Verzeichnisse, falls sie noch nicht existieren
if [ ! -d "$ND" ]
then
mkdir -p "$ND"
fi
if [ ! -d "$RD" ]
then
mkdir -p "$RD"
fi
if [ ! -d "$FD" ]
then
mkdir -p "$FD"
fi
(IFS=$'\n'; for torrent in `/usr/bin/find "$ND" -name "*.torrent"`
do
# Prüft ob torrent.pid vorhanden
if [ ! -e "$torrent.pid" ]
then
# Wenn torrent.pid nicht vorhanden wird *.torrent gestartet
cd "$RD"
$CT "$torrent" -E 2.0 -e 10 -S localhost:$CTCS_PORT -p $CT_PORT -C $CACHE > "$torrent.log" 2> "$torrent.error" &
echo "`date` : Added $torrent" >> "$ND/log.txt"
ps a | grep "$torrent" | head -c 5 | tr -d [:blank:] > "$torrent.pid"
else
# Wenn torrent.pid vorhanden wird überprüft ob Prozess noch läuft bzw. der torrent beendet ist
PID=`cat "$torrent.pid"`
# RUNNING=`ps -A | grep $PID | head -n 1 | tr -d [:blank:]`
RUNNING=`ps -A | grep $PID | head -n 1`
echo $RUNNING
if [ ! $RUNNING ]
then
# Wenn torrent beendet werden die entsprechenden Datein verschoben bzw. gelöscht
chmod 777 "$torrent"
mv "$torrent" "$FD"
rm "$torrent.log"
rm "$torrent.error"
rm "$torrent.pid"
echo "`date`: $torrent finished" >> "$ND/log.txt"
fi
fi
done) # Klammer nicht vergessen!
Inhalt der ctcs
#!/bin/sh
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="CTCS CTorrent Control Server"
NAME=ctcs
DAEMON=/usr/local/bin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
#Function that starts the daemon/service.
#
d_start() {
start-stop-daemon --start --background --quiet \
--exec $DAEMON
}
#
#Function that stops the daemon/service.
#
d_stop() {
killall ctcs
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Quellen:
http://ctorrent.sourceforge.net/?action=installation





