feat: Update 7 files
All checks were successful
Build-Test-Publish / build (linux/amd64) (push) Successful in 35s
Build-Test-Publish / build (linux/arm64) (push) Successful in 3m15s

This commit is contained in:
j
2026-01-02 22:27:40 +13:00
parent 767692160d
commit ae5a6fabe9
7 changed files with 95 additions and 2 deletions

View File

@@ -3,10 +3,12 @@ set -uo pipefail
# all_status.sh - Get status and ports for all services on this server
#
# Usage: all_status.sh
# Usage: all_status.sh [EXPECTED_AGENT_HASH]
#
# Output: JSON object with status and ports for each service
# {
# "agent_hash": "hash-of-remote-agent",
# "agent_match": true|false,
# "services": [
# {
# "name": "service-name",
@@ -24,6 +26,17 @@ DROPSHELL_DIR="$(dirname "${AGENT_PATH}")"
SERVICES_DIR="${DROPSHELL_DIR}/services"
# -- Get agent hash --
EXPECTED_HASH="${1:-}"
LOCAL_HASH=""
AGENT_MATCH="true"
if [[ -f "${AGENT_PATH}/agent.hash" ]]; then
LOCAL_HASH=$(cat "${AGENT_PATH}/agent.hash" | tr -d '[:space:]')
fi
if [[ -n "${EXPECTED_HASH}" && "${LOCAL_HASH}" != "${EXPECTED_HASH}" ]]; then
AGENT_MATCH="false"
fi
# -- Helper to escape JSON strings --
json_escape() {
local str="$1"
@@ -37,7 +50,11 @@ json_escape() {
}
# -- Start JSON output --
echo -n '{"services":['
echo -n '{"agent_hash":"'
json_escape "$LOCAL_HASH"
echo -n '","agent_match":'
echo -n "$AGENT_MATCH"
echo -n ',"services":['
first=true

View File

@@ -38,6 +38,24 @@ if [[ ! -f "${AGENT_PATH}/common.sh" ]]; then
fi
source "${AGENT_PATH}/common.sh"
# -- Check agent hash (if AGENT_HASH is provided by dropshell) --
# Exit code 199 = agent mismatch (special code for dropshell to detect)
if [[ -n "${AGENT_HASH:-}" ]]; then
LOCAL_HASH_FILE="${AGENT_PATH}/agent.hash"
if [[ -f "${LOCAL_HASH_FILE}" ]]; then
LOCAL_HASH=$(cat "${LOCAL_HASH_FILE}" | tr -d '[:space:]')
EXPECTED_HASH=$(echo "${AGENT_HASH}" | tr -d '[:space:]')
if [[ "${LOCAL_HASH}" != "${EXPECTED_HASH}" ]]; then
echo "AGENT_MISMATCH:${EXPECTED_HASH}:${LOCAL_HASH}" >&2
exit 199
fi
else
# No local hash file - agent is outdated (pre-hash version)
echo "AGENT_MISMATCH:${AGENT_HASH}:no_hash_file" >&2
exit 199
fi
fi
# -- Validate arguments --
if [[ $# -lt 2 ]]; then
echo "Usage: ds_run.sh SERVICE COMMAND [args...]" >&2