diff --git a/Dockerfile b/Dockerfile index 25ff8a98..960d6398 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,29 +1,102 @@ -FROM linuxserver/baseimage.nginx +FROM lsiobase/alpine +MAINTAINER sparklyballs -MAINTAINER Sparklyballs +# package version +ARG MEDIAINF_VER="0.7.85" +ARG RUTORRENT_VER="3.7" -ENV APTLIST="dtach ffmpeg git-core mediainfo nano php5-geoip \ -rtorrent unrar unzip wget" +RUN \ + apk add --no-cache \ + ca-certificates \ + curl \ + fcgi \ + ffmpeg \ + geoip \ + gzip \ + nginx \ + rtorrent \ + screen \ + tar \ + unrar \ + unzip \ + zip && \ -# install packages -RUN add-apt-repository ppa:kirillshkrogalev/ffmpeg-next && \ -add-apt-repository -y ppa:jalaziz/rtorrent && \ -apt-get update -q && \ -apt-get install $APTLIST -qy && \ + apk add --no-cache \ + --repository http://nl.alpinelinux.org/alpine/edge/testing \ + php7 \ + php7-cgi \ + php7-fpm \ + php7-json \ + php7-pear && \ -# cleanup -apt-get clean -y && \ -rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# install webui + curl -o \ + /tmp/rutorrent.zip -L \ + "http://dl.bintray.com/novik65/generic/ruTorrent-${RUTORRENT_VER}.zip" && \ + unzip -qq /tmp/rutorrent.zip -d /tmp && \ + mkdir -p \ + /usr/share/webapps/rutorrent \ + /defaults/rutorrent-conf && \ + mv /tmp/ruTorrent-master/conf/* \ + /defaults/rutorrent-conf/ && \ + cp -r /tmp/ruTorrent-master/* \ + /usr/share/webapps/rutorrent/ && \ + rm -rf \ + /defaults/rutorrent-conf/users \ + /tmp/* + +# install build packages +RUN \ + apk add --no-cache --virtual=build-dependencies \ + autoconf \ + automake \ + cppunit-dev \ + curl-dev \ + file \ + g++ \ + gcc \ + libtool \ + make \ + ncurses-dev \ + openssl-dev && \ + +# fetch and unpack source + curl -o \ + /tmp/libmediainfo.tar.gz -L \ + "http://mediaarea.net/download/binary/libmediainfo0/${MEDIAINF_VER}/MediaInfo_DLL_${MEDIAINF_VER}_GNU_FromSource.tar.gz" && \ + curl -o \ + /tmp/mediainfo.tar.gz -L \ + "http://mediaarea.net/download/binary/mediainfo/${MEDIAINF_VER}/MediaInfo_CLI_${MEDIAINF_VER}_GNU_FromSource.tar.gz" && \ -#Adding Custom files -ADD defaults/ /defaults/ -ADD init/ /etc/my_init.d/ -ADD services/ /etc/service/ -RUN chmod -v +x /etc/service/*/run /etc/my_init.d/*.sh && \ + mkdir -p \ + /tmp/libmediainfo \ + /tmp/mediainfo && \ + tar xf /tmp/libmediainfo.tar.gz -C \ + /tmp/libmediainfo --strip-components=1 && \ + tar xf /tmp/mediainfo.tar.gz -C \ + /tmp/mediainfo --strip-components=1 && \ + +# compile mediainfo packages + cd /tmp/libmediainfo && \ + ./SO_Compile.sh && \ + cd /tmp/libmediainfo/ZenLib/Project/GNU/Library && \ + make install && \ + cd /tmp/libmediainfo/MediaInfoLib/Project/GNU/Library && \ + make install && \ + cd /tmp/mediainfo && \ + ./CLI_Compile.sh && \ + cd /tmp/mediainfo/MediaInfo/Project/GNU/CLI && \ + make install && \ + +# cleanup + apk del --purge \ + build-dependencies && \ + rm -rf \ + /tmp/* -# configure php -sed -i 's#;upload_tmp_dir =#upload_tmp_dir = /config/tmp#g' /etc/php5/fpm/php.ini +# add local files +COPY root/ / -# ports and volumes -EXPOSE 80 9527/udp 45566-45576 +# ports and volumes +EXPOSE 80 VOLUME /config /downloads diff --git a/README.md b/README.md index 4d4e8cfa..95744497 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![https://linuxserver.io](https://www.linuxserver.io/wp-content/uploads/2015/06/linuxserver_medium.png) -The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring auto-update on startup, easy user mapping and community support. Find us for support at: +The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring easy user mapping and community support. Find us for support at: * [forum.linuxserver.io](https://forum.linuxserver.io) * [IRC](https://www.linuxserver.io/index.php/irc/) on freenode at `#linuxserver.io` * [Podcast](https://www.linuxserver.io/index.php/category/podcast/) covers everything to do with getting the most from your Linux Server plus a focus on all things Docker and containerisation! @@ -15,22 +15,27 @@ Popular rtorrent client with a webui for ease of use. [Rutorrent](https://github docker create --name=ruttorent \ -v :/config \ -v :/downloads \ --e PGID= -e PUID= -e TZ= \ --p 80:80 -p 9527:9527/udp -p 45566:45566 \ +-e PGID= -e PUID= \ +-e TZ= \ +-p 80:80 -p 5000:5000 \ +-p 51413:51413 -p 6881:6881/udp \ linuxserver/rutorrent ``` **Parameters** * `-p 80` - the port(s) -* `-p 45566-45576` - the port(s) -* `-p 9527/udp` - the port(s) +* `-p 5000` - the port(s) +* `-p 51413` - the port(s) +* `-p 6881/udp` - the port(s) * `-v /config` - where rutorrent should store it's config files * `-v /downloads` - path to your downloads folder * `-e PGID` for GroupID - see below for explanation * `-e PUID` for UserID - see below for explanation * `-e TZ` for timezone information, eg Europe/London +It is based on alpine linux with s6 overlay, for shell access whilst the container is running do `docker exec -it rutorrent /bin/bash`. + ### User / Group Identifiers Sometimes when using data volumes (`-v` flags) permissions issues can arise between the host OS and the container. We avoid this issue by allowing you to specify the user `PUID` and group `PGID`. Ensure the data volume directory on the host is owned by the same user you specify and it will "just work" ™. @@ -44,21 +49,25 @@ In this instance `PUID=1001` and `PGID=1001`. To find yours use `id user` as bel ## Setting up the application -Webui can be found at `:80` , configuration files are in /config/rtorrent. +Webui can be found at `:80` , configuration files for rtorrent are in /config/rtorrent and for the webui in /config/rutorrent/settings. -`** Important note for unraid users or those running a webserver on port 80, change port 80 assignment -**` +`Settings, changed by the user through the "Settings" panel in ruTorrent, are valid until rtorrent restart. After which all settings will be set according to the rtorrent config file (/config/rtorrent/rtorrent.rc),this is a limitation of the actual apps themselves.` +** Important note for unraid users or those running services such as a webserver on port 80, change port 80 assignment ** -## Updates +`** It should also be noted that this container when run will create subfolders ,completed, incoming, sessions and watched in the /downloads volume.**` -* Shell access whilst the container is running: `docker exec -it rutorrent /bin/bash` -* Upgrade to the latest version: `docker restart rutorrent` -* To monitor the logs of the container in realtime: `docker logs -f rutorrent` +** The Port Assignments and configuration folder structure has been changed from the previous ubuntu based +versions of this container and we recommend a clean install ** +## Info + +* Shell access whilst the container is running: `docker exec -it rutorrent /bin/bash` +* To monitor the logs of the container in realtime: `docker logs -f rutorrent` ## Versions -+ **08.03.2016:** Intial Release. ++ **26.07.16:** Rebase to alpine. ++ **08.03.16:** Intial Release. diff --git a/defaults/default b/defaults/default deleted file mode 100644 index 4a9b6465..00000000 --- a/defaults/default +++ /dev/null @@ -1,34 +0,0 @@ -server { - listen 80; - root /config/www/webui; - index index.html index.htm index.php; - client_max_body_size 0; - server_name _; - - location / { - # First attempt to serve request as file, then - # as directory, then fall back to displaying a 404. - try_files $uri $uri/ =404; - # Uncomment to enable naxsi on this location - # include /etc/nginx/naxsi.rules - } - - location ~ \.php$ { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini - - # With php5-cgi alone: - fastcgi_pass 127.0.0.1:9000; - # With php5-fpm: - # fastcgi_pass unix:/var/run/php5-fpm.sock; - fastcgi_index index.php; - include /etc/nginx/fastcgi_params; - } - - location /RPC2 { - include /etc/nginx/scgi_params; - scgi_pass 127.0.0.1:5000; - } -} - - diff --git a/defaults/nginx-fpm.conf b/defaults/nginx-fpm.conf deleted file mode 100644 index 7839417b..00000000 --- a/defaults/nginx-fpm.conf +++ /dev/null @@ -1,392 +0,0 @@ -; Start a new pool named 'www'. -; the variable $pool can we used in any directive and will be replaced by the -; pool name ('www' here) -[www] - -; Per pool prefix -; It only applies on the following directives: -; - 'slowlog' -; - 'listen' (unixsocket) -; - 'chroot' -; - 'chdir' -; - 'php_values' -; - 'php_admin_values' -; When not set, the global prefix (or /usr) applies instead. -; Note: This directive can also be relative to the global prefix. -; Default Value: none -;prefix = /path/to/pools/$pool - -; Unix user/group of processes -; Note: The user is mandatory. If the group is not set, the default user's group -; will be used. -user = abc -group = abc - -; The address on which to accept FastCGI requests. -; Valid syntaxes are: -; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on -; a specific port; -; 'port' - to listen on a TCP socket to all addresses on a -; specific port; -; '/path/to/unix/socket' - to listen on a unix socket. -; Note: This value is mandatory. -listen = 127.0.0.1:9000 - -; Set listen(2) backlog. -; Default Value: 65535 (-1 on FreeBSD and OpenBSD) -;listen.backlog = 65535 - -; Set permissions for unix socket, if one is used. In Linux, read/write -; permissions must be set in order to allow connections from a web server. Many -; BSD-derived systems allow connections regardless of permissions. -; Default Values: user and group are set as the running user -; mode is set to 0660 -listen.owner = abc -listen.group = abc -;listen.mode = 0660 - -; List of ipv4 addresses of FastCGI clients which are allowed to connect. -; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original -; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address -; must be separated by a comma. If this value is left blank, connections will be -; accepted from any ip address. -; Default Value: any -;listen.allowed_clients = 127.0.0.1 - -; Specify the nice(2) priority to apply to the pool processes (only if set) -; The value can vary from -19 (highest priority) to 20 (lower priority) -; Note: - It will only work if the FPM master process is launched as root -; - The pool processes will inherit the master process priority -; unless it specified otherwise -; Default Value: no set -; priority = -19 - -; Choose how the process manager will control the number of child processes. -; Possible Values: -; static - a fixed number (pm.max_children) of child processes; -; dynamic - the number of child processes are set dynamically based on the -; following directives. With this process management, there will be -; always at least 1 children. -; pm.max_children - the maximum number of children that can -; be alive at the same time. -; pm.start_servers - the number of children created on startup. -; pm.min_spare_servers - the minimum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is less than this -; number then some children will be created. -; pm.max_spare_servers - the maximum number of children in 'idle' -; state (waiting to process). If the number -; of 'idle' processes is greater than this -; number then some children will be killed. -; ondemand - no children are created at startup. Children will be forked when -; new requests will connect. The following parameter are used: -; pm.max_children - the maximum number of children that -; can be alive at the same time. -; pm.process_idle_timeout - The number of seconds after which -; an idle process will be killed. -; Note: This value is mandatory. -pm = dynamic - -; The number of child processes to be created when pm is set to 'static' and the -; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. -; This value sets the limit on the number of simultaneous requests that will be -; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. -; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP -; CGI. The below defaults are based on a server without much resources. Don't -; forget to tweak pm.* to fit your needs. -; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' -; Note: This value is mandatory. -pm.max_children = 5 - -; The number of child processes created on startup. -; Note: Used only when pm is set to 'dynamic' -; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 -pm.start_servers = 2 - -; The desired minimum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.min_spare_servers = 1 - -; The desired maximum number of idle server processes. -; Note: Used only when pm is set to 'dynamic' -; Note: Mandatory when pm is set to 'dynamic' -pm.max_spare_servers = 3 - -; The number of seconds after which an idle process will be killed. -; Note: Used only when pm is set to 'ondemand' -; Default Value: 10s -;pm.process_idle_timeout = 10s; - -; The number of requests each child process should execute before respawning. -; This can be useful to work around memory leaks in 3rd party libraries. For -; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. -; Default Value: 0 -;pm.max_requests = 500 - -; The URI to view the FPM status page. If this value is not set, no URI will be -; recognized as a status page. It shows the following informations: -; pool - the name of the pool; -; process manager - static, dynamic or ondemand; -; start time - the date and time FPM has started; -; start since - number of seconds since FPM has started; -; accepted conn - the number of request accepted by the pool; -; listen queue - the number of request in the queue of pending -; connections (see backlog in listen(2)); -; max listen queue - the maximum number of requests in the queue -; of pending connections since FPM has started; -; listen queue len - the size of the socket queue of pending connections; -; idle processes - the number of idle processes; -; active processes - the number of active processes; -; total processes - the number of idle + active processes; -; max active processes - the maximum number of active processes since FPM -; has started; -; max children reached - number of times, the process limit has been reached, -; when pm tries to start more children (works only for -; pm 'dynamic' and 'ondemand'); -; Value are updated in real time. -; Example output: -; pool: www -; process manager: static -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 62636 -; accepted conn: 190460 -; listen queue: 0 -; max listen queue: 1 -; listen queue len: 42 -; idle processes: 4 -; active processes: 11 -; total processes: 15 -; max active processes: 12 -; max children reached: 0 -; -; By default the status page output is formatted as text/plain. Passing either -; 'html', 'xml' or 'json' in the query string will return the corresponding -; output syntax. Example: -; http://www.foo.bar/status -; http://www.foo.bar/status?json -; http://www.foo.bar/status?html -; http://www.foo.bar/status?xml -; -; By default the status page only outputs short status. Passing 'full' in the -; query string will also return status for each pool process. -; Example: -; http://www.foo.bar/status?full -; http://www.foo.bar/status?json&full -; http://www.foo.bar/status?html&full -; http://www.foo.bar/status?xml&full -; The Full status returns for each process: -; pid - the PID of the process; -; state - the state of the process (Idle, Running, ...); -; start time - the date and time the process has started; -; start since - the number of seconds since the process has started; -; requests - the number of requests the process has served; -; request duration - the duration in µs of the requests; -; request method - the request method (GET, POST, ...); -; request URI - the request URI with the query string; -; content length - the content length of the request (only with POST); -; user - the user (PHP_AUTH_USER) (or '-' if not set); -; script - the main script called (or '-' if not set); -; last request cpu - the %cpu the last request consumed -; it's always 0 if the process is not in Idle state -; because CPU calculation is done when the request -; processing has terminated; -; last request memory - the max amount of memory the last request consumed -; it's always 0 if the process is not in Idle state -; because memory calculation is done when the request -; processing has terminated; -; If the process is in Idle state, then informations are related to the -; last request the process has served. Otherwise informations are related to -; the current request being served. -; Example output: -; ************************ -; pid: 31330 -; state: Running -; start time: 01/Jul/2011:17:53:49 +0200 -; start since: 63087 -; requests: 12808 -; request duration: 1250261 -; request method: GET -; request URI: /test_mem.php?N=10000 -; content length: 0 -; user: - -; script: /home/fat/web/docs/php/test_mem.php -; last request cpu: 0.00 -; last request memory: 0 -; -; Note: There is a real-time FPM status monitoring sample web page available -; It's available in: ${prefix}/share/fpm/status.html -; -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;pm.status_path = /status - -; The ping URI to call the monitoring page of FPM. If this value is not set, no -; URI will be recognized as a ping page. This could be used to test from outside -; that FPM is alive and responding, or to -; - create a graph of FPM availability (rrd or such); -; - remove a server from a group if it is not responding (load balancing); -; - trigger alerts for the operating team (24/7). -; Note: The value must start with a leading slash (/). The value can be -; anything, but it may not be a good idea to use the .php extension or it -; may conflict with a real PHP file. -; Default Value: not set -;ping.path = /ping - -; This directive may be used to customize the response of a ping request. The -; response is formatted as text/plain with a 200 response code. -; Default Value: pong -;ping.response = pong - -; The access log file -; Default: not set -;access.log = log/$pool.access.log - -; The access log format. -; The following syntax is allowed -; %%: the '%' character -; %C: %CPU used by the request -; it can accept the following format: -; - %{user}C for user CPU only -; - %{system}C for system CPU only -; - %{total}C for user + system CPU (default) -; %d: time taken to serve the request -; it can accept the following format: -; - %{seconds}d (default) -; - %{miliseconds}d -; - %{mili}d -; - %{microseconds}d -; - %{micro}d -; %e: an environment variable (same as $_ENV or $_SERVER) -; it must be associated with embraces to specify the name of the env -; variable. Some exemples: -; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e -; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e -; %f: script filename -; %l: content-length of the request (for POST request only) -; %m: request method -; %M: peak of memory allocated by PHP -; it can accept the following format: -; - %{bytes}M (default) -; - %{kilobytes}M -; - %{kilo}M -; - %{megabytes}M -; - %{mega}M -; %n: pool name -; %o: output header -; it must be associated with embraces to specify the name of the header: -; - %{Content-Type}o -; - %{X-Powered-By}o -; - %{Transfert-Encoding}o -; - .... -; %p: PID of the child that serviced the request -; %P: PID of the parent of the child that serviced the request -; %q: the query string -; %Q: the '?' character if query string exists -; %r: the request URI (without the query string, see %q and %Q) -; %R: remote IP address -; %s: status (response code) -; %t: server time the request was received -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; %T: time the log has been written (the request has finished) -; it can accept a strftime(3) format: -; %d/%b/%Y:%H:%M:%S %z (default) -; %u: remote user -; -; Default: "%R - %u %t \"%m %r\" %s" -;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" - -; The log file for slow requests -; Default Value: not set -; Note: slowlog is mandatory if request_slowlog_timeout is set -;slowlog = log/$pool.log.slow - -; The timeout for serving a single request after which a PHP backtrace will be -; dumped to the 'slowlog' file. A value of '0s' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_slowlog_timeout = 0 - -; The timeout for serving a single request after which the worker process will -; be killed. This option should be used when the 'max_execution_time' ini option -; does not stop script execution for some reason. A value of '0' means 'off'. -; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) -; Default Value: 0 -;request_terminate_timeout = 0 - -; Set open file descriptor rlimit. -; Default Value: system defined value -;rlimit_files = 1024 - -; Set max core size rlimit. -; Possible Values: 'unlimited' or an integer greater or equal to 0 -; Default Value: system defined value -;rlimit_core = 0 - -; Chroot to this directory at the start. This value must be defined as an -; absolute path. When this value is not set, chroot is not used. -; Note: you can prefix with '$prefix' to chroot to the pool prefix or one -; of its subdirectories. If the pool prefix is not set, the global prefix -; will be used instead. -; Note: chrooting is a great security feature and should be used whenever -; possible. However, all PHP paths will be relative to the chroot -; (error_log, sessions.save_path, ...). -; Default Value: not set -;chroot = - -; Chdir to this directory at the start. -; Note: relative path can be used. -; Default Value: current directory or / when chroot -chdir = / - -; Redirect worker stdout and stderr into main error log. If not set, stdout and -; stderr will be redirected to /dev/null according to FastCGI specs. -; Note: on highloaded environement, this can cause some delay in the page -; process time (several ms). -; Default Value: no -;catch_workers_output = yes - -; Limits the extensions of the main script FPM will allow to parse. This can -; prevent configuration mistakes on the web server side. You should only limit -; FPM to .php extensions to prevent malicious users to use other extensions to -; exectute php code. -; Note: set an empty value to allow all extensions. -; Default Value: .php -;security.limit_extensions = .php .php3 .php4 .php5 - -; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from -; the current environment. -; Default Value: clean env -;env[HOSTNAME] = $HOSTNAME -;env[PATH] = /usr/local/bin:/usr/bin:/bin -env[TMP] = /tmp -env[TMPDIR] = /tmp -env[TEMP] = /tmp - -; Additional php.ini defines, specific to this pool of workers. These settings -; overwrite the values previously defined in the php.ini. The directives are the -; same as the PHP SAPI: -; php_value/php_flag - you can set classic ini defines which can -; be overwritten from PHP call 'ini_set'. -; php_admin_value/php_admin_flag - these directives won't be overwritten by -; PHP call 'ini_set' -; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. - -; Defining 'extension' will load the corresponding shared extension from -; extension_dir. Defining 'disable_functions' or 'disable_classes' will not -; overwrite previously defined php.ini values, but will append the new value -; instead. - -; Note: path INI options can be relative and will be expanded with the prefix -; (pool, global or /usr) - -; Default Value: nothing is defined by default except the values in php.ini and -; specified at startup with the -d argument -;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com -;php_flag[display_errors] = off -;php_admin_value[error_log] = /var/log/fpm-php.www.log -;php_admin_flag[log_errors] = on -;php_admin_value[memory_limit] = 32M diff --git a/defaults/rtorrent.rc b/defaults/rtorrent.rc deleted file mode 100644 index f09aa789..00000000 --- a/defaults/rtorrent.rc +++ /dev/null @@ -1,125 +0,0 @@ - -# This is an example resource file for rTorrent. -# uncomment extra options you wish to enable. - -#Set umask within rtorrent -system.umask.set=0002 - -# SCGI port for ruTorrent frontend -scgi_port = 127.0.0.1:5000 - -# Force encoding to enable nginx as webserver -encoding_list = UTF-8 - -# Maximum and minimum number of peers to connect to per torrent. -min_peers = 1 -max_peers = 100 - -# Same as above but for seeding completed torrents (-1 = same as downloading) -min_peers_seed = 1 -max_peers_seed = 50 - -# Maximum number of uploads single torrent may use -max_uploads = 10 - -# Maximum number of simultaneous downloads -max_downloads_global = 10 -# Maximum number of simultaneous uploads -max_uploads_global = 20 - -# Global upload and download rate in KiB. "0" for unlimited. -download_rate = 0 -upload_rate = 0 - -# Default directory to save the downloaded torrents. -directory = /downloads - -# Default session directory. Make sure you don't run multiple instance -# of rtorrent using the same session directory. Perhaps using a -# relative path? -session = /config/rtorrent/rtorrent_sess - -# Watch a directory for new torrents, and stop those that have been -# deleted. -#schedule = watch_directory,5,5,load_start=./rtactive/*.torrent -#schedule = tied_directory,6,5,start_tied= -#schedule = untied_directory,7,5,stop_untied= - -# Close torrents when diskspace is low. -#schedule = low_diskspace,5,60,close_low_diskspace=2000M - -# Periodically save session data -schedule = session_save,240,300,session_save= - -# Enable the default ratio group. -#ratio.enable= -# Change the limits, the defaults should be sufficient. -# Upload to a minimum ratio of 4.0 -#ratio.min.set=400 -# Upload to a maximum ratio of 20.0 -#ratio.max.set=2000 -# Upload a minimum of 250 MB -#ratio.upload.set=250M - -# When seeding ratio is reached close the torrent -#system.method.set = group.seeding.ratio.command, d.close= - -# Move files to ./unsorted when download completes -#system.method.set_key = event.download.finished,move_complete,"execute=mv,-n,$d.get_base_path=,./unsorted/;d.set_directory=./unsorted/" - -# Port range to use for listening. -port_range = 45566-45566 - -# Start opening ports at a random position within the port range. -port_random = yes - -# Encryption options, set to none (default) or any combination of the following: -# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext -# -# The example value allows incoming encrypted connections, starts unencrypted -# outgoing connections but retries with encryption if they fail, preferring -# plaintext to RC4 encryption after the encrypted handshake - -#encryption = allow_incoming,try_outgoing,enable_retry,prefer_plaintext - -# Sort the main view by ratio -#view.sort_current = main,greater=d.get_ratio= -#view.sort_new = main,less=d.get_ratio= -#view.sort = main - -# Sort the seeding view by the upload rate and only show torrents with peers -#view.sort_current = seeding,greater=d.get_up_rate= -#view.filter = seeding,"and=d.get_complete=,d.get_peers_connected=" -#view.sort_new = seeding,less=d.get_up_rate= -#view.sort = seeding - -# Sort the leeching view by name -#view.sort_current = leeching,greater=d.get_name= -#view.sort_new = leeching,greater=d.get_name= -#view.sort = leeching - -# Filter the active view by connected peers -#view.sort_current = active,less=d.get_name= -#view.sort_new = leeching,less=d.get_name= -#view.filter = active,d.get_peers_connected= -#view.sort = active - -#schedule = sort_main,11,5,view.sort=main -#schedule = sort_seeding,12,5,view.sort=seeding -#schedule = sort_leeching,13,5,view.sort=leeching -#schedule = sort_active,14,5,view.sort=active - -# Enable DHT support for trackerless torrents or when all trackers are down. -# May be set to "disable" (completely disable DHT), "off" (do not start DHT), -# "auto" (start and stop DHT as needed), or "on" (start DHT immediately). -# The default is "off". For DHT to work, a session directory must be defined. -# -#dht = auto - -# UDP port to use for DHT. -# -dht_port = 9527 - -# Enable peer exchange (for torrents not marked private) -# -#peer_exchange = yes diff --git a/init/60_get_rutorrent.sh b/init/60_get_rutorrent.sh deleted file mode 100644 index 3175b178..00000000 --- a/init/60_get_rutorrent.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# get webui -[[ ! -d /config/www/webui/.git ]] && (git clone https://github.com/Novik/ruTorrent.git /config/www/webui && \ -chown -R abc:abc /config/www) - - -# opt out for autoupdates -[ "$ADVANCED_DISABLEUPDATES" ] && exit 0 - -# update webui -cd /config/www/webui || exit -git pull -chown -R abc:abc /config/www diff --git a/init/70_set_folders_and_config.sh b/init/70_set_folders_and_config.sh deleted file mode 100644 index be9b55a9..00000000 --- a/init/70_set_folders_and_config.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# make folders -mkdir -p /config/tmp /config/rtorrent/rtorrent_sess /config/log/rtorrent /detach_sess - -if [ -e "/detach_sess/.dtach" ]; then -rm -f /detach_sess/.dtach || true -fi - -if [ -e "/config/rtorrent/rtorrent_sess/rtorrent.lock" ]; then -rm -f /config/rtorrent/rtorrent_sess/rtorrent.lock || true -fi - -# copy config files/set links etc... -[[ ! -f /config/rtorrent/config.php ]] && cp /defaults/config.php /config/rtorrent/config.php -[[ ! -L /config/www/webui/conf/config.php && -f /config/www/webui/conf/config.php ]] && rm /config/www/webui/conf/config.php -[[ ! -L /config/www/webui/conf/config.php ]] && ln -s /config/rtorrent/config.php /config/www/webui/conf/config.php -[[ ! -f /config/rtorrent/rtorrent.rc ]] && cp /defaults/rtorrent.rc /config/rtorrent/rtorrent.rc - -# set perms -chown abc:abc -R /config /detach_sess -chown abc:abc /downloads diff --git a/root/defaults/nginx.conf b/root/defaults/nginx.conf new file mode 100644 index 00000000..8116dd20 --- /dev/null +++ b/root/defaults/nginx.conf @@ -0,0 +1,139 @@ +user abc; +worker_processes 1; +pid /run/nginx.pid; + +events { + worker_connections 768; + # multi_accept on; +} + +http { +upstream backendrutorrent { + server unix:/run/php/php-fpm-rutorrent.sock; +} +upstream backendrtorrent { + server unix:/run/php/.rtorrent.sock; +} + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 65; + types_hash_max_size 2048; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + client_max_body_size 0; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + +server { + listen 80 default_server; + root /var/www/localhost/rutorrent; + index index.html index.htm index.php; + + server_name _; + client_max_body_size 0; + + location / { + access_log /config/log/nginx/rutorrent.access.log; + error_log /config/log/nginx/rutorrent.error.log; + location ~ .php$ { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass backendrutorrent; + fastcgi_index index.php; + fastcgi_intercept_errors on; + fastcgi_ignore_client_abort off; + fastcgi_connect_timeout 60; + fastcgi_send_timeout 180; + fastcgi_read_timeout 180; + fastcgi_buffer_size 128k; + fastcgi_buffers 4 256k; + fastcgi_busy_buffers_size 256k; + fastcgi_temp_file_write_size 256k; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } +} + + location /RPC2 { + access_log /config/log/nginx/rutorrent.rpc2.access.log; + error_log /config/log/nginx/rutorrent.rpc2.error.log; + include /etc/nginx/scgi_params; + scgi_pass backendrtorrent; +} +} + ## + # Logging Settings + ## + + # access_log /config/log/nginx/access.log; + # error_log /config/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + gzip_disable "msie6"; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # nginx-naxsi config + ## + # Uncomment it if you installed nginx-naxsi + ## + + #include /etc/nginx/naxsi_core.rules; + + ## + # nginx-passenger config + ## + # Uncomment it if you installed nginx-passenger + ## + + #passenger_root /usr; + #passenger_ruby /usr/bin/ruby; + + ## + # Virtual Host Configs + ## + include /etc/nginx/conf.d/*.conf; + # include /defaults/site-confs/*; +} + + +#mail { +# # See sample authentication script at: +# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript +# +# # auth_http localhost/auth.php; +# # pop3_capabilities "TOP" "USER"; +# # imap_capabilities "IMAP4rev1" "UIDPLUS"; +# +# server { +# listen localhost:110; +# protocol pop3; +# proxy on; +# } +# +# server { +# listen localhost:143; +# protocol imap; +# proxy on; +# } +#} +daemon off; diff --git a/root/defaults/rtorrent.rc b/root/defaults/rtorrent.rc new file mode 100644 index 00000000..3c55a8ec --- /dev/null +++ b/root/defaults/rtorrent.rc @@ -0,0 +1,27 @@ +execute = {sh,-c,/usr/bin/php7 /usr/share/webapps/rutorrent/php/initplugins.php abc &} +execute.nothrow = rm,/run/php/.rtorrent.sock +network.scgi.open_local = /run/php/.rtorrent.sock +schedule = socket_chmod,0,0,"execute=chmod,0660,/run/php/.rtorrent.sock" +schedule = socket_chgrp,0,0,"execute=chgrp,abc,/run/php/.rtorrent.sock" +log.open_file = "rtorrent", /config/log/rtorrent/rtorrent.log +log.add_output = "info", "rtorrent" +min_peers = 40 +max_peers = 1200 +max_uploads = 15 +download_rate = 10000 +upload_rate = 5000 +directory = /downloads/incoming +session = /config/rtorrent/rtorrent_sess +schedule = low_diskspace,5,60,close_low_diskspace=100M +# ip = 178.32.28.51 +bind = 0.0.0.0 +port_range = 51413-51413 +check_hash = yes +use_udp_trackers = yes +encryption = allow_incoming,try_outgoing,enable_retry +dht = auto +dht_port = 6881 +peer_exchange = yes +# scgi_port = 0.0.0.0:5000 +encoding_list = UTF-8 +system.umask.set = 002 diff --git a/defaults/config.php b/root/defaults/rutorrent-conf/config.php similarity index 65% rename from defaults/config.php rename to root/defaults/rutorrent-conf/config.php index c159b278..7913233f 100644 --- a/defaults/config.php +++ b/root/defaults/rutorrent-conf/config.php @@ -19,32 +19,32 @@ $schedule_rand = 10; // rand for schedulers start, +0..X seconds $do_diagnostic = true; - $log_file = '/config/log/rtorrent/error.log'; // path to log file (comment or leave blank to disable logging) + $log_file = '/config/log/rutorrent/rutorrent.log'; // path to log file (comment or leave blank to disable logging) $saveUploadedTorrents = true; // Save uploaded torrents to profile/torrents directory or not $overwriteUploadedTorrents = false; // Overwrite existing uploaded torrents in profile/torrents directory or make unique name - $topDirectory = '/downloads'; // Upper available directory. Absolute path with trail slash. + $topDirectory = '/'; // Upper available directory. Absolute path with trail slash. $forbidUserSettings = false; - $scgi_port = 5000; - $scgi_host = "127.0.0.1"; + // $scgi_port = 5000; + // $scgi_host = "127.0.0.1"; // For web->rtorrent link through unix domain socket // (scgi_local in rtorrent conf file), change variables // above to something like this: // - // $scgi_port = 0; - // $scgi_host = "unix:///tmp/rpc.socket"; + $scgi_port = 0; + $scgi_host = "unix:////run/php/.rtorrent.sock"; $XMLRPCMountPoint = "/RPC2"; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!! $pathToExternals = array( - "php" => '/usr/bin/php', // Something like /usr/bin/php. If empty, will be found in PATH. + "php" => '/usr/bin/php7', // Something like /usr/bin/php. If empty, will be found in PATH. "curl" => '/usr/bin/curl', // Something like /usr/bin/curl. If empty, will be found in PATH. - "gzip" => '/bin/gzip', // Something like /usr/bin/gzip. If empty, will be found in PATH. - "id" => '', // Something like /usr/bin/id. If empty, will be found in PATH. - "stat" => '/usr/bin/stat', // Something like /usr/bin/stat. If empty, will be found in PATH. + "gzip" => '/usr/bin/gzip', // Something like /usr/bin/gzip. If empty, will be found in PATH. + "id" => '/usr/bin/id', // Something like /usr/bin/id. If empty, will be found in PATH. + "stat" => '/bin/stat', // Something like /usr/bin/stat. If empty, will be found in PATH. ); $localhosts = array( // list of local interfaces @@ -52,11 +52,13 @@ "localhost", ); - $profilePath = '../share'; // Path to user profiles + $profilePath = '/config/rutorrent/profiles'; // Path to user profiles $profileMask = 0777; // Mask for files and directory creation in user profiles. // Both Webserver and rtorrent users must have read-write access to it. // For example, if Webserver and rtorrent users are in the same group then the value may be 0770. - $tempDirectory = '/config/tmp'; // Temp directory. Absolute path with trail slash. If null, then autodetect will be used. + $tempDirectory = '/config/rutorrent/profiles/tmp/'; // Temp directory. Absolute path with trail slash. If null, then autodetect will be used. $canUseXSendFile = true; // Use X-Sendfile feature if it exist + + $locale = "UTF8"; diff --git a/root/etc/cont-init.d/20-config b/root/etc/cont-init.d/20-config new file mode 100644 index 00000000..0dbe655a --- /dev/null +++ b/root/etc/cont-init.d/20-config @@ -0,0 +1,48 @@ +#!/usr/bin/with-contenv bash + + +# make folders +mkdir -p \ + /config{/log/nginx,/log/rtorrent,/log/rutorrent,/nginx,/rtorrent/rtorrent_sess,/rutorrent/settings/users} \ + /config/rutorrent/profiles{/settings,/torrents,/users,/tmp} \ + /downloads{/completed,/incoming,/sessions,/watched} \ + /run{/nginx,/php} + +# copy config +PREV_DIR=$(pwd) + +cd /defaults/rutorrent-conf || exit + for i in $(find . -type f) + do + [[ ! -e "/config/rutorrent/settings/${i}" ]] && cp -v "${i}" "/config/rutorrent/settings/${i}" + done + +cd "${PREV_DIR}" || exit + +[[ ! -e /config/nginx/nginx.conf ]] && \ + cp /defaults/nginx.conf /config/nginx/nginx.conf + +[[ ! -e /config/rtorrent/rtorrent.rc ]] && \ + cp /defaults/rtorrent.rc /config/rtorrent/rtorrent.rc +cp -pr /config/rutorrent/settings/* /usr/share/webapps/rutorrent/conf/ + +# create symlink for webui files +[[ ! -e /var/www/localhost/rutorrent ]] && ln -s \ +/usr/share/webapps/rutorrent /var/www/localhost/rutorrent + +# delete lock file if exists +[[ -e /config/rtorrent/rtorrent_sess/rtorrent.lock ]] && \ + rm /config/rtorrent/rtorrent_sess/rtorrent.lock + +# permissions +chown abc:abc \ + /downloads \ + /downloads{/completed,/incoming,/sessions,/watched} + +chown -R abc:abc \ + /config \ + /run \ + /usr/share/webapps/rutorrent \ + /var/www/localhost/rutorrent + +chmod -R 755 /config/rutorrent/profiles diff --git a/root/etc/php7/php-fpm.d/rutorrent.conf b/root/etc/php7/php-fpm.d/rutorrent.conf new file mode 100644 index 00000000..c6a65f34 --- /dev/null +++ b/root/etc/php7/php-fpm.d/rutorrent.conf @@ -0,0 +1,13 @@ +[rutorrent] +user = abc +group = abc +listen = /run/php/php-fpm-rutorrent.sock +listen.owner = abc +listen.group = abc +listen.mode = 0660 +pm = static +pm.max_children = 2 +pm.start_servers = 2 +pm.min_spare_servers = 1 +pm.max_spare_servers = 3 +chdir = / diff --git a/root/etc/services.d/fpm/run b/root/etc/services.d/fpm/run new file mode 100644 index 00000000..9840e253 --- /dev/null +++ b/root/etc/services.d/fpm/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bash +/usr/sbin/php-fpm7 -F -y /etc/php7/php-fpm.d/rutorrent.conf + diff --git a/root/etc/services.d/nginx/run b/root/etc/services.d/nginx/run new file mode 100644 index 00000000..1ccc9c7c --- /dev/null +++ b/root/etc/services.d/nginx/run @@ -0,0 +1,2 @@ +#!/usr/bin/with-contenv bash +exec /usr/sbin/nginx -c /config/nginx/nginx.conf diff --git a/root/etc/services.d/rutorrent/run b/root/etc/services.d/rutorrent/run new file mode 100644 index 00000000..f4134751 --- /dev/null +++ b/root/etc/services.d/rutorrent/run @@ -0,0 +1,15 @@ +#!/usr/bin/with-contenv bash +umask 002 + +exec \ + screen -D -m -S \ + rtorrent s6-setuidgid abc /usr/bin/rtorrent \ + -n -o import=/config/rtorrent/rtorrent.rc + +until [ -e "/config/rtorrent/rtorrent_sess/rtorrent.lock" ]; +do +sleep 1s +done + +rtorrent_pid=$(cat /config/rtorrent/rtorrent_sess/rtorrent.lock | cut -d '+' -f 2) +tail -n 1 -f /config/log/rtorrent/rtorrent.log "$rtorrent_pid" diff --git a/services/rtorrent/run b/services/rtorrent/run deleted file mode 100644 index 4438b174..00000000 --- a/services/rtorrent/run +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -dtach -n /detach_sess/.dtach /sbin/setuser abc /usr/bin/rtorrent -n -o import=/config/rtorrent/rtorrent.rc - -until [ -e "/config/rtorrent/rtorrent_sess/rtorrent.lock" ]; -do -sleep 1s -done - -rtorrent_pid=$(cat /config/rtorrent/rtorrent_sess/rtorrent.lock | cut -d '+' -f 2) -tail -n 1 -F /config/log/nginx/access.log --pid="$rtorrent_pid"