Files
aria2/rootfs/root/docker/setup/05-custom.sh
T

57 lines
2.5 KiB
Bash
Raw Normal View History

2025-02-04 21:48:34 -05:00
#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2026-05-12 20:05:30 -04:00
##@Version : 202605101200-git
2025-02-04 21:48:34 -05:00
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@ReadME :
2026-05-12 20:05:30 -04:00
# @@Copyright : Copyright 2026 CasjaysDev
2025-02-04 21:48:34 -05:00
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 05-custom.sh
2026-05-12 20:05:30 -04:00
# @@Description : build-time custom: install AriaNg from prebundled zip + wipe-and-replace configs
2025-02-04 21:48:34 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# shellcheck shell=bash
2026-05-12 20:05:30 -04:00
# shellcheck disable=SC2016,SC2031,SC2120,SC2155,SC2199,SC2317
2025-02-04 21:48:34 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
2025-02-04 22:08:45 -05:00
set -o pipefail
2025-02-04 21:48:34 -05:00
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables
exitCode=0
2025-02-04 22:08:45 -05:00
ARIANG_HOME="/usr/local/share/ariang"
2026-05-12 20:05:30 -04:00
ARIANG_SRC_DIR="/tmp/ariang-src"
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Wipe-and-replace per-service configs (per template §4)
for d in aria2 nginx; do
[ -d "/tmp/etc/$d" ] || continue
echo "Wiping /etc/$d and copying from /tmp/etc/$d"
rm -Rf "/etc/$d"/*
cp -Rf "/tmp/etc/$d/." "/etc/$d/"
# restage template-files/config so first-run seed gets the optimized config
mkdir -p "/usr/local/share/template-files/config/$d"
cp -Rf "/etc/$d/." "/usr/local/share/template-files/config/$d/"
done
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Install AriaNg from the host-prebundled zip (buildx network can't reach github reliably)
2025-05-13 16:22:29 -04:00
\rm -Rf "${ARIANG_HOME:?}"
\mkdir -p "${ARIANG_HOME:?}"
2026-05-12 20:05:30 -04:00
ARIANG_ZIP=""
if [ -d "$ARIANG_SRC_DIR" ]; then
ARIANG_ZIP="$(ls -1 "$ARIANG_SRC_DIR"/AriaNg-*.zip 2>/dev/null | head -n1 || true)"
fi
if [ -n "$ARIANG_ZIP" ] && [ -f "$ARIANG_ZIP" ]; then
echo "Extracting prebundled AriaNg: $ARIANG_ZIP -> $ARIANG_HOME"
unzip -qq "$ARIANG_ZIP" -d "$ARIANG_HOME"
2025-02-04 21:48:34 -05:00
exitCode=$?
else
2026-05-12 20:05:30 -04:00
echo "ERROR: AriaNg zip not found at $ARIANG_SRC_DIR/AriaNg-*.zip" >&2
echo " Place AriaNg-X.Y.Z.zip from https://github.com/mayswind/AriaNg/releases there." >&2
2025-02-04 21:54:43 -05:00
exitCode=9
2025-02-04 21:48:34 -05:00
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2026-05-12 20:05:30 -04:00
# Create runtime dirs that aria2 + nginx need on first start
mkdir -p /run/nginx /run/aria2 /data/downloads/aria2 /data/logs/aria2 /data/logs/nginx /var/log/nginx
2025-02-04 21:48:34 -05:00
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode