The image creates SWW_STATE_DIR when it is missing (closes #337)
check / check (push) Waiting to run

Before waf starts, share/sww.run makes SWW_STATE_DIR if it is missing,
gives it to sww:sww and sets its mode to 0700. A setting that is not an
absolute path, or a SWW_STATE_DIR_FILE that cannot be read, still
changes nothing. script/example-app now checks that a waf container
whose SWW_STATE_DIR does not exist becomes healthy with the directory
made for sww, mode 0700.

Model: opus-5-5
This commit is contained in:
sneak committed 2026-11-11 10:01:50 +00:00
1 parent b93bad5842
commit 82adb13a0d
6 files changed
+40 -32

No files matched your search

+17 -18
View File
@@ -12,7 +12,7 @@ main() {
case "$command" in
rproxy) ;;
waf)
give_state_dir_to_sww
make_state_dir_for_sww
make_cache_dir_for_sww
;;
*)
@@ -24,28 +24,27 @@ main() {
exec chpst -u sww:sww /usr/local/bin/sww "$command"
}
# give_state_dir_to_sww gives the state directory and every file in
# it to the sww user, so that a volume mounted there needs no change
# of owner; chown -R changes a symbolic link itself, never what it points
# to. When SWW_STATE_DIR, in either form, cannot be read or is not the
# absolute path of a directory, no owner is changed, and waf starts and
# stops with a message naming the setting. A change of owner that fails, as
# on a volume mounted read-only, does not end the script either: waf
# reports a directory it cannot write.
give_state_dir_to_sww() {
# make_state_dir_for_sww makes the state directory, SWW_STATE_DIR in
# either form, when it is missing, gives it and every file in it to the
# sww user, and sets its mode to 0700. So a volume mounted there needs no
# change of owner; chown -R changes a symbolic link itself, never what it
# points to. When the setting cannot be read or is not an absolute path,
# nothing is changed, and waf starts and stops with a message naming the
# setting. A step that fails, as on a volume mounted read-only, does not
# end the script either: waf reports a directory it cannot write.
make_state_dir_for_sww() {
local dir
if dir="$(setting SWW_STATE_DIR /var/lib/sww)" &&
[[ "$dir" == /* && -d "$dir" ]]; then
chown -R sww:sww "$dir" || true
if dir="$(setting SWW_STATE_DIR /var/lib/sww)" && [[ "$dir" == /* ]]; then
{ mkdir -p -- "$dir" && chown -R sww:sww "$dir" &&
chmod 0700 "$dir"; } || true
fi
}
# make_cache_dir_for_sww makes the cache directory, SWW_CACHE_DIR in
# either form, and gives it and every file in it to the sww user, as
# give_state_dir_to_sww does the state directory. Unlike that one, it is
# made when it is missing, since the cache files need no volume. As there,
# a setting that cannot be read or is not an absolute path changes
# nothing, and a failure does not end the script.
# either form, when it is missing, and gives it and every file in it to
# the sww user. As for the state directory, a setting that cannot be read
# or is not an absolute path changes nothing, and a failure does not end
# the script.
make_cache_dir_for_sww() {
local dir
if dir="$(setting SWW_CACHE_DIR /var/cache/sww)" && [[ "$dir" == /* ]]; then