From 8864309c7de009c1a0edc6fc4fe6452b53548bda Mon Sep 17 00:00:00 2001 From: Michel Abboud Date: Thu, 29 Jan 2026 00:54:47 +0000 Subject: [PATCH] feat: Add 'stop all' to stop all running containers - ./winctl.sh stop all finds and stops all running containers - Updated help, WINCTL_GUIDE.md, and readme.md Co-Authored-By: Claude Opus 4.5 --- WINCTL_GUIDE.md | 3 +++ readme.md | 1 + winctl.sh | 20 +++++++++++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/WINCTL_GUIDE.md b/WINCTL_GUIDE.md index 48d4d99..94e89fe 100644 --- a/WINCTL_GUIDE.md +++ b/WINCTL_GUIDE.md @@ -173,6 +173,9 @@ Stop containers with a 2-minute grace period for clean shutdown. # Stop multiple versions ./winctl.sh stop win11 win10 +# Stop all running containers +./winctl.sh stop all + # Interactive menu ./winctl.sh stop ``` diff --git a/readme.md b/readme.md index 8ea61b8..71aa872 100644 --- a/readme.md +++ b/readme.md @@ -91,6 +91,7 @@ Use `winctl.sh` for easy container management: # Stop containers (with confirmation) ./winctl.sh stop win11 +./winctl.sh stop all # Stop all running # View logs ./winctl.sh logs win11 -f diff --git a/winctl.sh b/winctl.sh index 01ae912..c8673f8 100755 --- a/winctl.sh +++ b/winctl.sh @@ -743,6 +743,23 @@ cmd_start() { cmd_stop() { local versions=("$@") + # Stop all running containers + if [[ ${#versions[@]} -eq 1 && "${versions[0]}" == "all" ]]; then + versions=() + refresh_status_cache + for v in "${ALL_VERSIONS[@]}"; do + local status + status=$(get_status "$v") + if [[ "$status" == "running" ]]; then + versions+=("$v") + fi + done + if [[ ${#versions[@]} -eq 0 ]]; then + info "No running containers found" + return 0 + fi + fi + # Interactive selection if no versions specified if [[ ${#versions[@]} -eq 0 ]]; then local selected @@ -1185,7 +1202,7 @@ show_usage() { printf '\n' printf '%b\n' "${BOLD}COMMANDS${RESET}" printf ' %b [version...] Start container(s), interactive if no version\n' "${BOLD}start${RESET}" - printf ' %b [version...] Stop container(s) with 2-min grace period\n' "${BOLD}stop${RESET}" + printf ' %b [version...|all] Stop container(s) or all running\n' "${BOLD}stop${RESET}" printf ' %b [version...] Restart container(s)\n' "${BOLD}restart${RESET}" printf ' %b [version...] Show status of container(s)\n' "${BOLD}status${RESET}" printf ' %b [-f] View container logs (-f to follow)\n' "${BOLD}logs${RESET}" @@ -1211,6 +1228,7 @@ show_usage() { printf ' %s start win11 # Start Windows 11\n' "${SCRIPT_NAME}" printf ' %s start win11 win10 # Start multiple\n' "${SCRIPT_NAME}" printf ' %s stop win11 # Stop with confirmation\n' "${SCRIPT_NAME}" + printf ' %s stop all # Stop all running\n' "${SCRIPT_NAME}" printf ' %s status # Show all containers\n' "${SCRIPT_NAME}" printf ' %s logs win11 -f # Follow logs\n' "${SCRIPT_NAME}" printf ' %s list desktop # List desktop versions\n' "${SCRIPT_NAME}"