Add container/VM autodiscovery, optional username in config, and management scripts
This commit is contained in:
19
infmap/check-config.sh
Executable file
19
infmap/check-config.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR" || exit 1
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME" "WEB_PORT" "SSH_KEY_PATH"
|
||||
|
||||
# Check SSH key exists
|
||||
[ -f "${SSH_KEY_PATH}" ] || _die "SSH key not found at ${SSH_KEY_PATH}"
|
||||
|
||||
# Check infrastructure.conf exists and is non-empty
|
||||
[ -f "${CONFIG_PATH}/infrastructure.conf" ] || _die "infrastructure.conf not found at ${CONFIG_PATH}/infrastructure.conf"
|
||||
[ -s "${CONFIG_PATH}/infrastructure.conf" ] || _die "infrastructure.conf is empty"
|
||||
|
||||
# Validate infrastructure.conf has at least one server entry
|
||||
server_count=$(grep -cE '^\s+\S' "${CONFIG_PATH}/infrastructure.conf" 2>/dev/null || echo 0)
|
||||
[ "$server_count" -gt 0 ] || _die "infrastructure.conf has no server entries"
|
||||
|
||||
echo "Config OK: ${server_count} server(s) configured, SSH key present, port ${WEB_PORT}"
|
||||
11
infmap/reload-config.sh
Executable file
11
infmap/reload-config.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR" || exit 1
|
||||
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# Restart to pick up any config changes (infrastructure.conf, service.env)
|
||||
docker compose -p "${CONTAINER_NAME}" restart || _die "Failed to restart ${CONTAINER_NAME}"
|
||||
|
||||
echo "${CONTAINER_NAME} reloaded"
|
||||
Reference in New Issue
Block a user