#!/usr/bin/env bash set -euo pipefail cd "$(dirname "$0")" case "${1:-}" in '') docker compose build ;; --skip-build) ;; *) printf 'Usage: ./setup [--skip-build]\n' >&2; exit 1 ;; esac # Import once into the existing state volume. Never source/evaluate legacy .env. # The import container does not join AD, reconcile permissions, or touch files. previous_container="$(docker compose ps --all -q samba)" if [[ -n "$previous_container" ]]; then # Resolved values preserve Compose interpolation and literal password bytes. docker inspect "$previous_container" --format '{{json .Config.Env}}' | docker compose run --rm --no-deps -T samba python3 /app/configuration.py import-runtime elif [[ -f .env ]]; then docker compose run --rm --no-deps -T samba python3 /app/configuration.py import-legacy < .env fi docker compose up -d printf '\nOpen http:/// to configure HTTPS, then continue over HTTPS.\n' printf 'First-launch setup codes: docker compose logs samba\n'