Skip to content

Commit

Permalink
Initialize release
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhotio authored Apr 29, 2024
0 parents commit 32ec18c
Show file tree
Hide file tree
Showing 32 changed files with 1,049 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.github
.gitattributes
build.sh
LICENSE
README.md
update-digests.sh
update-versions.sh
VERSION.json
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
12 changes: 12 additions & 0 deletions .github/workflows/call-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: call-build

on:
workflow_dispatch:
push:
branches-ignore:
- 'master'

jobs:
call:
uses: hotio/build-workflow/.github/workflows/build-on-call.yml@master
secrets: inherit
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Documentation

All our documentation is located at [hotio.dev](https://hotio.dev).

# Support

If you need some assistance, please join our [discord](https://hotio.dev/discord) server.

# Source

The source is hosted at [GitHub](https://github.com/hotio). If you can't find it in the `master` branch, it's probably located in another branch.

# Show your support

You can show your support by giving us a star on Docker Hub or/and GitHub, it's also possible to make a [donation](https://hotio.dev/donate).
14 changes: 14 additions & 0 deletions VERSION.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"description": "Releases",
"flood_version": "4.8.0",
"latest": true,
"rtorrent_version": "0.9.8-r16",
"test_amd64": true,
"test_arm64": true,
"test_url": "http://localhost:3000",
"upstream_digest_amd64": "sha256:81d80abc4fd0243787d219f344b702915c6fed097f2d198183687681d83715f6",
"upstream_digest_arm64": "sha256:8b1217064599410503a0de18b1e14bd86cfc7faba3e88746974700616c186ad0",
"upstream_image": "ghcr.io/hotio/base",
"upstream_tag": "alpinevpn",
"version": "0.9.8-r16--4.8.0"
}
10 changes: 10 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if [[ -z ${1} ]]; then
echo "Usage: ./build.sh amd64"
echo " ./build.sh arm64"
exit 1
fi

image=$(basename "$(git rev-parse --show-toplevel)")
docker build --platform "linux/${1}" -f "./linux-${1}.Dockerfile" -t "${image}-${1}" $(for i in $(jq -r 'to_entries[] | [(.key | ascii_upcase),.value] | join("=")' < VERSION.json); do out+="--build-arg $i " ; done; echo $out;out="") .
20 changes: 20 additions & 0 deletions linux-amd64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG UPSTREAM_IMAGE
ARG UPSTREAM_DIGEST_AMD64

FROM ${UPSTREAM_IMAGE}@${UPSTREAM_DIGEST_AMD64}
EXPOSE 3000 5000
ARG IMAGE_STATS
ENV IMAGE_STATS=${IMAGE_STATS} FLOOD_AUTH="false" WEBUI_PORTS="3000/tcp,3000/udp,5000/tcp,5000/udp"

RUN apk add --no-cache xmlrpc-c-tools nginx openssl mediainfo && \
ln -s "${CONFIG_DIR}/rpc2/basic_auth_credentials" "${APP_DIR}/basic_auth_credentials"

ARG RTORRENT_VERSION
RUN curl -fsSL "https://github.com/jesec/rtorrent/releases/download/v${RTORRENT_VERSION}/rtorrent-linux-amd64" > "${APP_DIR}/rtorrent" && \
chmod 755 "${APP_DIR}/rtorrent"

ARG FLOOD_VERSION
RUN curl -fsSL "https://github.com/jesec/flood/releases/download/v${FLOOD_VERSION}/flood-linux-x64" > "${APP_DIR}/flood" && \
chmod 755 "${APP_DIR}/flood"

COPY root/ /
20 changes: 20 additions & 0 deletions linux-arm64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG UPSTREAM_IMAGE
ARG UPSTREAM_DIGEST_ARM64

FROM ${UPSTREAM_IMAGE}@${UPSTREAM_DIGEST_ARM64}
EXPOSE 3000 5000
ARG IMAGE_STATS
ENV IMAGE_STATS=${IMAGE_STATS} FLOOD_AUTH="false" WEBUI_PORTS="3000/tcp,3000/udp,5000/tcp,5000/udp"

RUN apk add --no-cache xmlrpc-c-tools nginx openssl mediainfo && \
ln -s "${CONFIG_DIR}/rpc2/basic_auth_credentials" "${APP_DIR}/basic_auth_credentials"

ARG RTORRENT_VERSION
RUN curl -fsSL "https://github.com/jesec/rtorrent/releases/download/v${RTORRENT_VERSION}/rtorrent-linux-arm64" > "${APP_DIR}/rtorrent" && \
chmod 755 "${APP_DIR}/rtorrent"

ARG FLOOD_VERSION
RUN curl -fsSL "https://github.com/jesec/flood/releases/download/v${FLOOD_VERSION}/flood-linux-arm64" > "${APP_DIR}/flood" && \
chmod 755 "${APP_DIR}/flood"

COPY root/ /
17 changes: 17 additions & 0 deletions root/app/forwarded_port_update_app
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# shellcheck shell=bash
until pidof rtorrent > /dev/null; do
sleep 1
done
old_port_range=$(grep network.port_range.set "${CONFIG_DIR}/rtorrent.rc" | awk -F '=' '{print $2}' | xargs)
if [[ "${old_port_range}" != "${port}-${port}" ]]; then
sed -i "s/network.port_range.set.*/network.port_range.set = ${port}-${port}/g" "${CONFIG_DIR}/rtorrent.rc"
sed -i "s/network.port_random.set.*/network.port_random.set = no/g" "${CONFIG_DIR}/rtorrent.rc"
echo "[INF] [$(date '+%Y-%m-%d %H:%M:%S')] [RTORRENT] Shutting down to restart with forwarded port [${port}]."
until xmlrpc localhost:5000 system.client_version > /dev/null; do
echo "[WRN] [$(date '+%Y-%m-%d %H:%M:%S')] [RTORRENT] Application not ready to receive xml-rpc commands!"
sleep 1
done
xmlrpc localhost:5000 system.shutdown.normal > /dev/null
else
echo "[INF] [$(date '+%Y-%m-%d %H:%M:%S')] [RTORRENT] Nothing to do, forwarded port hasn't changed."
fi
38 changes: 38 additions & 0 deletions root/app/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
events {}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size @XMLRPC_SIZE_LIMIT@;
server_tokens off;

client_body_temp_path temp_client_body 1 2;
fastcgi_temp_path temp_fastcgi 1 2;
proxy_temp_path temp_proxy 1 2;
scgi_temp_path temp_scgi 1 2;
uwsgi_temp_path temp_uwsgi 1 2;

server {
server_name rpc;
listen 0.0.0.0:5000;
access_log access.log;

include /etc/nginx/scgi_params;

satisfy any;
allow 127.0.0.1;
auth_basic "Restricted";
auth_basic_user_file basic_auth_credentials;

location /RPC {
scgi_pass unix:/dev/shm/rtorrent.sock;
}
location /RPC2 {
scgi_param CONTENT_TYPE text/xml;
scgi_pass unix:/dev/shm/rtorrent.sock;
}
location /JSONRPC {
scgi_param CONTENT_TYPE application/json-rpc;
scgi_pass unix:/dev/shm/rtorrent.sock;
}
}
}
124 changes: 124 additions & 0 deletions root/app/rtorrent.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#############################################################################
# A minimal rTorrent configuration that provides the basic features
# you want to have in addition to the built-in defaults.
#
# See https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
# for an up-to-date version.
#############################################################################

## Fix Added Date in Flood UI
method.set_key = event.download.inserted_new, loaded_time, "d.custom.set=addtime,$cat=$system.time=;d.save_full_session="

## Instance layout (base paths)
method.insert = cfg.basedir, private|const|string, (cat,"/config/")
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/")
method.insert = cfg.logs, private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile, private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session, private|const|string, (cat,(cfg.basedir),"session/")
method.insert = cfg.watch, private|const|string, (cat,(cfg.basedir),"watch/")


## Create instance directories
execute.throw = sh, -c, (cat,\
"mkdir -p \"",(cfg.download),"\" ",\
"\"",(cfg.logs),"\" ",\
"\"",(cfg.session),"\" ",\
"\"",(cfg.watch),"/load\" ",\
"\"",(cfg.watch),"/start\" ")


## Listening port for incoming peer traffic (fixed; you can also randomize it)
network.port_range.set = 50000-50000
network.port_random.set = no


## Tracker-less torrent and UDP tracker support
## (conservative settings for 'private' trackers, change for 'public')
dht.mode.set = disable
protocol.pex.set = no

trackers.use_udp.set = no


## Peer settings
throttle.max_uploads.set = 100
throttle.max_uploads.global.set = 250

throttle.min_peers.normal.set = 20
throttle.max_peers.normal.set = 60
throttle.min_peers.seed.set = 30
throttle.max_peers.seed.set = 80
trackers.numwant.set = 80

protocol.encryption.set = allow_incoming,try_outgoing,enable_retry


## Limits for file handle resources, this is optimized for
## an `ulimit` of 1024 (a common default). You MUST leave
## a ceiling of handles reserved for rTorrent's internal needs!
network.http.max_open.set = 50
network.max_open_files.set = 600
network.max_open_sockets.set = 300


## Memory resource usage (increase if you have a large number of items loaded,
## and/or the available resources to spend)
pieces.memory.max.set = 1800M
network.xmlrpc.size_limit.set = 4M


## Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
#log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
(session.path), "rtorrent.pid", " ",(system.pid))


## Other operational settings (check & adapt)
encoding.add = utf8
system.umask.set = 0027
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
#pieces.hash.on_completion.set = no
#view.sort_current = seeding, greater=d.ratio=
#keys.layout.set = qwerty
#network.http.capath.set = "/etc/ssl/certs"
#network.http.ssl_verify_peer.set = 0
#network.http.ssl_verify_host.set = 0


## Some additional values and commands
method.insert = system.startup_time, value|const, (system.time)
method.insert = d.data_path, simple,\
"if=(d.is_multi_file),\
(cat, (d.directory), /),\
(cat, (d.directory), /, (d.name))"
method.insert = d.session_file, simple, "cat=(session.path), (d.hash), .torrent"


## Watch directories (add more as you like, but use unique schedule names)
## Add torrent
schedule2 = watch_load, 11, 10, ((load.verbose, (cat, (cfg.watch), "load/*.torrent")))
## Add & download straight away
schedule2 = watch_start, 10, 10, ((load.start_verbose, (cat, (cfg.watch), "start/*.torrent")))


## Run the rTorrent process as a daemon in the background
## (and control via XMLRPC sockets)
#system.daemon.set = true
#network.scgi.open_local = (cat,(session.path),rpc.socket)
#execute.nothrow = chmod,770,(cat,(session.path),rpc.socket)


## Logging:
## Levels = critical error warn notice info debug
## Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "info", "log"
#log.add_output = "tracker_debug", "log"

### END of rtorrent.rc ###
Empty file.
28 changes: 28 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/init-setup-app/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/command/with-contenv bash
# shellcheck shell=bash

umask "${UMASK}"

echo "
----------------------------------------------------------------------
ENVIRONMENT APP
----------------------------------------------------------------------
WEBUI_PORTS=${WEBUI_PORTS}
FLOOD_AUTH=${FLOOD_AUTH}
----------------------------------------------------------------------
"

if [[ ! -f "${CONFIG_DIR}/rtorrent.rc" ]]; then
echo "Installing default \"rtorrent.rc\"..."
cp "${APP_DIR}/rtorrent.rc" "${CONFIG_DIR}/rtorrent.rc"
find "${CONFIG_DIR}/rtorrent.rc" -maxdepth 0 \( ! -user hotio -or ! -group hotio \) -exec chown hotio:hotio {} +
fi

if [[ ! -f "${CONFIG_DIR}/rpc2/basic_auth_credentials" ]]; then
echo "Creating new \"basic_auth_credentials\" file for RPC2..."
[[ ! -d "${CONFIG_DIR}/rpc2" ]] && mkdir "${CONFIG_DIR}/rpc2"
rpc2_password=$(openssl rand -base64 10)
echo "hotio:$(openssl passwd -5 "${rpc2_password}")" >> "${CONFIG_DIR}/rpc2/basic_auth_credentials"
echo "Your RPC2 credentials are [hotio:${rpc2_password}]."
find "${CONFIG_DIR}/rpc2" \( ! -user hotio -or ! -group hotio \) -exec chown hotio:hotio {} +
fi
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/init-setup-app/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oneshot
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/init-setup-app/up
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/init-setup-app/run
Empty file.
14 changes: 14 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/service-flood/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/command/with-contenv bash
# shellcheck shell=bash

umask "${UMASK}"

if [[ ${FLOOD_AUTH} == true ]]; then
FLOOD_OPTION_AUTH=default && export FLOOD_OPTION_AUTH
echo "rTorrent socket file is \"/dev/shm/rtorrent.sock\"."
else
FLOOD_OPTION_AUTH=none && export FLOOD_OPTION_AUTH
fi

# shellcheck disable=SC2086
exec s6-setuidgid hotio "${APP_DIR}/flood" --rundir "${CONFIG_DIR}/flood" --host 0.0.0.0 --port "${WEBUI_PORTS%%/*}" --rtsocket "/dev/shm/rtorrent.sock" ${FLOOD_ARGS}
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/service-flood/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
12 changes: 12 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/service-rpc2/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/command/with-contenv bash
# shellcheck shell=bash

umask "${UMASK}"

readarray -td, PORTS <<< "${WEBUI_PORTS}"
sed -i "s/0.0.0.0:5000/0.0.0.0:${PORTS[2]%%/*}/" "${APP_DIR}/nginx.conf"

body_size=$(grep 'network.xmlrpc.size_limit.set.*' "${CONFIG_DIR}/rtorrent.rc" | awk -F '=' '{print $2}' | xargs)
sed -i "s/@XMLRPC_SIZE_LIMIT@/${body_size,,}/" "${APP_DIR}/nginx.conf"

exec s6-setuidgid hotio nginx -c "${APP_DIR}/nginx.conf" -p "${CONFIG_DIR}/rpc2" -e "error.log" -g "daemon off;pid nginx.pid;"
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/service-rpc2/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
4 changes: 4 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/service-rtorrent/finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/command/with-contenv bash
# shellcheck shell=bash

find "${CONFIG_DIR}" -name rtorrent.lock -type f -delete
7 changes: 7 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/service-rtorrent/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/command/with-contenv bash
# shellcheck shell=bash

umask "${UMASK}"

# shellcheck disable=SC2086
exec s6-setuidgid hotio "${APP_DIR}/rtorrent" -n -o "try_import=${CONFIG_DIR}/rtorrent.rc,network.scgi.open_local=/dev/shm/rtorrent.sock,system.daemon.set=true,encoding.add=UTF-8"
1 change: 1 addition & 0 deletions root/etc/s6-overlay/s6-rc.d/service-rtorrent/type
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
longrun
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions update-digests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
json=$(cat VERSION.json)
upstream_image=$(jq -re '.upstream_image' <<< "${json}")
upstream_tag=$(jq -re '.upstream_tag' <<< "${json}")
manifest=$(skopeo inspect --raw "docker://${upstream_image}:${upstream_tag}") || exit 1
upstream_digest_amd64=$(jq -re '.manifests[] | select (.platform.architecture == "amd64" and .platform.os == "linux").digest' <<< "${manifest}")
upstream_digest_arm64=$(jq -re '.manifests[] | select (.platform.architecture == "arm64" and .platform.os == "linux").digest' <<< "${manifest}")
jq --sort-keys \
--arg upstream_digest_amd64 "${upstream_digest_amd64}" \
--arg upstream_digest_arm64 "${upstream_digest_arm64}" \
'.upstream_digest_amd64 = $upstream_digest_amd64 | .upstream_digest_arm64 = $upstream_digest_arm64' <<< "${json}" | tee VERSION.json
14 changes: 14 additions & 0 deletions update-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
rtorrent_version=$(curl -u "${GITHUB_ACTOR}:${GITHUB_TOKEN}" -fsSL "https://api.github.com/repos/jesec/rtorrent/releases/latest" | jq -re .tag_name) || exit 1
[[ -z ${rtorrent_version} ]] && exit 0
[[ ${rtorrent_version} == null ]] && exit 0
flood_version=$(curl -u "${GITHUB_ACTOR}:${GITHUB_TOKEN}" -fsSL "https://api.github.com/repos/jesec/flood/releases/latest" | jq -re .tag_name) || exit 1
[[ -z ${flood_version} ]] && exit 0
[[ ${flood_version} == null ]] && exit 0
version="${rtorrent_version}--${flood_version}"
json=$(cat VERSION.json)
jq --sort-keys \
--arg version "${version//v/}" \
--arg flood_version "${flood_version//v/}" \
--arg rtorrent_version "${rtorrent_version//v/}" \
'.version = $version | .flood_version = $flood_version | .rtorrent_version = $rtorrent_version' <<< "${json}" | tee VERSION.json

0 comments on commit 32ec18c

Please sign in to comment.