zscripts-token-savers/bash/zstop
KellyMichels 8e6ffea1a4 feat(bash): native bash port of all z-scripts for Linux/macOS/WSL
Full port: zhelpers.sh library (jq config, ssh, http/tcp, archive builder,
build-version, motd, port-kill), all commands (zstart/zkill/zrestart/zstop,
zdeploy with 5 kind handlers, zec2/zec2online/zrepair, zbackup/zbackup_ec2/
zsync/zbackup_and_sync, zstart_docker, zsetup_mail, setup_backup_schedule via
cron), Unix-path zconfig.example.json, and a bash/README.md.

Verified: bash -n clean on all scripts; archive exclusions, config semantics,
and zec2 tested against the real config and live server from Git Bash. Needs a
Linux/macOS/WSL shakedown for lsof/rsync/nohup paths before merging.
2026-07-16 14:07:02 -05:00

38 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# Evomedia.net Token Savers — https://github.com/kellymichels/zscripts-token-savers
# Created by Kelly Michels · dev@evomedia.net
# Licensed under the MIT License. See LICENSE.
#
# zstop — stop docker compose stacks on the server without removing data or files.
#
# Usage:
# zstop <project> [<project> ...]
#
# Data volumes are preserved. Run zdeploy <project> to bring a stack back up.
set -uo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/zhelpers.sh"
z_need_config
z_require ssh
if [ $# -eq 0 ]; then
printf '\n'; warn "Usage: zstop <project> [<project> ...]"
dim " Projects in zconfig.json: $(zproj_csv)"
exit 1
fi
for key in "$@"; do
zproj_require "$key"
label="$(zproj "$key" .label)"; [ -n "$label" ] || label="$key"
compose_dir="$(zremote_compose_dir "$key")"
printf '\n'; info "--- Stopping $label ---"
if zssh "cd $compose_dir && sudo docker compose down 2>&1 || true"; then
ok " $label stopped."
else
warn " WARNING: docker compose down returned non-zero for $label"
fi
done
printf '\n'; dim "Done. Data volumes are intact. Run zdeploy <project> to restart."