diff --git a/scripts/ensure-container-stopped.sh b/scripts/ensure-container-stopped.sh index a6f02eec..1cb82a52 100755 --- a/scripts/ensure-container-stopped.sh +++ b/scripts/ensure-container-stopped.sh @@ -44,11 +44,14 @@ done if $ALL_DOMAINS; then uid=$(id -u) for domain in "gui/$uid" "user/$uid" "system"; do + if [ "$domain" = "system" ] && [ "$uid" -ne 0 ]; then + continue + fi launchctl print "$domain" 2>/dev/null \ | grep -oE 'com\.apple\.container\.[^ ]+' \ | sort -u \ | while read -r service; do - launchctl bootout "$domain/$service" + launchctl bootout "$domain/$service" 2>/dev/null || true done done else @@ -67,5 +70,6 @@ else exit 1 fi - launchctl list | grep -e 'com\.apple\.container\W' | awk '{print $3}' | xargs -I % launchctl bootout $domain_string/% + launchctl list | grep -e 'com\.apple\.container\W' | awk '{print $3}' \ + | xargs -I % sh -c 'launchctl bootout '"$domain_string"'/% 2>/dev/null || true' fi