From 34c4aa2577fb40ffdb123cc5b8b56c4184c6403d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Gruszczy=C5=84ski?= Date: Thu, 23 Oct 2025 23:06:34 +0200 Subject: [PATCH] fixes --- npm_install.py | 58 +++----------------------------------------------- 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/npm_install.py b/npm_install.py index 4162f9c..fcece14 100644 --- a/npm_install.py +++ b/npm_install.py @@ -332,61 +332,8 @@ def setup_angie(): write_file(Path("/usr/sbin/nginx"), "#!/bin/sh\nexec /usr/sbin/angie \"$@\"\n", 0o755) WRAP = """#!/bin/sh -# nginx compat -> angie; silent safe config test (-t) -# - drop all user -g -# - for -t use temp config without 'pid' -# - suppress ALL output; return angie's exit code - -strip_pid_conf() { - # find base config from -c if provided, else default - local base_conf="/etc/angie/angie.conf" - local next_is_c= - local arg - for arg in "$@"; do - if [ -n "$next_is_c" ]; then - base_conf="$arg" - next_is_c= - continue - fi - [ "$arg" = "-c" ] && next_is_c=1 - done - - # create a temp config with any top-level 'pid ...;' removed - local tmpd tmpc - tmpd="$(mktemp -d)" - tmpc="$tmpd/angie.conf" - # remove 'pid ...;' at start of line (optionally indented) - sed -E 's/^[[:space:]]*pid[[:space:]]+[^;]+;//' "$base_conf" > "$tmpc" - printf '%s\n' "$tmpc" -} - -if printf ' %s ' "$@" | grep -q ' -t '; then - # rebuild args without any '-g ' and without '-c ' - NEW_ARGS="" - skip_next="" - for a in "$@"; do - if [ -n "$skip_next" ]; then - skip_next="" - continue - fi - if [ "$a" = "-g" ] || [ "$a" = "-c" ]; then - skip_next=1 - continue - fi - NEW_ARGS="$NEW_ARGS $a" - done - - TMP_CONF="$(strip_pid_conf "$@")" - # run test SILENTLY; propagate exit code; cleanup temp - # shellcheck disable=SC2086 - /usr/sbin/angie -g "pid /tmp/angie-test.pid; error_log off;" -c "$TMP_CONF" $NEW_ARGS >/dev/null 2>&1 - rc=$? - rm -rf "$(dirname "$TMP_CONF")" - exit $rc -else - exec /usr/sbin/angie "$@" -fi - +# /usr/sbin/nginx wrapper -> run angie as root via sudo (non-interactive) +exec sudo -n /usr/sbin/angie "$@" """ write_file(Path("/usr/sbin/nginx"), WRAP, 0o755) @@ -684,6 +631,7 @@ Wants=angie.service User=npm Group=npm WorkingDirectory=/opt/npm +Environment=DISABLE_IPV6=true Environment=NODE_ENV=production ExecStart=/usr/bin/node /opt/npm/index.js Restart=on-failure