Add asterisk, nextcloud, onlyoffice, mattermost services + vendor/easy-asterisk
asterisk.sh (homelab): - Easy Asterisk PBX with self-hosted coturn TURN server - Vendored from outis1one/easy-asterisk v0.10.0 for offline install - LAN-only or FQDN mode (TLS + TURN relay for remote access) - Auto-answer SIP headers for intercom use case - Authelia SSO for web admin; WEB_ADMIN_AUTH_DISABLED=true when chosen - UFW rules: 5060-5061, 8080, 8088-8089, 3478, 10000-20000/udp, 49152-49252/udp - Builds custom Docker image from vendor/easy-asterisk/ nextcloud.sh (utilities): - Custom Dockerfile: nextcloud:apache + smbclient (SMB external storage) - MariaDB 10.11 sidecar with matching env vars - OVERWRITEPROTOCOL/OVERWRITECLIURL/TRUSTED_PROXIES set for Caddy - Enables files_external app after first-run init (waits up to 90s) onlyoffice.sh (utilities): - JWT generated once, preserved across re-runs - _ensure_yq: auto-installs yq v4 for FileBrowser config patching - _wire_nextcloud: idempotent occ wiring (DocumentServerUrl, jwt_secret) - _wire_filebrowser: patches config.yaml + restarts container - Caddy block overrides X-Frame-Options to allow iframe embedding mattermost.sh (utilities): - PostgreSQL 15-alpine + Mattermost Team Edition + coturn (port 3479) - 8443/udp for Calls plugin RTC server - coturn uses --use-auth-secret HMAC mode (required by Calls plugin) - SITE_URL computed from SITE_DOMAIN, promptable - UFW: 8443/udp, 3479, 49153-49352/udp vendor/easy-asterisk/: - All upstream source files vendored for offline/self-contained installs - Dockerfile, docker/entrypoint.sh, docker/coturn-entrypoint.sh - easy-asterisk-v0.10.0.sh (6929-line management script) - scripts/vpn-diagnostics.sh, scripts/dns-whitelist.sh - .env.example https://claude.ai/code/session_014CCYqVwW6d6f5dw1qRokYt
This commit is contained in:
+164
-198
@@ -2,14 +2,14 @@
|
||||
# services/mattermost.sh — Team messaging with voice/video calls (Mattermost + coturn).
|
||||
# Part of the modular post-install system (sourced by setup.sh).
|
||||
#
|
||||
# Mattermost Team Edition with PostgreSQL and a dedicated coturn TURN server
|
||||
# (port 3479 — distinct from Easy Asterisk's coturn on 3478).
|
||||
#
|
||||
# Can also be run standalone on any machine:
|
||||
# sudo bash mattermost.sh
|
||||
# (Docker must already be installed when run standalone)
|
||||
|
||||
# ── Standalone bootstrap ──────────────────────────────────────────────────────
|
||||
# Detected when the script is executed directly rather than sourced by setup.sh.
|
||||
# Sets up helpers and globals, then defers execution until after the function
|
||||
# definition at the bottom of this file.
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
[[ "$(id -u)" == "0" ]] || { echo "Run with sudo: sudo bash $0"; exit 1; }
|
||||
|
||||
@@ -17,9 +17,11 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
_COMMON="$_SELF_DIR/../lib/common.sh"
|
||||
|
||||
if [[ -f "$_COMMON" ]]; then
|
||||
# Full repo present — use the real helpers (picks up ~/docker/.config too)
|
||||
# shellcheck source=../lib/common.sh
|
||||
source "$_COMMON"
|
||||
else
|
||||
# One-off copy — inline minimal stubs so the script works without the repo
|
||||
log_info() { echo -e "\033[0;34m[INFO]\033[0m $*"; }
|
||||
log_success() { echo -e "\033[0;32m[OK]\033[0m $*"; }
|
||||
log_warning() { echo -e "\033[1;33m[WARN]\033[0m $*"; }
|
||||
@@ -38,15 +40,11 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
}
|
||||
}
|
||||
|
||||
generate_password() {
|
||||
local _len="${1:-32}"
|
||||
tr -dc 'A-Za-z0-9' </dev/urandom | head -c "$_len"
|
||||
}
|
||||
|
||||
ensure_docker_dir_ownership() {
|
||||
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$@" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# Match common.sh's eval-based pattern so local vars in install_* are set correctly
|
||||
prompt_text() {
|
||||
local _q="$1" _def="$2" _var="$3" _r
|
||||
[[ "${UNATTENDED:-false}" == "true" ]] && { eval "$_var='$_def'"; return; }
|
||||
@@ -66,6 +64,53 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
local _caddy_dir="$DOCKER_DIR/caddy"
|
||||
local _caddyfile="$_caddy_dir/Caddyfile"
|
||||
|
||||
# Remote Caddy support: if CADDY_REMOTE_HOST is set, operate on the
|
||||
# remote machine via SSH instead of the local filesystem.
|
||||
if [[ -n "${CADDY_REMOTE_HOST:-}" ]]; then
|
||||
echo ""
|
||||
local _do_caddy=""
|
||||
read -r -p " Configure Caddy reverse proxy for $_name on $CADDY_REMOTE_HOST? [y/N]: " _do_caddy
|
||||
[[ "${_do_caddy,,}" == "y" ]] || {
|
||||
log_info "Skipping — access at: http://$(hostname -I | awk '{print $1}'):${_upstream##*:}"
|
||||
return 0
|
||||
}
|
||||
|
||||
local _domain=""
|
||||
read -r -p " Domain (e.g. ${_subdomain}.${SITE_DOMAIN:-example.com}): " _domain
|
||||
[[ -n "$_domain" ]] || { log_warning "No domain entered — skipping Caddy."; return 0; }
|
||||
|
||||
local _block
|
||||
_block="$(cat << CBLOCK
|
||||
|
||||
# $_name
|
||||
$_domain {
|
||||
reverse_proxy $_upstream
|
||||
|
||||
header {
|
||||
Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
||||
X-Content-Type-Options "nosniff"
|
||||
X-Frame-Options "SAMEORIGIN"
|
||||
Referrer-Policy "strict-origin-when-cross-origin"
|
||||
}
|
||||
|
||||
log {
|
||||
output file /var/log/caddy/${_domain}.log
|
||||
format json
|
||||
}
|
||||
${_extra}
|
||||
}
|
||||
CBLOCK
|
||||
)"
|
||||
echo "$_block" | ssh "$CADDY_REMOTE_HOST" "cat >> $_caddyfile"
|
||||
ssh "$CADDY_REMOTE_HOST" "docker exec caddy caddy fmt --overwrite /etc/caddy/Caddyfile 2>/dev/null || true"
|
||||
if ssh "$CADDY_REMOTE_HOST" "docker exec caddy caddy reload --config /etc/caddy/Caddyfile 2>/dev/null"; then
|
||||
log_success "$_name accessible at: https://$_domain"
|
||||
else
|
||||
log_warning "Reload failed — check: ssh $CADDY_REMOTE_HOST docker logs caddy"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ! -d "$_caddy_dir" ]]; then
|
||||
log_info "Access $_name directly on port ${_upstream##*:}."
|
||||
return 0
|
||||
@@ -83,6 +128,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
read -r -p " Domain (e.g. ${_subdomain}.${SITE_DOMAIN:-example.com}): " _domain
|
||||
[[ -n "$_domain" ]] || { log_warning "No domain entered — skipping Caddy."; return 0; }
|
||||
|
||||
# Back up before touching
|
||||
if [[ -f "$_caddyfile" ]]; then
|
||||
local _bk="$_caddy_dir/Caddyfile.backup.$(date +%Y%m%d-%H%M%S)"
|
||||
cp "$_caddyfile" "$_bk"
|
||||
@@ -91,6 +137,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
touch "$_caddyfile"
|
||||
fi
|
||||
|
||||
# Remove existing block for this domain if present
|
||||
if grep -q "^${_domain}" "$_caddyfile" 2>/dev/null; then
|
||||
log_warning "$_domain already in Caddyfile"
|
||||
local _ow=""
|
||||
@@ -131,12 +178,21 @@ CBLOCK
|
||||
}
|
||||
|
||||
write_readme() {
|
||||
local _dir="$1"; shift
|
||||
local _dir="$1"
|
||||
mkdir -p "$_dir"
|
||||
[[ "${DRY_RUN:-false}" == "true" ]] && return 0
|
||||
cat > "$_dir/README.md"
|
||||
}
|
||||
|
||||
generate_password() {
|
||||
local _len="${1:-32}"
|
||||
tr -dc 'A-Za-z0-9' < /dev/urandom | head -c "$_len"
|
||||
echo
|
||||
}
|
||||
fi
|
||||
|
||||
# Globals — ACTUAL_USER/ACTUAL_HOME must come before DOCKER_DIR
|
||||
# ($HOME under sudo is /root, not the real user's home)
|
||||
ACTUAL_USER="${ACTUAL_USER:-${SUDO_USER:-$USER}}"
|
||||
ACTUAL_HOME="$(getent passwd "$ACTUAL_USER" 2>/dev/null | cut -d: -f6 || echo "${HOME:-/root}")"
|
||||
DOCKER_DIR="${DOCKER_DIR:-$ACTUAL_HOME/docker}"
|
||||
@@ -145,8 +201,9 @@ CBLOCK
|
||||
SITE_TZ="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
|
||||
SITE_DOMAIN="${SITE_DOMAIN:-example.com}"
|
||||
SITE_CADDY_NET="${SITE_CADDY_NET:-caddy_net}"
|
||||
CADDY_REMOTE_HOST="${CADDY_REMOTE_HOST:-}"
|
||||
|
||||
register_service() { :; }
|
||||
register_service() { :; } # no-op — no wizard to register into
|
||||
_RUN_STANDALONE=1
|
||||
fi
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
@@ -155,67 +212,57 @@ register_service mattermost utilities "Team messaging with voice/video calls (Ma
|
||||
|
||||
install_mattermost() {
|
||||
require_docker || return 1
|
||||
log_info "Installing Mattermost Team Edition..."
|
||||
log_info "Installing Mattermost + coturn..."
|
||||
|
||||
local DIR="$DOCKER_DIR/mattermost"
|
||||
|
||||
if [ "$DRY_RUN" = true ]; then
|
||||
echo "[DRY-RUN] Would create $DIR with subdirectories: data logs config plugins db"
|
||||
echo "[DRY-RUN] Would generate DB password, MM secret key, and TURN secret"
|
||||
echo "[DRY-RUN] Would write docker-compose.yml and .env"
|
||||
echo "[DRY-RUN] Would open UFW ports: 3479/udp+tcp, 49153-49352/udp"
|
||||
echo "[DRY-RUN] Would configure Caddy reverse proxy for Mattermost"
|
||||
echo "[DRY-RUN] Would create $DIR with docker-compose.yml"
|
||||
echo "[DRY-RUN] Would write .env with DB and Mattermost secrets"
|
||||
echo "[DRY-RUN] Would create data/ logs/ config/ plugins/ db/ subdirectories"
|
||||
echo "[DRY-RUN] Would open UFW ports 8443/udp, 3479, 49153:49352/udp"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# ── Create directory structure ────────────────────────────────────────────
|
||||
mkdir -p "$DIR"/{data,logs,config,plugins,db}
|
||||
# Mattermost runs as UID 2000 inside the container
|
||||
chown -R 2000:2000 "$DIR/data" "$DIR/logs" "$DIR/config" "$DIR/plugins"
|
||||
ensure_docker_dir_ownership "$DIR/db"
|
||||
mkdir -p "$DIR"
|
||||
ensure_docker_dir_ownership "$DIR"
|
||||
cd "$DIR" || return 1
|
||||
|
||||
# ── Generate secrets ──────────────────────────────────────────────────────
|
||||
local DB_PASS MM_SECRET TURN_SECRET
|
||||
DB_PASS="$(generate_password 32)"
|
||||
MM_SECRET="$(generate_password 48)"
|
||||
TURN_SECRET="$(openssl rand -hex 32 2>/dev/null || generate_password 32)"
|
||||
local DB_PASS
|
||||
local MM_SECRET
|
||||
DB_PASS=$(generate_password 32)
|
||||
MM_SECRET=$(generate_password 48)
|
||||
|
||||
# ── Site URL ──────────────────────────────────────────────────────────────
|
||||
local TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
|
||||
local UID_VAL GID_VAL
|
||||
UID_VAL=$(id -u "$ACTUAL_USER")
|
||||
GID_VAL=$(id -g "$ACTUAL_USER")
|
||||
|
||||
# Compute SITE_URL
|
||||
local SITE_URL="http://localhost:8065"
|
||||
if [[ -n "$SITE_DOMAIN" && "$SITE_DOMAIN" != "example.com" ]]; then
|
||||
SITE_URL="https://chat.${SITE_DOMAIN}"
|
||||
if [ -n "$SITE_DOMAIN" ] && [ "$SITE_DOMAIN" != "example.com" ]; then
|
||||
SITE_URL="https://mattermost.${SITE_DOMAIN}"
|
||||
fi
|
||||
local CONFIGURED_SITEURL=""
|
||||
prompt_text "Mattermost site URL [${SITE_URL}]:" "$SITE_URL" CONFIGURED_SITEURL
|
||||
prompt_text "Mattermost site URL [$SITE_URL]:" "$SITE_URL" CONFIGURED_SITEURL
|
||||
[[ -n "$CONFIGURED_SITEURL" ]] && SITE_URL="$CONFIGURED_SITEURL"
|
||||
|
||||
# ── docker-compose.yml ────────────────────────────────────────────────────
|
||||
cat > docker-compose.yml << COMPOSE
|
||||
# Mattermost Team Edition — generated by ubuntu-post-install
|
||||
# Manage: docker compose up -d / down / logs -f
|
||||
# Admin setup: \${MATTERMOST_SITE_URL}/signup_user_complete
|
||||
|
||||
cat > docker-compose.yml << 'EOF'
|
||||
name: mattermost
|
||||
|
||||
services:
|
||||
|
||||
db:
|
||||
image: postgres:15-alpine
|
||||
container_name: mattermost-db
|
||||
hostname: mattermost-db
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
pids_limit: 100
|
||||
env_file: .env
|
||||
volumes:
|
||||
- ./db:/var/lib/postgresql/data
|
||||
environment:
|
||||
- POSTGRES_USER=mattermost
|
||||
- POSTGRES_PASSWORD=\${DB_PASS}
|
||||
- POSTGRES_DB=mattermost
|
||||
networks:
|
||||
- caddy_net
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U mattermost"]
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
@@ -223,46 +270,36 @@ services:
|
||||
mattermost:
|
||||
image: mattermost/mattermost-team-edition:latest
|
||||
container_name: mattermost
|
||||
hostname: mattermost
|
||||
restart: unless-stopped
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
pids_limit: 200
|
||||
env_file: .env
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8065:8065"
|
||||
- "8443:8443/udp" # Calls plugin RTC server (WebRTC direct path)
|
||||
volumes:
|
||||
- ./data:/mattermost/data
|
||||
- ./logs:/mattermost/logs
|
||||
- ./config:/mattermost/config
|
||||
- ./plugins:/mattermost/plugins
|
||||
environment:
|
||||
- MM_SQLSETTINGS_DRIVERNAME=postgres
|
||||
- MM_SQLSETTINGS_DATASOURCE=postgres://mattermost:\${DB_PASS}@db:5432/mattermost?sslmode=disable
|
||||
- MM_SERVICESETTINGS_SITEURL=\${MATTERMOST_SITE_URL}
|
||||
- MM_PLUGINSETTINGS_ENABLEUPLOADS=true
|
||||
- MM_SERVICESETTINGS_ENABLELOCALMODE=true
|
||||
- TZ=\${TZ}
|
||||
ports:
|
||||
- "8065:8065"
|
||||
- "8443:8443/udp"
|
||||
networks:
|
||||
- default
|
||||
- caddy_net
|
||||
|
||||
coturn:
|
||||
image: coturn/coturn:latest
|
||||
container_name: mattermost-coturn
|
||||
restart: unless-stopped
|
||||
network_mode: host
|
||||
user: root
|
||||
command:
|
||||
- -n
|
||||
- --listening-port=3479
|
||||
- --tls-listening-port=5350
|
||||
- --listening-ip=0.0.0.0
|
||||
- --fingerprint
|
||||
- --use-auth-secret
|
||||
- --static-auth-secret=\${TURN_SECRET}
|
||||
- --realm=\${TURN_REALM}
|
||||
- --static-auth-secret=${COTURN_SECRET}
|
||||
- --realm=${MM_REALM:-localhost}
|
||||
- --min-port=49153
|
||||
- --max-port=49352
|
||||
- --no-tls
|
||||
@@ -270,171 +307,100 @@ services:
|
||||
- --no-cli
|
||||
- --no-multicast-peers
|
||||
- --log-file=stdout
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
default:
|
||||
caddy_net:
|
||||
external: true
|
||||
name: \${CADDY_NET:-caddy_net}
|
||||
COMPOSE
|
||||
name: ${CADDY_NET:-caddy_net}
|
||||
EOF
|
||||
|
||||
# ── .env ──────────────────────────────────────────────────────────────────
|
||||
cat > .env << ENV
|
||||
# Mattermost — environment configuration
|
||||
# Edit and restart: docker compose down && docker compose up -d
|
||||
|
||||
# PostgreSQL password (do not change after first start without migrating data)
|
||||
DB_PASS=$DB_PASS
|
||||
|
||||
# Mattermost secret key (used for signing session tokens)
|
||||
MM_SECRET=$MM_SECRET
|
||||
|
||||
# Site URL — must match the public URL clients use to access Mattermost
|
||||
MATTERMOST_SITE_URL=$SITE_URL
|
||||
|
||||
# Timezone
|
||||
TZ=$SITE_TZ
|
||||
|
||||
# TURN server shared secret for Mattermost Calls plugin
|
||||
# Generate a new one: openssl rand -hex 32
|
||||
TURN_SECRET=$TURN_SECRET
|
||||
|
||||
# TURN realm (typically your domain)
|
||||
TURN_REALM=${SITE_DOMAIN:-localhost}
|
||||
|
||||
# Caddy network name
|
||||
cat > .env << EOF
|
||||
TZ=$TZ_VAL
|
||||
CADDY_NET=$SITE_CADDY_NET
|
||||
ENV
|
||||
|
||||
# PostgreSQL
|
||||
POSTGRES_DB=mattermost
|
||||
POSTGRES_USER=mattermost
|
||||
POSTGRES_PASSWORD=$DB_PASS
|
||||
|
||||
# Mattermost
|
||||
MM_SQLSETTINGS_DRIVERNAME=postgres
|
||||
MM_SQLSETTINGS_DATASOURCE=postgres://mattermost:${DB_PASS}@mattermost-db:5432/mattermost?sslmode=disable&connect_timeout=10
|
||||
MM_SERVICESETTINGS_SITEURL=$SITE_URL
|
||||
MM_SERVICESETTINGS_ENABLELOCALMODE=true
|
||||
MM_FILESETTINGS_DRIVERNAME=local
|
||||
MM_PLUGINSETTINGS_ENABLE=true
|
||||
|
||||
# coturn HMAC secret for Mattermost Calls plugin
|
||||
COTURN_SECRET=$MM_SECRET
|
||||
MM_REALM=${SITE_DOMAIN:-localhost}
|
||||
|
||||
# PUID/PGID for file ownership
|
||||
PUID=$UID_VAL
|
||||
PGID=$GID_VAL
|
||||
EOF
|
||||
chmod 600 .env
|
||||
chown "$ACTUAL_USER:$ACTUAL_USER" .env
|
||||
|
||||
# ── UFW firewall rules ─────────────────────────────────────────────────────
|
||||
echo ""
|
||||
log_info "Firewall — Mattermost coturn uses port 3479 (avoiding conflict with Easy Asterisk on 3478)."
|
||||
if command -v ufw >/dev/null 2>&1 && ufw status 2>/dev/null | grep -q "Status: active"; then
|
||||
log_info "Opening UFW ports for Mattermost..."
|
||||
ufw allow 8443/udp comment "Mattermost Calls RTC server" >/dev/null
|
||||
ufw allow 3479/udp comment "Mattermost coturn STUN/TURN" >/dev/null
|
||||
ufw allow 3479/tcp comment "Mattermost coturn STUN/TURN" >/dev/null
|
||||
ufw allow 49153:49352/udp comment "Mattermost coturn relay" >/dev/null
|
||||
log_success "UFW rules added"
|
||||
else
|
||||
log_info "UFW not active — add these rules manually if needed:"
|
||||
echo " ufw allow 8443/udp # Mattermost Calls RTC"
|
||||
echo " ufw allow 3479/udp && ufw allow 3479/tcp # coturn STUN/TURN"
|
||||
echo " ufw allow 49153:49352/udp # coturn relay"
|
||||
mkdir -p data logs config plugins db
|
||||
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$DIR"
|
||||
|
||||
# Open required firewall ports
|
||||
if command -v ufw &>/dev/null; then
|
||||
ufw allow 8443/udp comment "Mattermost Calls RTC"
|
||||
ufw allow 3479/udp; ufw allow 3479/tcp
|
||||
ufw allow 49153:49352/udp comment "Mattermost coturn relay"
|
||||
fi
|
||||
|
||||
# ── Router port-forward instructions ──────────────────────────────────────
|
||||
echo ""
|
||||
echo " ┌─────────────────────────────────────────────────────────────────┐"
|
||||
echo " │ Router port-forwards needed for Mattermost Calls (external) │"
|
||||
echo " ├──────────────────┬──────────┬──────────────────────────────────┤"
|
||||
echo " │ Port(s) │ Protocol │ Service │"
|
||||
echo " ├──────────────────┼──────────┼──────────────────────────────────┤"
|
||||
echo " │ 8443 │ UDP │ Calls plugin RTC (direct WebRTC) │"
|
||||
echo " │ 3479 │ UDP+TCP │ coturn STUN/TURN │"
|
||||
echo " │ 49153–49352 │ UDP │ coturn relay range │"
|
||||
echo " └──────────────────┴──────────┴──────────────────────────────────┘"
|
||||
echo ""
|
||||
echo " ⚠ WebRTC (Calls) requires HTTPS. Calls will not work if Mattermost"
|
||||
echo " is accessed over plain HTTP. Configure Caddy with a domain below."
|
||||
echo ""
|
||||
log_success "Mattermost configured at $DIR"
|
||||
|
||||
ensure_docker_dir_ownership "$DIR"
|
||||
configure_caddy_for_service "Mattermost" "mattermost:8065" "mattermost"
|
||||
|
||||
# ── Caddy reverse proxy ───────────────────────────────────────────────────
|
||||
# SITEURL is already set from SITE_DOMAIN above. configure_caddy_for_service
|
||||
# will pre-fill the domain prompt with chat.$SITE_DOMAIN.
|
||||
configure_caddy_for_service "Mattermost" "mattermost:8065" "chat"
|
||||
|
||||
# ── README ────────────────────────────────────────────────────────────────
|
||||
write_readme "$DIR" << MD
|
||||
# Mattermost
|
||||
|
||||
Team messaging platform with voice/video calls via the Calls plugin and self-hosted coturn TURN server.
|
||||
Team messaging with voice/video calls. PostgreSQL backend + coturn TURN relay.
|
||||
|
||||
## Access
|
||||
- Direct: http://localhost:8065
|
||||
- Via Caddy: see your configured domain (e.g. https://chat.${SITE_DOMAIN:-example.com})
|
||||
- URL: $SITE_URL (or http://localhost:8065)
|
||||
- First run: create admin account at the URL above
|
||||
|
||||
## Initial admin setup
|
||||
Visit: \`${SITE_URL}/signup_user_complete\`
|
||||
## Voice/Video Calls (Calls plugin)
|
||||
Port 8443/udp must be open on your router/firewall.
|
||||
coturn relay runs on port 3479 (HMAC secret in .env).
|
||||
|
||||
The first user to sign up becomes the System Admin.
|
||||
|
||||
## Calls plugin (voice/video)
|
||||
The Mattermost Calls plugin provides voice/video channels.
|
||||
**WebRTC requires HTTPS** — calls will not work over plain HTTP.
|
||||
|
||||
### Enable the plugin
|
||||
1. Go to **System Console → Plugins → Plugin Management**
|
||||
2. Enable the **Calls** plugin (pre-installed in Team Edition)
|
||||
|
||||
### Configure ICE / TURN server
|
||||
1. Go to **System Console → Plugins → Calls**
|
||||
2. Set **RTC Server Address**: your server's public IP or domain
|
||||
3. Set **TURN server URL**: \`turn:<your-server-or-ip>:3479\`
|
||||
4. Set **TURN credentials type**: Static credentials (auth secret)
|
||||
5. Set **TURN static auth secret**: (see \`TURN_SECRET\` in \`$DIR/.env\`)
|
||||
6. Save and test a call in a channel
|
||||
|
||||
Direct WebRTC (port 8443/UDP) is tried first; coturn relay is the fallback
|
||||
for clients behind strict NAT (cellular, hotel WiFi, Proton VPN, etc.).
|
||||
|
||||
## Router port-forwards (for external calls)
|
||||
| Port(s) | Protocol | Service |
|
||||
|--------------|-----------|---------------------------------|
|
||||
| 8443 | UDP | Calls plugin RTC (direct path) |
|
||||
| 3479 | UDP+TCP | coturn STUN/TURN |
|
||||
| 49153–49352 | UDP | coturn relay range |
|
||||
Configure in Mattermost: System Console → Plugins → Calls:
|
||||
- TURN Server URI: turn:YOUR_DOMAIN_OR_IP:3479?transport=udp
|
||||
- TURN Credentials: use static-auth-secret (see .env COTURN_SECRET)
|
||||
|
||||
## Manage
|
||||
\`\`\`bash
|
||||
cd $DIR
|
||||
docker compose up -d # start
|
||||
docker compose down # stop
|
||||
docker compose logs -f # all logs
|
||||
docker compose logs -f mattermost # app logs only
|
||||
docker compose logs -f coturn # TURN server logs
|
||||
docker compose pull && docker compose up -d # update images
|
||||
docker compose up -d
|
||||
docker compose down
|
||||
docker compose logs -f
|
||||
docker compose pull && docker compose up -d
|
||||
\`\`\`
|
||||
|
||||
## Backup
|
||||
Important paths to back up:
|
||||
- \`$DIR/data/\` — uploaded files and attachments
|
||||
- \`$DIR/config/\` — server configuration
|
||||
- \`$DIR/plugins/\` — installed plugins
|
||||
- \`$DIR/db/\` — PostgreSQL data directory
|
||||
- \`$DIR/.env\` — secrets and configuration
|
||||
|
||||
## Configuration
|
||||
Main config file: \`$DIR/config/config.json\` (created on first start).
|
||||
Environment variables in \`.env\` override config.json values.
|
||||
After editing .env: \`docker compose down && docker compose up -d\`
|
||||
MD
|
||||
|
||||
# ── Start ──────────────────────────────────────────────────────────────────
|
||||
echo ""
|
||||
if [[ "$SITE_URL" == http://* ]]; then
|
||||
log_warning "WebRTC (voice/video calls) requires HTTPS. Configure Caddy and update SITE_URL."
|
||||
fi
|
||||
|
||||
local START=""
|
||||
prompt_yn "Start Mattermost now? (y/n):" "y" START
|
||||
if [[ "$START" =~ ^[Yy]$ ]]; then
|
||||
log_info "Pulling images and starting Mattermost (first start may take a minute)..."
|
||||
if docker compose pull 2>&1 | tail -3 && docker compose up -d; then
|
||||
log_success "Mattermost started"
|
||||
echo ""
|
||||
echo " App: http://localhost:8065"
|
||||
echo " Admin setup: ${SITE_URL}/signup_user_complete"
|
||||
echo ""
|
||||
log_info "Enable the Calls plugin and configure TURN at:"
|
||||
log_info " System Console → Plugins → Calls"
|
||||
log_info " TURN URL: turn:<your-public-ip>:3479"
|
||||
log_info " TURN secret: (see $DIR/.env → TURN_SECRET)"
|
||||
else
|
||||
log_warning "Start failed — check: docker compose logs"
|
||||
fi
|
||||
if [ "$START" = "y" ] || [ "$START" = "Y" ]; then
|
||||
docker compose up -d \
|
||||
&& log_success "Mattermost started" \
|
||||
|| log_warning "Start failed — check: docker compose logs"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo " Access at: $SITE_URL"
|
||||
echo " First run: open the URL above and create your admin account."
|
||||
echo " Calls plugin: System Console → Plugins → Calls to configure coturn."
|
||||
echo " TURN URI: turn:${SITE_DOMAIN:-YOUR_IP}:3479?transport=udp"
|
||||
echo " Auth secret: see COTURN_SECRET in $DIR/.env"
|
||||
echo ""
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user