2026-08-22 14:56:38 +02:00
|
|
|
#!/usr/bin/env bash
|
2026-08-22 17:36:38 +02:00
|
|
|
# install.sh — integrate Collabora nodes into existing nextcloud-node-red (:1880)
|
2026-08-22 15:23:33 +02:00
|
|
|
#
|
2026-08-22 17:36:38 +02:00
|
|
|
# Default: INSTALL_MODE=integrate (no new container, no port 1881)
|
|
|
|
|
# Sidecar (only if you explicitly want it): INSTALL_MODE=sidecar
|
2026-08-22 15:23:33 +02:00
|
|
|
#
|
2026-08-22 17:36:38 +02:00
|
|
|
# Environment (optional — .env in repo root is loaded automatically):
|
|
|
|
|
# NODERED_DIR Path to existing nextcloud-node-red (auto-detected if empty)
|
|
|
|
|
# NODERED_CONTAINER Docker name, default nextcloud-node-red
|
2026-08-22 17:10:34 +02:00
|
|
|
# NODERED_PORT default 1880
|
2026-08-22 17:36:38 +02:00
|
|
|
# CODE_CONTAINER Collabora CODE container name, default code
|
|
|
|
|
# COLLABORA_IP CODE bridge IP (auto-detected if empty)
|
|
|
|
|
# NEXTCLOUD_URL e.g. https://cloud.example.com (shown in install summary)
|
|
|
|
|
# INSTALL_USER file owner for chown, default ncadmin
|
2026-08-22 17:10:34 +02:00
|
|
|
# FORCE_REBUILD=1 docker compose build --no-cache
|
|
|
|
|
#
|
2026-08-22 14:56:38 +02:00
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
|
|
VERSION="1.0.0"
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
INSTALL_DIR="${INSTALL_DIR:-$SCRIPT_DIR}"
|
2026-08-22 15:23:33 +02:00
|
|
|
INSTALL_MODE="${INSTALL_MODE:-integrate}"
|
2026-08-22 17:10:34 +02:00
|
|
|
|
2026-08-22 17:36:38 +02:00
|
|
|
# Load .env if present (no secrets required here)
|
2026-08-22 17:10:34 +02:00
|
|
|
if [ -f "${INSTALL_DIR}/.env" ]; then
|
|
|
|
|
set -a
|
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
|
. "${INSTALL_DIR}/.env"
|
|
|
|
|
set +a
|
|
|
|
|
fi
|
|
|
|
|
|
2026-08-22 15:23:33 +02:00
|
|
|
NODERED_DIR="${NODERED_DIR:-/home/ncadmin/nextcloud-node-red}"
|
2026-08-22 17:10:34 +02:00
|
|
|
[ -n "${NODERED_DIR}" ] || NODERED_DIR="/home/ncadmin/nextcloud-node-red"
|
|
|
|
|
NODERED_CONTAINER="${NODERED_CONTAINER:-nextcloud-node-red}"
|
|
|
|
|
NODERED_PORT="${NODERED_PORT:-1880}"
|
2026-08-22 14:59:25 +02:00
|
|
|
CODE_CONTAINER="${CODE_CONTAINER:-code}"
|
2026-08-22 17:10:34 +02:00
|
|
|
COLLABORA_IP="${COLLABORA_IP:-}"
|
|
|
|
|
NEXTCLOUD_URL="${NEXTCLOUD_URL:-https://cloud.hannesahlin.se}"
|
|
|
|
|
[ -n "${NEXTCLOUD_URL}" ] || NEXTCLOUD_URL="https://cloud.hannesahlin.se"
|
2026-08-22 14:56:38 +02:00
|
|
|
|
|
|
|
|
log() { printf '[install] %s\n' "$*"; }
|
2026-08-22 17:36:38 +02:00
|
|
|
die() { printf '[install] ERROR: %s\n' "$*" >&2; exit 1; }
|
2026-08-22 14:56:38 +02:00
|
|
|
|
2026-08-22 17:36:38 +02:00
|
|
|
log "nextcloud-collabora-nodered v${VERSION} (mode: ${INSTALL_MODE})"
|
2026-08-22 14:56:38 +02:00
|
|
|
|
2026-08-22 15:23:33 +02:00
|
|
|
if [ "${INSTALL_MODE}" = "sidecar" ]; then
|
2026-08-22 17:36:38 +02:00
|
|
|
log "Sidecar mode — note: default is integrate (existing :1880)"
|
|
|
|
|
require_cmd() { command -v "$1" >/dev/null 2>&1 || die "Missing: $1"; }
|
2026-08-22 15:23:33 +02:00
|
|
|
require_cmd docker
|
2026-08-22 14:56:38 +02:00
|
|
|
COMPOSE="docker compose"
|
2026-08-22 15:23:33 +02:00
|
|
|
docker compose version >/dev/null 2>&1 || COMPOSE="docker-compose"
|
|
|
|
|
cd "${INSTALL_DIR}"
|
2026-08-22 17:36:38 +02:00
|
|
|
[ -f docker-compose.yml ] || die "docker-compose.yml not found"
|
2026-08-22 15:23:33 +02:00
|
|
|
[ -f .env ] || cp .env.example .env
|
|
|
|
|
if ! docker ps --format '{{.Names}}' | grep -qx "${CODE_CONTAINER}"; then
|
2026-08-22 17:36:38 +02:00
|
|
|
die "CODE container '${CODE_CONTAINER}' is not running"
|
2026-08-22 14:59:25 +02:00
|
|
|
fi
|
|
|
|
|
${COMPOSE} build
|
2026-08-22 15:23:33 +02:00
|
|
|
${COMPOSE} up -d
|
2026-08-22 17:36:38 +02:00
|
|
|
log "Sidecar started on :1881 (not recommended if :1880 already runs)"
|
2026-08-22 15:23:33 +02:00
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# === integrate (default) ===
|
|
|
|
|
chmod +x "${SCRIPT_DIR}/scripts/integrate-into-nodered.sh"
|
|
|
|
|
PKG_SRC="${INSTALL_DIR}" \
|
|
|
|
|
NODERED_DIR="${NODERED_DIR}" \
|
2026-08-22 17:10:34 +02:00
|
|
|
NODERED_CONTAINER="${NODERED_CONTAINER}" \
|
|
|
|
|
NODERED_PORT="${NODERED_PORT}" \
|
2026-08-22 15:23:33 +02:00
|
|
|
CODE_CONTAINER="${CODE_CONTAINER}" \
|
|
|
|
|
COLLABORA_IP="${COLLABORA_IP}" \
|
2026-08-22 17:10:34 +02:00
|
|
|
NEXTCLOUD_URL="${NEXTCLOUD_URL}" \
|
|
|
|
|
INSTALL_USER="${INSTALL_USER:-}" \
|
2026-08-22 15:23:33 +02:00
|
|
|
bash "${SCRIPT_DIR}/scripts/integrate-into-nodered.sh"
|
2026-08-22 14:56:38 +02:00
|
|
|
|
2026-08-22 17:36:38 +02:00
|
|
|
log "Done."
|