From eea40150db547f07ed0048a8f1546000a16d2ad7 Mon Sep 17 00:00:00 2001 From: Zoey Date: Fri, 10 Jan 2025 19:15:28 +0100 Subject: [PATCH] fix #1371/#1373/fix hosts always regenerate on container restart/fix healtheck/change minimum PUID/PGID Signed-off-by: Zoey --- backend/package.json | 4 ++-- backend/schema/components/stream-object.json | 4 ++-- compose.yaml | 4 ++-- rootfs/usr/local/bin/healthcheck.sh | 22 ++++++++++------- rootfs/usr/local/bin/start.sh | 25 +++++++++++++------- 5 files changed, 36 insertions(+), 23 deletions(-) diff --git a/backend/package.json b/backend/package.json index 9b194f1fa..9648bd4f1 100644 --- a/backend/package.json +++ b/backend/package.json @@ -32,8 +32,8 @@ "license": "MIT", "devDependencies": { "@apidevtools/swagger-parser": "10.1.1", - "@eslint/js": "9.17.0", - "eslint": "9.17.0", + "@eslint/js": "9.18.0", + "eslint": "9.18.0", "eslint-config-prettier": "9.1.0", "eslint-plugin-prettier": "5.2.1", "globals": "15.14.0", diff --git a/backend/schema/components/stream-object.json b/backend/schema/components/stream-object.json index 16c8ada24..f36ed40c5 100644 --- a/backend/schema/components/stream-object.json +++ b/backend/schema/components/stream-object.json @@ -18,7 +18,7 @@ }, "incoming_port": { "type": "string", - "pattern": "^([0-9]+{1,5}$|[0-9]+{1,5}-[0-9]+{1,5}$)", + "pattern": "^([0-9]{1,5}$|[0-9]{1,5}-[0-9]{1,5}$)", "maxLength": 11 }, "forwarding_host": { @@ -27,7 +27,7 @@ }, "forwarding_port": { "type": "string", - "pattern": "^([0-9]+{1,5}|\\$server_port)$", + "pattern": "^([0-9]{1,5}|\\$server_port)$", "maxLength": 12 }, "tcp_forwarding": { diff --git a/compose.yaml b/compose.yaml index 6fc502156..a56e401f1 100644 --- a/compose.yaml +++ b/compose.yaml @@ -19,8 +19,8 @@ services: # - "ACME_OCSP_STAPLING=false" # enables ocsp stapling, default true, I recommend you to enable this if your CA supports it, supported by zerossl and google public ca, unsupported by letsencrypt certs created after May 7, 2025 (will create warning in your log, default value will change then) # - "ACME_KEY_TYPE=rsa" # which key type to use ecdsa or rsa, default and recommended: ecdsa # - "ACME_SERVER_TLS_VERIFY=false" # enables checking if ACME_SERVER has a valid TLS cert, default true -# - "PUID=1000" # set group id, default 0 (root) -# - "PGID=1000" # set user id, default 0 (root), requires PUID +# - "PUID=1000" # set group id, needs to be a number greater or equal to 99, or equal to 0, default 0 (root) +# - "PGID=1000" # set user id, needs to be a number greater or equal to 99, or equal to 0, default 0 (root), requires PUID to be not 0 # - "NIBEP=48682" # internal port of the NPMplus API, always bound to 127.0.0.1, default 48681, you need to change it, if you want to run multiple npm instances in network mode host # - "GOAIWSP=48692" # internal port of goaccess, always bound to 127.0.0.1, default 48691, you need to change it, if you want to run multiple npm with goaccess instances in network mode host # - "NPM_PORT=82" # Port the NPM UI should be bound to, default 81, you need to change it, if you want to run multiple npm instances in network mode host diff --git a/rootfs/usr/local/bin/healthcheck.sh b/rootfs/usr/local/bin/healthcheck.sh index bae9da18d..0cc11c09f 100755 --- a/rootfs/usr/local/bin/healthcheck.sh +++ b/rootfs/usr/local/bin/healthcheck.sh @@ -1,18 +1,24 @@ #!/usr/bin/env sh -export HCNPM_IP="$NPM_IPV4_BINDING" -export HCGOA_IP="$GOA_IPV4_BINDING" - -if [ "$NPM_IPV4_BINDING" = "0.0.0.0" ]; then - export HCNPM_IP="127.0.0.1" +export GOA="${GOA:-false}" +export GOA_PORT="${GOA_PORT:-91}" +export GOA_IPV4_BINDING="${GOA_IPV4_BINDING:-0.0.0.0}" +if [ "$GOA_IPV4_BINDING" = "0.0.0.0" ]; then + export GOA_IPV4_BINDING="127.0.0.1" fi -if [ "$GOA_IPV4_BINDING" = "0.0.0.0" ]; then - export HCGOA_IP="127.0.0.1" +export PHP82="${PHP82:-false}" +export PHP83="${PHP83:-false}" +export PHP84="${PHP84:-false}" + +export NPM_PORT="${NPM_PORT:-81}" +export NPM_IPV4_BINDING="${NPM_IPV4_BINDING:-0.0.0.0}" +if [ "$NPM_IPV4_BINDING" = "0.0.0.0" ]; then + export NPM_IPV4_BINDING="127.0.0.1" fi -if (if [ "$GOA" = "true" ]; then [ -f /tmp/goa/index.html ] && nc -z "$HCGOA_IP" "$GOA_PORT"; fi && if [ "$PHP82" = true ]; then cgi-fcgi -bind -connect /run/php82.sock > /dev/null 2>&1; fi && if [ "$PHP83" = true ]; then cgi-fcgi -bind -connect /run/php83.sock > /dev/null 2>&1; fi && [ "$(curl -sk https://"$HCNPM_IP":"$NPM_PORT"/api/ | jq --raw-output .status)" = "OK" ]); then +if (if [ "$GOA" = "true" ]; then [ -f /tmp/goa/index.html ] && nc -z "$GOA_IPV4_BINDING" "$GOA_PORT"; fi && if [ "$PHP82" = true ]; then cgi-fcgi -bind -connect /run/php82.sock > /dev/null 2>&1; fi && if [ "$PHP83" = true ]; then cgi-fcgi -bind -connect /run/php83.sock > /dev/null 2>&1; fi && if [ "$PHP84" = true ]; then cgi-fcgi -bind -connect /run/php84.sock > /dev/null 2>&1; fi && [ "$(curl -sk https://"$NPM_IPV4_BINDING":"$NPM_PORT"/api/ | jq --raw-output .status)" = "OK" ]); then echo "OK" exit 0 else diff --git a/rootfs/usr/local/bin/start.sh b/rootfs/usr/local/bin/start.sh index 027d10b35..d7a6159fd 100755 --- a/rootfs/usr/local/bin/start.sh +++ b/rootfs/usr/local/bin/start.sh @@ -156,22 +156,22 @@ fi if ! echo "$PUID" | grep -q "^[0-9]\+$"; then - echo "PUID needs to be a number greater or equal to 1000, or equal to 0." + echo "PUID needs to be a number greater or equal to 99, or equal to 0." sleep inf fi -if [ "$PUID" -lt "1000" ] && [ "$PUID" != "0" ]; then - echo "PUID needs to be a number greater or equal to 1000, or equal to 0." +if [ "$PUID" -lt "99" ] && [ "$PUID" != "0" ]; then + echo "PUID needs to be a number greater or equal to 99, or equal to 0." sleep inf fi if ! echo "$PGID" | grep -q "^[0-9]\+$"; then - echo "PGID needs to be a number greater or equal to 1000, or equal to 0." + echo "PGID needs to be a number greater or equal to 99, or equal to 0." sleep inf fi -if [ "$PGID" -lt "1000" ] && [ "$PGID" != "0" ]; then - echo "PGID needs to be a number greater or equal to 1000, or equal to 0." +if [ "$PGID" -lt "99" ] && [ "$PGID" != "0" ]; then + echo "PGID needs to be a number greater or equal to 99, or equal to 0." sleep inf fi @@ -377,8 +377,14 @@ if echo "$GOACLA" | grep -vq "geoip-database"; then if [ -s /data/etc/goaccess/geoip/GeoLite2-City.mmdb ] || [ -s /data/etc/goaccess/geoip/GeoLite2-Country.mmdb ]|| [ -s /data/etc/goaccess/geoip/GeoLite2-ASN.mmdb ]; then echo "All goaccess geoip databases need to be moved from etc/goaccess/geoip to goaccess/geoip inside the mounted data folder!" fi - if [ -s /data/goaccess/GeoLite2-City.mmdb ] && [ -s /data/goaccess/GeoLite2-Country.mmdb ] && [ -s /data/goaccess/GeoLite2-ASN.mmdb ]; then - export GOACLA="$GOACLA --geoip-database=/data/goaccess/geoip/GeoLite2-City.mmdb --geoip-database=/data/goaccess/geoip/GeoLite2-Country.mmdb --geoip-database=/data/goaccess/geoip/GeoLite2-ASN.mmdb" + if [ -s /data/goaccess/geoip/GeoLite2-City.mmdb ]; then + export GOACLA="$GOACLA --geoip-database=/data/goaccess/geoip/GeoLite2-City.mmdb" + fi + if [ -s /data/goaccess/geoip/GeoLite2-Country.mmdb ]; then + export GOACLA="$GOACLA --geoip-database=/data/goaccess/geoip/GeoLite2-Country.mmdb" + fi + if [ -s /data/goaccess/geoip/GeoLite2-ASN.mmdb ]; then + export GOACLA="$GOACLA --geoip-database=/data/goaccess/geoip/GeoLite2-ASN.mmdb" fi fi @@ -467,7 +473,8 @@ if [ "$NC_AIO" = "true" ]; then fi -if [ ! -s /data/npmplus/env.sha512sum ] || [ "$(cat /data/npmplus/env.sha512sum)" != "$( (grep "env\.[A-Z0-9_]\+" -roh /app/templates | sed "s|env.||g" | sort | uniq | xargs printenv; echo "1") | tr -d "\n" | sha512sum | cut -d" " -f1)" ]; then +export TV="1" +if [ ! -s /data/npmplus/env.sha512sum ] || [ "$(cat /data/npmplus/env.sha512sum)" != "$( (grep "env\.[A-Z0-9_]\+" -roh /app/templates | sed "s|env.||g" | sort | uniq | xargs printenv; echo "$TV") | tr -d "\n" | sha512sum | cut -d" " -f1)" ]; then echo "At least one env or the template version changed, all hosts will be regenerated." export REGENERATE_ALL="true" fi