From 993bb25a06251b8be5d5da0b4271bbbde93ebf41 Mon Sep 17 00:00:00 2001 From: Wonderfall Date: Fri, 9 Sep 2016 17:52:00 +0200 Subject: [PATCH] add rtorrent-flood image --- rtorrent-flood/Dockerfile | 99 ++++++++++++++++++++++++++++++++++ rtorrent-flood/README.md | 16 ++++++ rtorrent-flood/config.js | 16 ++++++ rtorrent-flood/postdl | 10 ++++ rtorrent-flood/postrm | 3 ++ rtorrent-flood/rtorrent.rc | 22 ++++++++ rtorrent-flood/startup | 16 ++++++ rtorrent-flood/supervisord.ini | 18 +++++++ 8 files changed, 200 insertions(+) create mode 100644 rtorrent-flood/Dockerfile create mode 100644 rtorrent-flood/README.md create mode 100644 rtorrent-flood/config.js create mode 100644 rtorrent-flood/postdl create mode 100644 rtorrent-flood/postrm create mode 100644 rtorrent-flood/rtorrent.rc create mode 100644 rtorrent-flood/startup create mode 100644 rtorrent-flood/supervisord.ini diff --git a/rtorrent-flood/Dockerfile b/rtorrent-flood/Dockerfile new file mode 100644 index 0000000..545e8b8 --- /dev/null +++ b/rtorrent-flood/Dockerfile @@ -0,0 +1,99 @@ +FROM wonderfall/node:stable +MAINTAINER Wonderfall + +ARG MEDIAINFO_VER=0.7.88 +ARG RTORRENT_VER=0.9.6 +ARG LIBTORRENT_VER=0.13.6 +ARG FILEBOT_VER=4.7.2 +ARG BUILD_CORES + +ENV UID=991 \ + GID=991 \ + FLOOD_SECRET=supersecret \ + PKG_CONFIG_PATH=/usr/local/lib/pkgconfig + +RUN echo "@commuedge https://nl.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ + && NB_CORES=${BUILD_CORES-`getconf _NPROCESSORS_CONF`} \ + && BUILD_DEPS=" \ + build-base \ + git \ + libtool \ + automake \ + autoconf \ + wget \ + tar \ + subversion \ + cppunit-dev \ + openssl-dev \ + ncurses-dev \ + curl-dev \ + binutils" \ + && apk -U add \ + ${BUILD_DEPS} \ + ffmpeg \ + ca-certificates \ + curl \ + gzip \ + zip \ + unrar \ + supervisor \ + geoip \ + tini@commuedge \ + openjdk8-jre@commuedge \ + && cd /tmp \ + && wget -q http://downloads.sourceforge.net/mktorrent/mktorrent-1.0.tar.gz \ + && tar xzvf mktorrent-1.0.tar.gz \ + && svn checkout http://svn.code.sf.net/p/xmlrpc-c/code/stable xmlrpc-c \ + && mkdir libtorrent rtorrent \ + && cd libtorrent && wget -qO- https://github.com/rakshasa/libtorrent/archive/${LIBTORRENT_VER}.tar.gz | tar xz --strip 1 \ + && cd ../rtorrent && wget -qO- https://github.com/rakshasa/rtorrent/archive/${RTORRENT_VER}.tar.gz | tar xz --strip 1 \ + && cd /tmp \ + && wget -q http://mediaarea.net/download/binary/mediainfo/${MEDIAINFO_VER}/MediaInfo_CLI_${MEDIAINFO_VER}_GNU_FromSource.tar.gz \ + && wget -q http://mediaarea.net/download/binary/libmediainfo0/${MEDIAINFO_VER}/MediaInfo_DLL_${MEDIAINFO_VER}_GNU_FromSource.tar.gz \ + && tar xzf MediaInfo_DLL_${MEDIAINFO_VER}_GNU_FromSource.tar.gz \ + && tar xzf MediaInfo_CLI_${MEDIAINFO_VER}_GNU_FromSource.tar.gz \ + && tar xzvf mktorrent-1.0.tar.gz \ + && cd /tmp/mktorrent-1.0 && make -j ${NB_CORES} && make install \ + && cd /tmp/MediaInfo_DLL_GNU_FromSource && ./SO_Compile.sh \ + && cd /tmp/MediaInfo_DLL_GNU_FromSource/ZenLib/Project/GNU/Library && make install \ + && cd /tmp/MediaInfo_DLL_GNU_FromSource/MediaInfoLib/Project/GNU/Library && make install \ + && cd /tmp/MediaInfo_CLI_GNU_FromSource && ./CLI_Compile.sh \ + && cd /tmp/MediaInfo_CLI_GNU_FromSource/MediaInfo/Project/GNU/CLI && make install \ + && cd /tmp/xmlrpc-c && ./configure && make -j ${NB_CORES} && make install \ + && cd /tmp/libtorrent && ./autogen.sh && ./configure \ + && make -j ${NB_CORES} && make install \ + && cd /tmp/rtorrent && ./autogen.sh && ./configure --with-xmlrpc-c \ + && make -j ${NB_CORES} && make install \ + && mkdir /filebot \ + && wget -q http://downloads.sourceforge.net/project/filebot/filebot/FileBot_${FILEBOT_VER}/FileBot_${FILEBOT_VER}-portable.zip -P /tmp \ + && unzip -q /tmp/FileBot_${FILEBOT_VER}-portable.zip -d /filebot \ + && strip -s /usr/local/bin/rtorrent \ + && strip -s /usr/local/bin/mediainfo \ + && cd /usr && git clone https://github.com/jfurrow/flood && cd flood \ + && npm install \ + && apk del ${BUILD_DEPS} \ + && deluser svn && delgroup svnusers \ + && rm -rf /var/cache/apk/* /tmp/* + +COPY config.js /usr/flood/ +COPY supervisord.ini /etc/supervisor.d/ +COPY startup /usr/bin/ +COPY postdl /usr/bin/ +COPY postrm /usr/bin/ +COPY config.js /usr/flood/ +COPY rtorrent.rc /home/torrent/.rtorrent.rc + +RUN chmod +x /usr/bin/* \ + && cd /usr/flood && ./node_modules/.bin/gulp dist + +VOLUME /data /usr/flood/server/db + +EXPOSE 3000 49184 49184/udp + +LABEL description="BitTorrent client with WebUI front-end" \ + rtorrent="rTorrent BiTorrent client v$RTORRENT_VER" \ + libtorrent="libtorrent v$LIBTORRENT_VER" \ + mediainfo="mediainfo v$MEDIAINFO_VER" \ + filebot="Filebot v$FILEBOT_VER" + +CMD ["/sbin/tini","--","startup"] diff --git a/rtorrent-flood/README.md b/rtorrent-flood/README.md new file mode 100644 index 0000000..621e705 --- /dev/null +++ b/rtorrent-flood/README.md @@ -0,0 +1,16 @@ +## wonderfall/rtorrent-flood + +#### Main features +- Lightweight, since it's based on Alpine Linux. +- Everything is almost compiled from source. +- Secured, don't bother about configuration files. +- Filebot is included, and creates symlinks in `/data/Media`. +- Flood WebUI + +#### Ports + +- **49184** (bind it). +- **3000** [(reverse proxy!)](https://github.com/hardware/mailserver/wiki/Reverse-proxy-configuration) + +#### Volumes +- **/data** : your files, symlinks, and so on. diff --git a/rtorrent-flood/config.js b/rtorrent-flood/config.js new file mode 100644 index 0000000..9d73a5b --- /dev/null +++ b/rtorrent-flood/config.js @@ -0,0 +1,16 @@ +const CONFIG = { + dbCleanInterval: 1000 * 60 * 60, + dbPath: './server/db/', + floodServerPort: 3000, + maxHistoryStates: 30, + pollInterval: 1000 * 5, + secret: '', + scgi: { + host: 'localhost', + port: 5000, + socket: false, + socketPath: '/tmp/rtorrent.sock' + } +}; + +module.exports = CONFIG; diff --git a/rtorrent-flood/postdl b/rtorrent-flood/postdl new file mode 100644 index 0000000..6061cf0 --- /dev/null +++ b/rtorrent-flood/postdl @@ -0,0 +1,10 @@ +#!/bin/sh + +# rtorrent.rc +# system.method.set_key=event.download.finished,filebot,"execute={rtorrent-postprocess.sh,$d.get_base_path=,$d.get_name=,$d.get_custom1=}" + +TORRENT_PATH="$1" +TORRENT_NAME="$2" +TORRENT_LABEL="$3" + +/filebot/filebot.sh -script fn:amc --output "/data/Media" --action symlink --conflict skip -non-strict --log-file amc.log --def excludeList=amc.excludes unsorted=y music=y "seriesFormat=/data/Media/TV/{n}/Season {s.pad(2)}/{s00e00} - {t}" "animeFormat=/data/Media/Animes/{n}/{e.pad(3)} - {t}" "movieFormat=/data/Media/Movies/{n}" "musicFormat=/data/Media/Music/{n}/{fn}" "ut_dir=$TORRENT_PATH" "ut_kind=multi" "ut_title=$TORRENT_NAME" "ut_label=$TORRENT_LABEL" & diff --git a/rtorrent-flood/postrm b/rtorrent-flood/postrm new file mode 100644 index 0000000..95490f2 --- /dev/null +++ b/rtorrent-flood/postrm @@ -0,0 +1,3 @@ +#!/bin/sh + +/filebot/filebot.sh -script fn:cleaner /data/Media diff --git a/rtorrent-flood/rtorrent.rc b/rtorrent-flood/rtorrent.rc new file mode 100644 index 0000000..bd0565d --- /dev/null +++ b/rtorrent-flood/rtorrent.rc @@ -0,0 +1,22 @@ +scgi_port = 0.0.0.0:5000 +encoding_list = UTF-8 +port_range = 49184-49184 +port_random = no +check_hash = no +directory = /data/torrents +session = /data/.session +encryption = require,require_RC4,allow_incoming,try_outgoing +use_udp_trackers = yes +dht = off +peer_exchange = no +min_peers = 1 +max_peers = 100 +min_peers_seed = 1 +max_peers_seed = 50 +max_uploads = 15 + +schedule = watch_directory,1,1,"load_start=/data/.watch/*.torrent" +schedule = untied_directory,5,5,"stop_untied=/data/.watch/*.torrent" +schedule = espace_disque_insuffisant,1,30,close_low_diskspace=500M +system.method.set_key=event.download.finished,filebot,"execute={/usr/bin/postdl,$d.get_base_path=,$d.get_name=,$d.get_custom1=}" +system.method.set_key=event.download.erased,filebot_cleaner,"execute={/usr/bin/postrm}" diff --git a/rtorrent-flood/startup b/rtorrent-flood/startup new file mode 100644 index 0000000..64062f0 --- /dev/null +++ b/rtorrent-flood/startup @@ -0,0 +1,16 @@ +#!/bin/sh +addgroup -g ${GID} torrent && adduser -h /home/torrent -s /bin/sh -G torrent -D -u ${UID} torrent + +mkdir -p /data/torrents +mkdir -p /data/.watch +mkdir -p /data/.session +mkdir -p /data/Media/Movies +mkdir -p /data/Media/TV +mkdir -p /data/Media/Animes +mkdir -p /data/Media/Music + +sed -i -e "s//$FLOOD_SECRET/g" /usr/flood/config.js +rm -f /data/.session/rtorrent.lock +chown -R torrent:torrent /data /home/torrent /filebot /usr/flood + +exec /usr/bin/supervisord -c /etc/supervisord.conf diff --git a/rtorrent-flood/supervisord.ini b/rtorrent-flood/supervisord.ini new file mode 100644 index 0000000..a2f1aa7 --- /dev/null +++ b/rtorrent-flood/supervisord.ini @@ -0,0 +1,18 @@ +[supervisord] +nodaemon=true + +[program:rtorrent] +user=torrent +directory=/home/torrent +priority=2 +redirect_stderr=true +environment=HOME="/home/torrent",PWD="/home/torrent",LOGNAME="rtorrent",USER="torrent",TERM="xterm" +startsecs=5 +command=rtorrent + +[program:flood] +user=torrent +directory=/usr/flood +command=/usr/flood/server/bin/www +autostart=true +autorestart=true