From 6acb361b5cf0355e70638840b3e9f69091e87cc8 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Mon, 22 Sep 2025 19:18:47 +0200 Subject: handle XDG_RUNTIME_DIR being unset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- bin/sv | 24 +++++++++++------------- bin/svtree-run | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/bin/sv b/bin/sv index 2f2bcf2..868125f 100755 --- a/bin/sv +++ b/bin/sv @@ -3,10 +3,9 @@ set -eu [ -n "${DEBUG:-}" ] && set -x SYS_RT=/run -USER_RT=$XDG_RUNTIME_DIR +USER_RT=${XDG_RUNTIME_DIR:-/nouser} # fallback when not set -main() -{ +main() { # NOTE: this assumes that: # system services have their live dir at /run/s6-rc # user services have their live dir at $XDG_RUNTIME_DIR/s6-rc @@ -30,7 +29,7 @@ main() ## ## db ## - reload|recompile) + reload | recompile) export LIVEDIR="$l" export STATEDIR="$confdir" export SRCDIR="$confdir/src" @@ -40,25 +39,24 @@ main() ## ## service ## - up|start) + up | start) exec s6-rc -v2 -l "$l" -b start $@ ;; - dn|down|stop) + dn | down | stop) exec s6-rc -v2 -l "$l" -b stop $@ ;; - re|restart) + re | restart) $0 dn $@ && $0 up $@ ;; - st|status|info) + st | status | info) local sv=${1:?} s6-rc-db -l "$l" type $sv >/dev/null 2>&1 || exit 1 printf 'Service (%s):\n' $(s6-rc-db -l "$l" type $sv) - for ln in $(s6-rc-db -l "$l" atomics $sv) - do + for ln in $(s6-rc-db -l "$l" atomics $sv); do printf '%s: ' $ln s6-svstat "$l/servicedirs/$ln" done | sort -k 2 | column -s ':' -t @@ -73,8 +71,8 @@ main() tail -n 10 "$logfile" fi ;; - - logtail|logs) + + logtail | logs) local sv=${1:?} # NOTE: this assumes logs are stored in $rt/log logfile="$rt/log/$sv/current" @@ -106,7 +104,7 @@ main() ## ## listall ## - ls|list|ps|*) + ls | list | ps | *) [ "${1:-}" = "-a" ] && exec s6-rc-db -l "$l" list services exec s6-rc -v2 -l "$l" -a list ;; diff --git a/bin/svtree-run b/bin/svtree-run index eab97f5..9424f39 100755 --- a/bin/svtree-run +++ b/bin/svtree-run @@ -1,7 +1,7 @@ #!/bin/execlineb -P -importas -iS -D "/etc" XDG_CONFIG_HOME -importas -iS -D "/run" XDG_RUNTIME_DIR +importas -D "/etc" -S XDG_CONFIG_HOME +importas -D "/run" -S XDG_RUNTIME_DIR envfile -I /opt/svtree/dirs.conf -- cgit 1.4.1