Files
nextcloud-collabora-nodered/install.sh
T
dev 5ca7b4d4e0 Defaults matchar servern: intern CODE över HTTPS (ssl.enable=true)
- collaboraUrl -> https://code:9980 överallt (config-node, example-flows,
  .env.example, docker-compose.yml, install.sh, resolve_collabora_url);
  http://code:9980 failar när CODE kör SSL
- verifyTls=false är nu ett krav (self-signed internt) i hjälptext/dok
- integrate: connect_nodered_bridge efter container-up (docker network
  connect bridge, ignorerar already connected) + verifiering via
  docker exec curl -sk https://code:9980/hosting/capabilities (HTTP 200)
- Publik URL förblir https://docs.domain.name i docs
2026-08-22 21:55:28 +02:00

86 lines
3.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# install.sh — integrate Collabora nodes into existing nextcloud-node-red (:1880)
#
# Default: INSTALL_MODE=integrate (no new container, no port 1881)
# Sidecar (only if you explicitly want it): INSTALL_MODE=sidecar
#
# 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
# NODERED_PORT default 1880
# 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 ncdeploy
# FORCE_REBUILD=1 docker compose build --no-cache
#
set -euo pipefail
VERSION="1.0.0"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
INSTALL_DIR="${INSTALL_DIR:-$SCRIPT_DIR}"
INSTALL_MODE="${INSTALL_MODE:-integrate}"
# Load .env if present (no secrets required here)
if [ -f "${INSTALL_DIR}/.env" ]; then
set -a
# shellcheck disable=SC1091
. "${INSTALL_DIR}/.env"
set +a
fi
NODERED_DIR="${NODERED_DIR:-/home/ncdeploy/nextcloud-node-red}"
[ -n "${NODERED_DIR}" ] || NODERED_DIR="/home/ncdeploy/nextcloud-node-red"
NODERED_CONTAINER="${NODERED_CONTAINER:-nextcloud-node-red}"
NODERED_PORT="${NODERED_PORT:-1880}"
CODE_CONTAINER="${CODE_CONTAINER:-code}"
COLLABORA_IP="${COLLABORA_IP:-}"
# Intern CODE kör HTTPS (ssl.enable=true, self-signed). http://code:9980 failar.
# Aldrig 127.0.0.1/host.docker.internal — CODE kör inte på Node-RED-värden.
case "${COLLABORA_URL:-https://code:9980}" in
http://127.0.0.1:*|http://localhost:*|http://host.docker.internal:*|\
https://127.0.0.1:*|https://localhost:*|https://host.docker.internal:*|"")
COLLABORA_URL="https://code:9980" ;;
*) COLLABORA_URL="${COLLABORA_URL}" ;;
esac
NEXTCLOUD_URL="${NEXTCLOUD_URL:-https://cloud.domain.name}"
[ -n "${NEXTCLOUD_URL}" ] || NEXTCLOUD_URL="https://cloud.domain.name"
log() { printf '[install] %s\n' "$*"; }
die() { printf '[install] ERROR: %s\n' "$*" >&2; exit 1; }
log "nextcloud-collabora-nodered v${VERSION} (mode: ${INSTALL_MODE})"
if [ "${INSTALL_MODE}" = "sidecar" ]; then
log "Sidecar mode — note: default is integrate (existing :1880)"
require_cmd() { command -v "$1" >/dev/null 2>&1 || die "Missing: $1"; }
require_cmd docker
COMPOSE="docker compose"
docker compose version >/dev/null 2>&1 || COMPOSE="docker-compose"
cd "${INSTALL_DIR}"
[ -f docker-compose.yml ] || die "docker-compose.yml not found"
[ -f .env ] || cp .env.example .env
if ! docker ps --format '{{.Names}}' | grep -qx "${CODE_CONTAINER}"; then
die "CODE container '${CODE_CONTAINER}' is not running"
fi
${COMPOSE} build
${COMPOSE} up -d
log "Sidecar started on :1881 (not recommended if :1880 already runs)"
exit 0
fi
# === integrate (default) ===
chmod +x "${SCRIPT_DIR}/scripts/integrate-into-nodered.sh"
PKG_SRC="${INSTALL_DIR}" \
NODERED_DIR="${NODERED_DIR}" \
NODERED_CONTAINER="${NODERED_CONTAINER}" \
NODERED_PORT="${NODERED_PORT}" \
CODE_CONTAINER="${CODE_CONTAINER}" \
COLLABORA_IP="${COLLABORA_IP}" \
COLLABORA_URL="${COLLABORA_URL}" \
NEXTCLOUD_URL="${NEXTCLOUD_URL}" \
INSTALL_USER="${INSTALL_USER:-}" \
bash "${SCRIPT_DIR}/scripts/integrate-into-nodered.sh"
log "Done."