From 1d6dd1520ef2e47a129c9b1dc9fc233994d898c7 Mon Sep 17 00:00:00 2001 From: casjay Date: Wed, 22 Oct 2025 10:50:04 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Update=20codebase=20?= =?UTF-8?q?=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/usr/local/bin/entrypoint.sh rootfs/usr/local/etc/docker/functions/entrypoint.sh rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh rootfs/usr/local/etc/docker/init.d/03-tor-server.sh rootfs/usr/local/etc/docker/init.d/09-unbound.sh rootfs/usr/local/etc/docker/init.d/98-privoxy.sh rootfs/usr/local/etc/docker/init.d/zz-nginx.sh --- rootfs/usr/local/bin/entrypoint.sh | 2 +- .../local/etc/docker/functions/entrypoint.sh | 28 ++++++++++++------- .../local/etc/docker/init.d/01-tor-bridge.sh | 4 +-- .../local/etc/docker/init.d/02-tor-relay.sh | 4 +-- .../local/etc/docker/init.d/03-tor-server.sh | 11 ++++---- .../usr/local/etc/docker/init.d/09-unbound.sh | 4 +-- .../usr/local/etc/docker/init.d/98-privoxy.sh | 4 +-- .../usr/local/etc/docker/init.d/zz-nginx.sh | 4 +-- 8 files changed, 35 insertions(+), 26 deletions(-) diff --git a/rootfs/usr/local/bin/entrypoint.sh b/rootfs/usr/local/bin/entrypoint.sh index d99ae2a..69aef8f 100755 --- a/rootfs/usr/local/bin/entrypoint.sh +++ b/rootfs/usr/local/bin/entrypoint.sh @@ -84,7 +84,7 @@ SERVICE_UID="${SERVICE_UID:-0}" # set the user id SERVICE_GID="${SERVICE_GID:-0}" # set the group id # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -SERVICE_USER="${SERVICE_USER:-$tor}" # execute command as another user +SERVICE_USER="${SERVICE_USER:-tor}" # execute command as another user SERVICE_GROUP="${SERVICE_GROUP:-tor}" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Secondary ports diff --git a/rootfs/usr/local/etc/docker/functions/entrypoint.sh b/rootfs/usr/local/etc/docker/functions/entrypoint.sh index 651d559..9dd6b3d 100644 --- a/rootfs/usr/local/etc/docker/functions/entrypoint.sh +++ b/rootfs/usr/local/etc/docker/functions/entrypoint.sh @@ -677,17 +677,18 @@ __create_service_user() { echo "$create_user ALL=(ALL) NOPASSWD: ALL" >"/etc/sudoers" fi exitStatus=0 - export SERVICE_UID="$create_uid" - export SERVICE_GID="$create_gid" - export SERVICE_USER="$create_user" - export SERVICE_GROUP="$create_group" + SERVICE_UID="$create_uid" + SERVICE_GID="$create_gid" + SERVICE_USER="$create_user" + SERVICE_GROUP="$create_group" else - export USER_UID=0 - export USER_GID=0 - export SERVICE_USER=root - export SERVICE_GROUP=root + SERVICE_UID=0 + SERVICE_GID=0 + SERVICE_USER=root + SERVICE_GROUP=root exitStatus=2 fi + export SERVICE_UID SERVICE_GID SERVICE_USER SERVICE_GROUP return $exitStatus } # - - - - - - - - - - - - - - - - - - - - - - - - - @@ -744,6 +745,7 @@ __start_init_scripts() { local retstatus="0" local initStatus="0" local critical_failures="0" + local pidFile="/run/__start_init_scripts.pid" local init_dir="${1:-/usr/local/etc/docker/init.d}" local init_count="$(ls -A "$init_dir"/* 2>/dev/null | grep -v '\.sample' | wc -l)" local exit_on_failure="${EXIT_ON_SERVICE_FAILURE:-true}" @@ -754,7 +756,7 @@ __start_init_scripts() { rm -f /run/*.pid /run/init.d/*.pid 2>/dev/null || true fi - touch /run/__start_init_scripts.pid + touch "$pidFile" if [ "$init_count" -eq 0 ] || [ ! -d "$init_dir" ]; then mkdir -p "/data/logs/init" @@ -772,6 +774,7 @@ __start_init_scripts() { for init in "$init_dir"/*.sh; do if [ -x "$init" ]; then + touch "$pidFile" name="$(basename "$init")" service="$(printf '%s' "$name" | sed 's/^[^-]*-//;s|.sh$||g')" __service_banner "🔧" "Executing service script:" "$(basename "$init")" @@ -798,14 +801,19 @@ __start_init_scripts() { fi else # Service uses PID tracking - verify actual running processes + set +e # Temporarily disable exit on error retPID="" + # First, try to find actual running process with various name patterns - for name_variant in "$service" "${service//-*/}" "${service//-/_}"; do + for name_variant in "$service" "${service}84" "${service}d" "$(echo "$service" | sed 's/-//g')" "$(echo "$service" | tr -d '-')"; do if [ -z "$retPID" ]; then retPID=$(__get_pid "$name_variant" 2>/dev/null || echo "") [ -n "$retPID" ] && found_process="$name_variant" && break fi done + + set -e # Re-enable exit on error + if [ -n "$retPID" ] && [ "$retPID" != "0" ]; then # Found actual running process initStatus="0" diff --git a/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh b/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh index bdf3a1b..6a2c2a5 100755 --- a/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh +++ b/rootfs/usr/local/etc/docker/init.d/01-tor-bridge.sh @@ -110,8 +110,8 @@ SERVICE_PORT="" RUNAS_USER="root" # normally root # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -#SERVICE_USER="tor" # execute command as another user -#SERVICE_GROUP="tor" # Set the service group +SERVICE_USER="root" # execute command as another user +SERVICE_GROUP="root" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set password length RANDOM_PASS_USER="" diff --git a/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh b/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh index ad6157f..ed19003 100755 --- a/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh +++ b/rootfs/usr/local/etc/docker/init.d/02-tor-relay.sh @@ -110,8 +110,8 @@ SERVICE_PORT="" RUNAS_USER="root" # normally root # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -#SERVICE_USER="tor" # execute command as another user -#SERVICE_GROUP="tor" # Set the service group +SERVICE_USER="root" # execute command as another user +SERVICE_GROUP="root" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set password length RANDOM_PASS_USER="" diff --git a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh index 6feaa05..e04e06e 100755 --- a/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh +++ b/rootfs/usr/local/etc/docker/init.d/03-tor-server.sh @@ -110,8 +110,8 @@ SERVICE_PORT="" RUNAS_USER="root" # normally root # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -#SERVICE_USER="tor" # execute command as another user -#SERVICE_GROUP="tor" # Set the service group +SERVICE_USER="root" # execute command as another user +SERVICE_GROUP="root" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set password length RANDOM_PASS_USER="" @@ -389,7 +389,8 @@ __post_execute() { ( # commands to execute while :; do - if pgrep unbound >/dev/null 2>&1; then + if __pgrep unbound >/dev/null 2>&1; then + get_hidden_service_hostnames=$(find "$DATA_DIR/services" -iname 'hostname' 2>/dev/null | wc -l || echo "0") break else sleep 10 @@ -400,8 +401,8 @@ __post_execute() { if [ -d "/data/htdocs/www" ]; then WWW_ROOT_DIR="/data/htdocs/www" fi - if [ -d "$DATA_DIR/services" ]; then - echo "Begin current hidden services"htdocs + if [ -d "$DATA_DIR/services" ] && [ "$get_hidden_service_hostnames" -gt 0 ]; then + echo "Begin current hidden services" [ -f "$WWW_ROOT_DIR/hostnames.html" ] && rm -f "$WWW_ROOT_DIR/hostnames.html" for host in "$DATA_DIR/services"/*/hostname; do d="$(dirname -- $host)" diff --git a/rootfs/usr/local/etc/docker/init.d/09-unbound.sh b/rootfs/usr/local/etc/docker/init.d/09-unbound.sh index 2eaedb7..bb5fe57 100755 --- a/rootfs/usr/local/etc/docker/init.d/09-unbound.sh +++ b/rootfs/usr/local/etc/docker/init.d/09-unbound.sh @@ -110,8 +110,8 @@ SERVICE_PORT="9053" RUNAS_USER="root" # normally root # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -#SERVICE_USER="unbound" # execute command as another user -#SERVICE_GROUP="unbound" # Set the service group +SERVICE_USER="root" # execute command as another user +SERVICE_GROUP="root" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set password length RANDOM_PASS_USER="" diff --git a/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh b/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh index e20da6d..87749c3 100755 --- a/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh +++ b/rootfs/usr/local/etc/docker/init.d/98-privoxy.sh @@ -112,8 +112,8 @@ SERVICE_PORT="8118" RUNAS_USER="root" # normally root # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -#SERVICE_USER="privoxy" # execute command as another user -#SERVICE_GROUP="privoxy" # Set the service group +SERVICE_USER="root" # execute command as another user +SERVICE_GROUP="root" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set password length RANDOM_PASS_USER="" diff --git a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh index 5afc8fb..ae462b8 100755 --- a/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh +++ b/rootfs/usr/local/etc/docker/init.d/zz-nginx.sh @@ -110,8 +110,8 @@ SERVICE_PORT="80" RUNAS_USER="root" # normally root # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # User and group in which the service switches to - IE: nginx,apache,mysql,postgres -#SERVICE_USER="nginx" # execute command as another user -#SERVICE_GROUP="nginx" # Set the service group +SERVICE_USER="root" # execute command as another user +SERVICE_GROUP="root" # Set the service group # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Set password length RANDOM_PASS_USER=""