chore: initial sanitized public snapshot
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
target
|
||||
target-alt
|
||||
.git
|
||||
.cargo-home
|
||||
@@ -0,0 +1,13 @@
|
||||
PUID=1000
|
||||
PGID=1000
|
||||
UMASK_SET=022
|
||||
# Required. Set this to a strong private value before running docker compose.
|
||||
RPC_SECRET=
|
||||
RPC_BIND_ADDRESS=127.0.0.1
|
||||
RPC_PORT=6800
|
||||
LISTEN_PORT=6888
|
||||
DISK_CACHE=64M
|
||||
IPV6_MODE=false
|
||||
UPDATE_TRACKERS=false
|
||||
CUSTOM_TRACKER_URL=
|
||||
SPECIAL_MODE=
|
||||
@@ -0,0 +1,53 @@
|
||||
FROM rust:1-bookworm AS builder
|
||||
|
||||
WORKDIR /work
|
||||
COPY Cargo.toml Cargo.lock rust-toolchain.toml deny.toml ./
|
||||
COPY .cargo ./.cargo
|
||||
COPY crates ./crates
|
||||
COPY xtask ./xtask
|
||||
|
||||
RUN rustup toolchain install nightly --profile minimal --component rust-src && \
|
||||
cargo +nightly build -Zbuild-std=std,panic_abort --release -p aria2-rust-pro-cli --bin aria2-rust-pro
|
||||
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
bash \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gosu \
|
||||
rclone && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /work/target/release/aria2-rust-pro /usr/local/bin/aria2-rust-pro
|
||||
RUN ln -s /usr/local/bin/aria2-rust-pro /usr/local/bin/aria2c
|
||||
|
||||
COPY docker/entrypoint.sh /usr/local/bin/aria2-rust-pro-entrypoint
|
||||
COPY docker/defaults /defaults
|
||||
|
||||
RUN chmod 755 /usr/local/bin/aria2-rust-pro-entrypoint /usr/local/bin/aria2-rust-pro && \
|
||||
find /defaults -type f -name '*.sh' -exec chmod 755 {} + && \
|
||||
mkdir -p /config /downloads /run/aria2-rust-pro
|
||||
|
||||
ENV CONFIG_DIR=/config \
|
||||
DOWNLOAD_DIR=/downloads \
|
||||
PUID= \
|
||||
PGID= \
|
||||
UMASK_SET=022 \
|
||||
RPC_SECRET= \
|
||||
RPC_PORT=6800 \
|
||||
LISTEN_PORT=6888 \
|
||||
DISK_CACHE=64M \
|
||||
IPV6_MODE=false \
|
||||
UPDATE_TRACKERS=false \
|
||||
CUSTOM_TRACKER_URL= \
|
||||
SPECIAL_MODE=
|
||||
|
||||
VOLUME ["/config", "/downloads"]
|
||||
|
||||
EXPOSE 6800 6888 6888/udp
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/aria2-rust-pro-entrypoint"]
|
||||
@@ -0,0 +1,9 @@
|
||||
# Base config copied to /config/aria2.conf on first start.
|
||||
# Environment-derived overrides are appended at runtime without mutating this file.
|
||||
|
||||
continue=true
|
||||
split=5
|
||||
max-connection-per-server=16
|
||||
min-split-size=1K
|
||||
piece-length=1K
|
||||
check-certificate=true
|
||||
@@ -0,0 +1,3 @@
|
||||
udp://tracker.opentrackr.org:1337/announce
|
||||
udp://tracker.torrent.eu.org:451/announce
|
||||
http://tracker.opentrackr.org:1337/announce
|
||||
@@ -0,0 +1,5 @@
|
||||
download-dir=/downloads
|
||||
completed-dir=/downloads/completed
|
||||
upload-log=/config/upload.log
|
||||
move-log=/config/move.log
|
||||
dest-dir=/downloads/completed
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
echo "[INFO] Clean hook completed."
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
echo "[INFO] Delete hook completed."
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
config="/config/script.conf"
|
||||
dest="/downloads/completed"
|
||||
|
||||
if [ -f "${config}" ]; then
|
||||
configured_dest="$(awk -F= '$1 == "dest-dir" {print substr($0, index($0, "=") + 1)}' "${config}" | tail -n 1)"
|
||||
if [ -n "${configured_dest}" ]; then
|
||||
dest="${configured_dest}"
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "${dest}"
|
||||
echo "[INFO] Move hook completed. Destination: ${dest}"
|
||||
@@ -0,0 +1 @@
|
||||
RCLONE_DESTINATION=remote:downloads
|
||||
@@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
aria2_conf="${1:-/config/aria2.conf}"
|
||||
tracker_url="${CUSTOM_TRACKER_URL:-https://trackerslist.com/all_aria2.txt}"
|
||||
tmp_file="$(mktemp)"
|
||||
|
||||
cleanup() {
|
||||
rm -f "${tmp_file}" "${tmp_file}.conf"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "[INFO] Updating BT trackers from ${tracker_url}"
|
||||
|
||||
if ! curl -fsSL --connect-timeout 10 --max-time 20 "${tracker_url}" -o "${tmp_file}"; then
|
||||
echo "[WARN] Failed to download tracker list from ${tracker_url}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
trackers="$(
|
||||
sed 's/\r$//' "${tmp_file}" |
|
||||
awk 'NF {print}' |
|
||||
paste -sd, -
|
||||
)"
|
||||
|
||||
if [ -z "${trackers}" ]; then
|
||||
echo "[WARN] Tracker list is empty" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if grep -q '^bt-tracker=' "${aria2_conf}"; then
|
||||
awk -v value="bt-tracker=${trackers}" '
|
||||
BEGIN { replaced = 0 }
|
||||
/^bt-tracker=/ { print value; replaced = 1; next }
|
||||
{ print }
|
||||
END { if (!replaced) print value }
|
||||
' "${aria2_conf}" > "${tmp_file}.conf"
|
||||
else
|
||||
cp "${aria2_conf}" "${tmp_file}.conf"
|
||||
printf '\nbt-tracker=%s\n' "${trackers}" >> "${tmp_file}.conf"
|
||||
fi
|
||||
|
||||
cat "${tmp_file}.conf" > "${aria2_conf}"
|
||||
echo "[INFO] Tracker file updated."
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
echo "[INFO] Rclone upload hook is enabled. Configure /config/rclone.conf and /config/script.conf for custom behavior."
|
||||
@@ -0,0 +1,27 @@
|
||||
services:
|
||||
aria2-rust-pro:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile
|
||||
image: aria2-rust-pro:local
|
||||
container_name: aria2-rust-pro
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
PUID: ${PUID:-1000}
|
||||
PGID: ${PGID:-1000}
|
||||
UMASK_SET: ${UMASK_SET:-022}
|
||||
RPC_SECRET: ${RPC_SECRET:?Set RPC_SECRET in docker/.env before exposing RPC}
|
||||
RPC_PORT: ${RPC_PORT:-6800}
|
||||
LISTEN_PORT: ${LISTEN_PORT:-6888}
|
||||
DISK_CACHE: ${DISK_CACHE:-64M}
|
||||
IPV6_MODE: ${IPV6_MODE:-false}
|
||||
UPDATE_TRACKERS: ${UPDATE_TRACKERS:-false}
|
||||
CUSTOM_TRACKER_URL: ${CUSTOM_TRACKER_URL:-}
|
||||
SPECIAL_MODE: ${SPECIAL_MODE:-}
|
||||
ports:
|
||||
- "${RPC_BIND_ADDRESS:-127.0.0.1}:${RPC_PORT:-6800}:${RPC_PORT:-6800}"
|
||||
- "${LISTEN_PORT:-6888}:${LISTEN_PORT:-6888}"
|
||||
- "${LISTEN_PORT:-6888}:${LISTEN_PORT:-6888}/udp"
|
||||
volumes:
|
||||
- ../.local/docker/config:/config
|
||||
- ../.local/docker/downloads:/downloads
|
||||
Executable
+176
@@ -0,0 +1,176 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
CONFIG_DIR="${CONFIG_DIR:-/config}"
|
||||
DOWNLOAD_DIR="${DOWNLOAD_DIR:-/downloads}"
|
||||
DEFAULTS_DIR="${DEFAULTS_DIR:-/defaults}"
|
||||
RUNTIME_DIR="${RUNTIME_DIR:-/run/aria2-rust-pro}"
|
||||
BASE_CONFIG="${CONFIG_DIR}/aria2.conf"
|
||||
SESSION_FILE="${CONFIG_DIR}/aria2.session"
|
||||
RUNTIME_CONFIG="${RUNTIME_DIR}/aria2.generated.conf"
|
||||
ARIA2_BIN="${ARIA2_BIN:-/usr/local/bin/aria2c}"
|
||||
SCRIPT_DIR="${CONFIG_DIR}/script"
|
||||
SCRIPT_CONFIG="${CONFIG_DIR}/script.conf"
|
||||
TRACKER_SNAPSHOT="${DEFAULTS_DIR}/bt-tracker.txt"
|
||||
explicit_aria2_command=0
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
case "$1" in
|
||||
aria2c|aria2-rust-pro)
|
||||
explicit_aria2_command=1
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
;;
|
||||
*)
|
||||
exec "$@"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ "${explicit_aria2_command}" -eq 1 ] && [ "$#" -gt 0 ]; then
|
||||
case "$1" in
|
||||
--version|-v|--help|-h|--help=*)
|
||||
exec "${ARIA2_BIN}" "$@"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
mkdir -p "${CONFIG_DIR}" "${DOWNLOAD_DIR}" "${RUNTIME_DIR}"
|
||||
|
||||
if [ ! -f "${BASE_CONFIG}" ]; then
|
||||
cp "${DEFAULTS_DIR}/aria2.conf" "${BASE_CONFIG}"
|
||||
fi
|
||||
|
||||
if [ ! -f "${SESSION_FILE}" ]; then
|
||||
: > "${SESSION_FILE}"
|
||||
fi
|
||||
|
||||
copy_default_if_missing() {
|
||||
src="$1"
|
||||
dest="$2"
|
||||
if [ ! -e "${dest}" ]; then
|
||||
cp "${src}" "${dest}"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_mode_script() {
|
||||
script_name="$1"
|
||||
mkdir -p "${SCRIPT_DIR}"
|
||||
copy_default_if_missing "${DEFAULTS_DIR}/script/${script_name}" "${SCRIPT_DIR}/${script_name}"
|
||||
chmod 755 "${SCRIPT_DIR}/${script_name}"
|
||||
}
|
||||
|
||||
apply_bt_tracker_snapshot() {
|
||||
if [ ! -f "${TRACKER_SNAPSHOT}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
bundled_trackers="$(
|
||||
sed 's/\r$//' "${TRACKER_SNAPSHOT}" |
|
||||
awk 'NF {print}' |
|
||||
paste -sd, -
|
||||
)"
|
||||
|
||||
if [ -z "${bundled_trackers}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -Eq '^bt-tracker=.+$' "${RUNTIME_CONFIG}"; then
|
||||
return
|
||||
fi
|
||||
|
||||
if grep -q '^bt-tracker=' "${RUNTIME_CONFIG}"; then
|
||||
tmp_file="$(mktemp)"
|
||||
awk -v value="bt-tracker=${bundled_trackers}" '
|
||||
BEGIN { replaced = 0 }
|
||||
/^bt-tracker=/ { print value; replaced = 1; next }
|
||||
{ print }
|
||||
END { if (!replaced) print value }
|
||||
' "${RUNTIME_CONFIG}" > "${tmp_file}"
|
||||
cat "${tmp_file}" > "${RUNTIME_CONFIG}"
|
||||
rm -f "${tmp_file}"
|
||||
return
|
||||
fi
|
||||
|
||||
append_line "bt-tracker=${bundled_trackers}"
|
||||
}
|
||||
|
||||
configure_special_mode() {
|
||||
mode="${SPECIAL_MODE:-}"
|
||||
case "${mode}" in
|
||||
"")
|
||||
return
|
||||
;;
|
||||
move)
|
||||
copy_mode_script "move.sh"
|
||||
copy_default_if_missing "${DEFAULTS_DIR}/script.conf" "${SCRIPT_CONFIG}"
|
||||
append_line "on-download-complete=${SCRIPT_DIR}/move.sh"
|
||||
;;
|
||||
rclone)
|
||||
copy_mode_script "upload.sh"
|
||||
copy_default_if_missing "${DEFAULTS_DIR}/script.conf" "${SCRIPT_CONFIG}"
|
||||
copy_default_if_missing "${DEFAULTS_DIR}/script/rclone.env" "${CONFIG_DIR}/rclone.env"
|
||||
if ! command -v rclone >/dev/null 2>&1; then
|
||||
printf 'warning: SPECIAL_MODE=rclone was requested but the rclone binary is not available\n' >&2
|
||||
fi
|
||||
append_line "on-download-complete=${SCRIPT_DIR}/upload.sh"
|
||||
;;
|
||||
*)
|
||||
printf 'warning: unknown SPECIAL_MODE "%s"; expected empty, move, or rclone\n' "${mode}" >&2
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
append_line() {
|
||||
printf '%s\n' "$1" >> "${RUNTIME_CONFIG}"
|
||||
}
|
||||
|
||||
cp "${BASE_CONFIG}" "${RUNTIME_CONFIG}"
|
||||
append_line ""
|
||||
append_line "# Generated overrides"
|
||||
append_line "dir=${DOWNLOAD_DIR}"
|
||||
append_line "input-file=${SESSION_FILE}"
|
||||
append_line "save-session=${SESSION_FILE}"
|
||||
append_line "save-session-interval=60"
|
||||
append_line "enable-rpc=true"
|
||||
append_line "rpc-listen-port=${RPC_PORT:-6800}"
|
||||
append_line "listen-port=${LISTEN_PORT:-6888}"
|
||||
append_line "dht-listen-port=${LISTEN_PORT:-6888}"
|
||||
if [ "${IPV6_MODE:-false}" = "true" ] || [ "${IPV6_MODE:-false}" = "TRUE" ] || [ "${IPV6_MODE:-false}" = "1" ]; then
|
||||
append_line "disable-ipv6=false"
|
||||
else
|
||||
append_line "disable-ipv6=true"
|
||||
fi
|
||||
|
||||
if [ -n "${DISK_CACHE:-}" ]; then
|
||||
append_line "disk-cache=${DISK_CACHE}"
|
||||
fi
|
||||
|
||||
if [ -n "${RPC_SECRET:-}" ]; then
|
||||
append_line "rpc-secret=${RPC_SECRET}"
|
||||
append_line "rpc-listen-all=true"
|
||||
else
|
||||
printf 'warning: RPC_SECRET is empty; RPC stays loopback-only unless the base config overrides it\n' >&2
|
||||
fi
|
||||
|
||||
apply_bt_tracker_snapshot
|
||||
configure_special_mode
|
||||
|
||||
if [ "${UPDATE_TRACKERS:-false}" = "true" ] || [ "${UPDATE_TRACKERS:-false}" = "TRUE" ] || [ "${UPDATE_TRACKERS:-false}" = "1" ]; then
|
||||
if ! "${DEFAULTS_DIR}/script/tracker.sh" "${RUNTIME_CONFIG}"; then
|
||||
printf 'warning: tracker update failed; continuing with bundled or existing tracker data\n' >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${PUID:-}" ] && [ -n "${PGID:-}" ]; then
|
||||
chown -R "${PUID}:${PGID}" "${CONFIG_DIR}" "${DOWNLOAD_DIR}" "${RUNTIME_DIR}"
|
||||
fi
|
||||
|
||||
umask "${UMASK_SET:-022}"
|
||||
|
||||
if [ -n "${PUID:-}" ] && [ -n "${PGID:-}" ]; then
|
||||
exec gosu "${PUID}:${PGID}" "${ARIA2_BIN}" --enable-rpc --conf-path="${RUNTIME_CONFIG}" "$@"
|
||||
fi
|
||||
|
||||
exec "${ARIA2_BIN}" --enable-rpc --conf-path="${RUNTIME_CONFIG}" "$@"
|
||||
Reference in New Issue
Block a user