57 lines
2.5 KiB
Bash
Executable File
57 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Disposable CI deployment. No host ports and no access to NPM/Pi-hole.
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${1:?Pass a locally built image}"
|
|
export HOMEGATE_IMAGE=$1
|
|
export HOMEGATE_LAN_IP=192.168.42.10
|
|
export HOMEGATE_PROXY_IP=192.168.42.11
|
|
export HOMEGATE_ALLOWED_NETWORKS='[192.168.42.0/24]'
|
|
export HOMEGATE_ZONES='[home]'
|
|
export HOMEGATE_DNS_MODE=manual
|
|
export UI_ORIGIN=http://192.168.42.10:8098
|
|
export NPM_URL=http://192.168.42.11:81
|
|
export NPM_IDENTITY=smoke@example.invalid
|
|
export PIHOLE_URL=
|
|
export API_CA_BUNDLE=
|
|
export UI_PASSWORD=disposable-smoke-password
|
|
export NPM_PASSWORD=disposable-smoke-npm
|
|
export PIHOLE_PASSWORD=not-used
|
|
smoke_dir=$(mktemp -d)
|
|
project="homegate-smoke-$(python3 -c 'import secrets; print(secrets.token_hex(6))')"
|
|
cat > "$smoke_dir/override.yaml" <<'YAML'
|
|
services:
|
|
ui:
|
|
ports: !reset []
|
|
network_mode: none
|
|
ssh-export:
|
|
ports: !reset []
|
|
network_mode: none
|
|
homegate:
|
|
network_mode: none
|
|
YAML
|
|
compose() {
|
|
docker compose --env-file /dev/null -p "$project" -f compose.registry.yaml -f "$smoke_dir/override.yaml" "$@"
|
|
}
|
|
cleanup() {
|
|
compose down --volumes --remove-orphans >/dev/null 2>&1 || true
|
|
rm -rf -- "$smoke_dir"
|
|
}
|
|
trap cleanup EXIT
|
|
trap 'exit 1' HUP INT TERM
|
|
compose up -d --wait --wait-timeout 60 --pull never ui ssh-export
|
|
compose run --rm --no-deps homegate validate
|
|
compose exec -T ui python - write < ci/smoke_ui.py
|
|
compose exec -T ssh-export python -c "from pathlib import Path; import os,urllib.request; assert os.getuid()==1000; assert not Path('/run/secrets/ui_password').exists(); assert not Path('/data').exists(); urllib.request.urlopen('http://127.0.0.1:8080/healthz',timeout=3).read()"
|
|
ca_check="from pathlib import Path; import hashlib,os,homegate as h; assert os.getuid()==1000; c=h.load_config('/config/services.yaml'); h.Authority(Path('/data'),c['domain_zones']); print(hashlib.sha256(Path('/data/root-ca.crt').read_bytes()).hexdigest())"
|
|
ca_before=$(compose run --rm --no-deps --entrypoint python homegate -c "$ca_check")
|
|
# Changing a first-run seed must not replace live settings or the established CA.
|
|
export HOMEGATE_PROXY_IP=192.168.42.99
|
|
export HOMEGATE_ZONES='[changed.internal]'
|
|
compose run --rm --no-deps initialize
|
|
compose restart ui ssh-export
|
|
compose exec -T ui python - verify < ci/smoke_ui.py
|
|
ca_after=$(compose run --rm --no-deps --entrypoint python homegate -c "$ca_check")
|
|
[ "$ca_before" = "$ca_after" ]
|
|
printf 'Runtime smoke test passed: bootstrap, permissions, secrets, config and CA persistence.\n'
|