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

57 lines
2.5 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202605101200-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@ReadME :
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Mon Aug 28 06:48:42 PM EDT 2023
# @@File : 05-custom.sh
# @@Description : build-time custom: install AriaNg from prebundled zip + wipe-and-replace configs
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# shellcheck shell=bash
# shellcheck disable=SC2016,SC2031,SC2120,SC2155,SC2199,SC2317
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables
exitCode=0
ARIANG_HOME="/usr/local/share/ariang"
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)
🗃️ Committing everything that changed 🗃️ Dockerfile .env.scripts .gitattributes .gitea/workflows/docker.yaml .gitignore LICENSE.md README.md rootfs/root/docker/setup/00-init.sh rootfs/root/docker/setup/01-system.sh rootfs/root/docker/setup/02-packages.sh rootfs/root/docker/setup/03-files.sh rootfs/root/docker/setup/04-users.sh rootfs/root/docker/setup/05-custom.sh rootfs/root/docker/setup/06-post.sh rootfs/root/docker/setup/07-cleanup.sh rootfs/tmp/ rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/bin/pkmgr rootfs/usr/local/etc/docker/env/00-directory.sh rootfs/usr/local/etc/docker/env/addresses.sh rootfs/usr/local/etc/docker/env/certbot.sh rootfs/usr/local/etc/docker/env/couchdb.sh rootfs/usr/local/etc/docker/env/default.sample rootfs/usr/local/etc/docker/env/global.sh rootfs/usr/local/etc/docker/env/healthcheck.sh rootfs/usr/local/etc/docker/env/mariadb.sh rootfs/usr/local/etc/docker/env/mongodb.sh rootfs/usr/local/etc/docker/env/networking.sh rootfs/usr/local/etc/docker/env/other.sh rootfs/usr/local/etc/docker/env/php.sh rootfs/usr/local/etc/docker/env/postgres.sh rootfs/usr/local/etc/docker/env/redis.sh rootfs/usr/local/etc/docker/env/services.sh rootfs/usr/local/etc/docker/env/ssl.sh rootfs/usr/local/etc/docker/env/supabase.sh rootfs/usr/local/etc/docker/env/webservers.sh rootfs/usr/local/etc/docker/env/zz-entrypoint.sh rootfs/usr/local/etc/docker/functions/ rootfs/usr/local/etc/docker/init.d/00-aria2c.sh rootfs/usr/local/etc/docker/init.d/zz-nginx.sh rootfs/usr/local/share/template-files/config/aria2/aria2.conf rootfs/usr/local/share/template-files/config/aria2/aria2.session rootfs/usr/local/share/template-files/config/aria2/aria-ng.config.js rootfs/usr/local/share/template-files/config/aria2/scripts/post-hook.sh rootfs/usr/local/share/template-files/config/env/default.sample rootfs/usr/local/share/template-files/config/env/examples/ rootfs/usr/local/share/template-files/config/.gitkeep rootfs/usr/local/share/template-files/config/nginx/mime.types rootfs/usr/local/share/template-files/config/nginx/nginx.conf
2025-05-13 16:22:29 -04:00
\rm -Rf "${ARIANG_HOME:?}"
\mkdir -p "${ARIANG_HOME:?}"
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"
exitCode=$?
else
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
exitCode=9
fi
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# 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
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode