webui: the unit script takes --send (#1576)
Row 83. scripts/webui-service.sh render and install take --send, only
with the full preview set; otherwise the script refuses before writing
anything. With --send the rendered ExecStart ends in --send; renders
without it are byte-identical to the base. status says whether the
installed unit sends. The script header, install message, README and
TOOLS.md carry the decision 102 start wording: Jason or Mos starts and
restarts the Console, no other agent.
Dewey's round 1, candidate manifest f764cd9e, base d13b9300. Approved
by Darkwing (27721) and Filbert (27722). Sage's gate green 04:07:30Z to
04:10:47Z.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -11,19 +11,24 @@
|
||||
# rename) and run `systemctl --user daemon-reload`
|
||||
# uninstall [--dir DIR] [--no-reload]
|
||||
# remove the unit; refuses while it is active
|
||||
# status [--dir DIR] unit state, then GET /healthz on its port
|
||||
# status [--dir DIR] unit state, whether it sends, then GET
|
||||
# /healthz on its port
|
||||
#
|
||||
# FLAGS are serve's: --port N (default 7332; 7330 is the operator's own
|
||||
# Console), --business ID, --board URL, and the preview set --public-host
|
||||
# NAME --auth-header HEADER --allow-user ID, all three or none. systemd
|
||||
# NAME --auth-header HEADER --allow-user ID, all three or none, and --send
|
||||
# (row 83), taken only with the preview set: the unit's Console then sends
|
||||
# human messages to roles and needs the system config at start. systemd
|
||||
# expands % and $ and splits on spaces, so each value is held to a plain
|
||||
# character set and refused otherwise. None is a secret.
|
||||
#
|
||||
# There is no start, stop, enable or restart verb. The Console reads the
|
||||
# bus through the human transport, so whoever starts it holds the human's
|
||||
# capability. An agent starting it, even detached through systemd, works
|
||||
# around the human proof (lead decisions 62 and 94). Jason starts it from
|
||||
# his own shell: `systemctl --user enable --now mosaic-webui`.
|
||||
# capability. Jason starts and restarts it
|
||||
# (`systemctl --user enable --now mosaic-webui`), and so may Mos under lead
|
||||
# decision 102, which accepts that sends from a Console Mos started enter
|
||||
# the trail as Jason (human-cli). Any other agent starting it, even detached
|
||||
# through systemd, works around the human proof (lead decisions 62 and 94).
|
||||
#
|
||||
# Exit codes: 0 ok, 1 operation failed, 4 usage.
|
||||
set -euo pipefail
|
||||
@@ -31,7 +36,7 @@ REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
TEMPLATE="$REPO/packages/webui/systemd/mosaic-webui.service.in"
|
||||
UNIT_NAME="mosaic-webui.service"
|
||||
USAGE="usage: scripts/webui-service.sh render [FLAGS] | install [--dir DIR] [--no-reload] [FLAGS] | uninstall [--dir DIR] [--no-reload] | status [--dir DIR]
|
||||
FLAGS: [--port N] [--business ID] [--board URL] [--public-host NAME --auth-header HEADER --allow-user ID]"
|
||||
FLAGS: [--port N] [--business ID] [--board URL] [--public-host NAME --auth-header HEADER --allow-user ID [--send]]"
|
||||
|
||||
die() { echo "webui-service: $*" >&2; exit 1; }
|
||||
usage() { echo "$USAGE" >&2; exit 4; }
|
||||
@@ -45,6 +50,7 @@ BOARD=""
|
||||
PUBLIC_HOST=""
|
||||
AUTH_HEADER=""
|
||||
ALLOW_USER=""
|
||||
SEND=0
|
||||
SERVE_SET=0
|
||||
|
||||
parse_flags() {
|
||||
@@ -58,6 +64,7 @@ parse_flags() {
|
||||
--public-host) [ $# -ge 2 ] || usage; PUBLIC_HOST="$2"; SERVE_SET=1; shift 2 ;;
|
||||
--auth-header) [ $# -ge 2 ] || usage; AUTH_HEADER="$2"; SERVE_SET=1; shift 2 ;;
|
||||
--allow-user) [ $# -ge 2 ] || usage; ALLOW_USER="$2"; SERVE_SET=1; shift 2 ;;
|
||||
--send) SEND=1; SERVE_SET=1; shift ;;
|
||||
*) usage ;;
|
||||
esac
|
||||
done
|
||||
@@ -86,6 +93,9 @@ serve_flags() {
|
||||
[ -z "$PUBLIC_HOST" ] || preview=$((preview + 1))
|
||||
[ -z "$AUTH_HEADER" ] || preview=$((preview + 1))
|
||||
[ -z "$ALLOW_USER" ] || preview=$((preview + 1))
|
||||
# serve refuses --send without the preview set; refuse it here first,
|
||||
# so no unit is written that would only exit 2 at start.
|
||||
[ "$SEND" = 0 ] || [ "$preview" -eq 3 ] || die "--send needs the preview mode (--public-host, --auth-header and --allow-user)"
|
||||
if [ "$preview" -ne 0 ]; then
|
||||
[ "$preview" -eq 3 ] || die "--public-host, --auth-header and --allow-user go together: all three or none"
|
||||
case "$PUBLIC_HOST" in [A-Za-z0-9]*) ;; *) die "public host must be a hostname, no port or scheme: $PUBLIC_HOST" ;; esac
|
||||
@@ -95,6 +105,7 @@ serve_flags() {
|
||||
case "$ALLOW_USER" in *[!A-Za-z0-9._@+-]*) die "allowed user contains a character the unit cannot carry: $ALLOW_USER" ;; esac
|
||||
flags="$flags --public-host $PUBLIC_HOST --auth-header $AUTH_HEADER --allow-user $ALLOW_USER"
|
||||
fi
|
||||
[ "$SEND" = 0 ] || flags="$flags --send"
|
||||
echo "$flags"
|
||||
}
|
||||
|
||||
@@ -138,8 +149,9 @@ install_unit() {
|
||||
echo "daemon-reload done"
|
||||
fi
|
||||
cat <<MSG
|
||||
this script starts nothing: the Console holds the human's capability, so the
|
||||
human starts it from their own shell:
|
||||
this script starts nothing: the Console holds the human's capability. Jason
|
||||
starts and restarts it, or Mos under lead decision 102 (sends then enter the
|
||||
trail as Jason); no other agent does:
|
||||
systemctl --user enable --now mosaic-webui start now and at login
|
||||
systemctl --user status mosaic-webui
|
||||
journalctl --user -u mosaic-webui -f the Console's log
|
||||
@@ -182,6 +194,13 @@ status_unit() {
|
||||
echo "healthz: not checked; no unit at $target"
|
||||
return 0
|
||||
fi
|
||||
# render puts --send right after the allowed user, which may itself be
|
||||
# the value --send; a unit that sends ends with both.
|
||||
if grep -q '^ExecStart=.* --allow-user [^ ][^ ]* --send$' "$target"; then
|
||||
echo "send: on (--send; human messages to roles)"
|
||||
else
|
||||
echo "send: off (read-only)"
|
||||
fi
|
||||
local port
|
||||
port="$(sed -n 's/^ExecStart=.* --port \([0-9][0-9]*\).*$/\1/p' "$target")"
|
||||
[ -n "$port" ] || { echo "healthz: not checked; no --port in $target"; return 0; }
|
||||
|
||||
Reference in New Issue
Block a user