#!/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. # # zec2 — quick reachability check (TCP + HTTP + live build version) for deployed projects. # # Usage: # zec2 [ ...] # zec2 all # every project with a "domain" in zconfig.json # zec2 viteapp --host 203.0.113.10 set -uo pipefail source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/zhelpers.sh" z_track_start "$@" z_need_config z_require curl projects=(); host_override="" while [ $# -gt 0 ]; do case "$1" in --host) host_override="${2:-}"; shift 2 ;; -*) err "Unknown option: $1"; exit 1 ;; *) projects+=("$1"); shift ;; esac done HOST="${host_override:-$(zec2_ip)}" if [ "${#projects[@]}" -eq 0 ]; then printf '\n'; warn "Usage: zec2 [ ...] | all [--host ]" dim " Projects in zconfig.json: $(zproj_csv)" dim " 'all' checks every project with a 'domain' configured." exit 1 fi if printf '%s\n' "${projects[@]}" | grep -qx 'all'; then projects=(); while IFS= read -r _zl || [ -n "$_zl" ]; do projects+=("$_zl"); done < <(zproj_keys_with_domain) if [ "${#projects[@]}" -eq 0 ]; then warn "No projects with a 'domain' configured in zconfig.json." exit 1 fi fi check_reachability() { #