Provision US-16 dependencies credentials HTTPS and native service configurations

This commit is contained in:
Steffen committed 2026-10-06 09:11:28 +02:00
1 parent 950f67d8b7
commit eedf2a941b
34 files changed
+1703 -373

No files matched your search

+16 -35
View File
@@ -1,50 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail
fail() { printf 'Error: %s\n' "$*" >&2; exit 1; }
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
fail() { printf 'Verification failed: %s\n' "$*" >&2; exit 1; }
source "$script_dir/services.sh"
requested=
probe_dir=
cycle=false
deployment=/var/lib/healthapp-installation/deployment
dotnet_path=/usr/bin/dotnet
while [[ $# -gt 0 ]]; do
case "$1" in
--services) [[ $# -gt 1 ]] || fail 'Missing services.'; requested=$2; shift 2;;
--probe-dir) [[ $# -gt 1 ]] || fail 'Missing probe directory.'; probe_dir=$2; shift 2;;
--cycle) cycle=true; shift;;
--help) printf '%s\n' 'Usage: bash verify.sh --services all|NAME[,NAME] --probe-dir DIRECTORY [--cycle]' 'Each NAME.curl contains curl configuration for a configured HTTPS endpoint and the required credentials.' 'Probes must return HTTP 200 (no redirects). --cycle explicitly permits stop/start/restart of each selected service.'; exit 0;;
--services|--deployment|--dotnet)
[[ $# -gt 1 ]] || fail 'Missing argument.'
case "$1" in --services) requested=$2;; --deployment) deployment=$2;; --dotnet) dotnet_path=$2;; esac
shift 2;;
--help) printf '%s\n' 'Usage: bash verify.sh --services all|NAME[,NAME] [--deployment GENERATED_DIRECTORY] [--dotnet PATH]' 'Checks systemd processes, HTTPS, dedicated databases, service credentials and the complete-system synthetic workflow.'; exit 0;;
*) fail "Unknown argument: $1";;
esac
done
select_services "$requested"
[[ -d "$probe_dir" ]] || fail 'Provide service-specific curl probe configuration.'
command -v curl >/dev/null || fail 'curl is required for network verification.'
[[ -d /run/systemd/system ]] || fail 'Verification requires a running systemd system manager.'
for service in "${selected_services[@]}"; do
[[ -f "$probe_dir/$service.curl" ]] || fail "Missing probe configuration: $service"
done
pids=()
for service in "${selected_services[@]}"; do
unit="healthapp-$service.service"
systemctl is-active --quiet "$unit" || fail "$service is not active."
pid=$(systemctl show --property MainPID --value "$unit")
[[ "$pid" =~ ^[1-9][0-9]*$ && -d "/proc/$pid" ]] || fail "$service has no running process."
for other in "${pids[@]}"; do [[ "$pid" != "$other" ]] || fail 'Services share a process.'; done
systemctl is-active --quiet "healthapp-$service.service" || fail "$service is not running."
pid=$(systemctl show --property MainPID --value "healthapp-$service.service")
[[ "$pid" =~ ^[1-9][0-9]*$ && -d "/proc/$pid" ]] || fail "$service has no process."
for peer in "${pids[@]}"; do [[ "$pid" != "$peer" ]] || fail 'Services share a process.'; done
pids+=("$pid")
if [[ "$cycle" == true ]]; then
# Confirm stopping this service does not directly stop another selected unit.
systemctl stop "$unit"
systemctl is-active --quiet "$unit" && fail "$service did not stop."
for peer in "${selected_services[@]}"; do
[[ "$peer" == "$service" ]] || systemctl is-active --quiet "healthapp-$peer.service" || fail "Stopping $service stopped $peer."
done
systemctl start "$unit"
systemctl restart "$unit"
systemctl is-active --quiet "$unit" || fail "$service did not restart."
fi
# curl settings are data, not sourced shell code; suppress bodies and credentials.
status=$(curl --config "$probe_dir/$service.curl" --silent --output /dev/null --write-out '%{http_code}' --max-time 15 --max-redirs 0 --retry 5 --retry-delay 1 --retry-connrefused) || fail "Network probe failed for $service."
[[ "$status" == 200 ]] || fail "Unexpected HTTP status for $service: $status"
systemctl is-active --quiet "$unit" || fail "$service exited during its network probe."
printf 'Verified process and configured network probe: %s\n' "$service"
done
printf '%s\n' 'Verification passed. For a complete system also run the representative API workflow documented in INSTALLATION.md.'
args=(verify --deployment "$deployment" --services "$(IFS=,; echo "${selected_services[*]}")")
[[ "$requested" != all ]] || args+=(--complete true)
"$dotnet_path" "$script_dir/provisioner/HealthApp.Provisioning.dll" "${args[@]}"
printf '%s\n' 'Installation verification passed.'