Skip to content

Commit

Permalink
fix #1371/#1373/fix hosts always regenerate on container restart/fix …
Browse files Browse the repository at this point in the history
…healtheck/change minimum PUID/PGID

Signed-off-by: Zoey <[email protected]>
  • Loading branch information
Zoey2936 committed Jan 11, 2025
1 parent aff410c commit eea4015
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
4 changes: 2 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions backend/schema/components/stream-object.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 14 additions & 8 deletions rootfs/usr/local/bin/healthcheck.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down
25 changes: 16 additions & 9 deletions rootfs/usr/local/bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eea4015

Please sign in to comment.