fixes
This commit is contained in:
@@ -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 <arg>' and without '-c <file>'
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user