install.sh: Neo4j is optional, off by default
Neo4j was auto-provisioned for everyone; a graph DB isn't core, so don't foist it on new users. Gate it behind maybe_setup_neo4j: enable with --with-neo4j, an interactive yes, or a previous run's choice (recorded in infra.conf, so a decline isn't re-prompted). MQTT and Postgres stay default-on. Existing installs with NEO4J=container keep running it unchanged.
This commit is contained in:
34
install.sh
34
install.sh
@@ -3,12 +3,14 @@
|
|||||||
#
|
#
|
||||||
# Idempotent script that sets up the infrastructure "control layer":
|
# Idempotent script that sets up the infrastructure "control layer":
|
||||||
# - Docker, Caddy (system binary)
|
# - Docker, Caddy (system binary)
|
||||||
# - MQTT broker, Postgres, Neo4j (Docker containers or existing)
|
# - MQTT broker, Postgres (Docker containers or existing)
|
||||||
|
# - Neo4j — optional, off by default (opt in with --with-neo4j or the prompt)
|
||||||
# - Directory structure, systemd lingering, seed configs
|
# - Directory structure, systemd lingering, seed configs
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
# ./install.sh # Interactive — prompts for existing services
|
# ./install.sh # Interactive — prompts for existing services + Neo4j
|
||||||
# ./install.sh --yes # Non-interactive — use containers for everything
|
# ./install.sh --yes # Non-interactive — containers for MQTT/Postgres, no Neo4j
|
||||||
|
# ./install.sh --with-neo4j # Also set up the optional Neo4j graph database
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
@@ -411,6 +413,28 @@ setup_neo4j() {
|
|||||||
"$NEO4J_IMAGE"
|
"$NEO4J_IMAGE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Neo4j is optional — off by default (a graph DB isn't core; don't foist it on new
|
||||||
|
# users). Enable with `--with-neo4j`, an interactive yes, or a previous run's choice
|
||||||
|
# (remembered in infra.conf so re-runs don't re-prompt).
|
||||||
|
maybe_setup_neo4j() {
|
||||||
|
local prev; prev=$(conf_get NEO4J)
|
||||||
|
if [ "${WITH_NEO4J:-0}" = "1" ] || [ "$prev" = "container" ] || [ "$prev" = "existing" ]; then
|
||||||
|
setup_neo4j
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
log_step "Neo4j (optional)"
|
||||||
|
if [ "$prev" = "disabled" ]; then
|
||||||
|
log_skip "off — enable later with ./install.sh --with-neo4j"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if ask_yes_no "Set up Neo4j? (optional graph database — you can add it later)" "n"; then
|
||||||
|
setup_neo4j
|
||||||
|
else
|
||||||
|
conf_set NEO4J "disabled"
|
||||||
|
log_skip "off by default — enable later with ./install.sh --with-neo4j"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Summary
|
# Summary
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
@@ -460,11 +484,13 @@ main() {
|
|||||||
# Parse args
|
# Parse args
|
||||||
AUTO_YES=0
|
AUTO_YES=0
|
||||||
WITH_DNS_PLUGIN="" # e.g. "cloudflare" → also build a DNS-plugin Caddy for acme TLS
|
WITH_DNS_PLUGIN="" # e.g. "cloudflare" → also build a DNS-plugin Caddy for acme TLS
|
||||||
|
WITH_NEO4J=0 # Neo4j is optional and off by default; --with-neo4j opts in
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--yes|-y) AUTO_YES=1 ;;
|
--yes|-y) AUTO_YES=1 ;;
|
||||||
--with-dns-plugin) WITH_DNS_PLUGIN="cloudflare" ;;
|
--with-dns-plugin) WITH_DNS_PLUGIN="cloudflare" ;;
|
||||||
--with-dns-plugin=*) WITH_DNS_PLUGIN="${arg#*=}" ;;
|
--with-dns-plugin=*) WITH_DNS_PLUGIN="${arg#*=}" ;;
|
||||||
|
--with-neo4j) WITH_NEO4J=1 ;;
|
||||||
*) printf "Unknown argument: %s\n" "$arg"; exit 1 ;;
|
*) printf "Unknown argument: %s\n" "$arg"; exit 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -480,7 +506,7 @@ main() {
|
|||||||
migrate_old_containers
|
migrate_old_containers
|
||||||
setup_mqtt
|
setup_mqtt
|
||||||
setup_postgres
|
setup_postgres
|
||||||
setup_neo4j
|
maybe_setup_neo4j
|
||||||
print_summary
|
print_summary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user