Files
smallwebwaf/script/run
T
clawbot 4d4ae61abf
check / check (push) Waiting to run
Rename the settings whose names do not say what they control (closes #234)
Applies the setting renames of the naming audit under the SWW_WAF_ and
SWW_RPROXY_ prefixes, with sneak's names for the IP reputation cache
time and the two time limits, which now take milliseconds. The rproxy
log field default_disposition becomes waf_backend_no_answer, and
config.Config and config.FromEnvironment become config.WAF and
config.WAFFromEnvironment. Go fields, test names and prose follow. No
aliases; nothing reads the old names.

Model: opus-5-5
2026-11-12 09:48:09 +00:00

59 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
# script/run: build bin/sww with script/build and run waf and
# rproxy on the host, with the settings in the environment, until rproxy
# exits or the script is told to stop. rproxy listens on port 8080 unless
# SWW_RPROXY_LISTEN_ADDR says otherwise, in front of the app at SWW_RPROXY_UPSTREAM_URL.
# waf listens on port 8090 unless SWW_WAF_LISTEN_ADDR says otherwise, and
# rproxy asks it there unless SWW_RPROXY_WAF_BACKEND says otherwise. Unless
# SWW_WAF_STATE_DIR is set, the state files go in bin/state, beside the binary,
# and unless SWW_WAF_CACHE_DIR is set, the cache files go in bin/cache. Unless
# SWW_WAF_RULE_FILES_DIR is set, the rule files are those of share/rules.d, which the
# image ships.
set -eu
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)"
ROOT="$(cd "$SCRIPT_DIR/.." && pwd -P)"
WAF=""
RPROXY=""
# stop_both: stop what runs, and wait for it, so that waf writes its state
# files.
stop_both() {
trap '' HUP INT TERM
kill $WAF $RPROXY 2>/dev/null || true
wait || true
}
main() {
"$SCRIPT_DIR/build"
if [ -z "${SWW_WAF_STATE_DIR+set}" ]; then
SWW_WAF_STATE_DIR="$ROOT/bin/state"
export SWW_WAF_STATE_DIR
mkdir -p "$SWW_WAF_STATE_DIR"
fi
if [ -z "${SWW_WAF_CACHE_DIR+set}" ]; then
SWW_WAF_CACHE_DIR="$ROOT/bin/cache"
export SWW_WAF_CACHE_DIR
mkdir -p "$SWW_WAF_CACHE_DIR"
fi
if [ -z "${SWW_WAF_RULE_FILES_DIR+set}" ]; then
SWW_WAF_RULE_FILES_DIR="$ROOT/share/rules.d"
export SWW_WAF_RULE_FILES_DIR
fi
SWW_WAF_LISTEN_ADDR="${SWW_WAF_LISTEN_ADDR:-:8090}"
SWW_RPROXY_WAF_BACKEND="${SWW_RPROXY_WAF_BACKEND:-http://127.0.0.1:${SWW_WAF_LISTEN_ADDR##*:}}"
export SWW_WAF_LISTEN_ADDR SWW_RPROXY_WAF_BACKEND
trap stop_both EXIT
trap 'exit 1' HUP INT TERM
"$ROOT/bin/sww" waf &
WAF=$!
"$ROOT/bin/sww" rproxy &
RPROXY=$!
wait "$RPROXY"
}
main "$@"