Add a Compose Manager Plus git stack for Fluxer.
The official bundle and the Unraid override live in the repository, and secrets stay in the stack .env outside the clone.
This commit is contained in:
1 parent
a19983df7b
commit
6d105355f4
20 files changed
+4805
-13
No files matched your search
@@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env bash
|
||||
# Write a Fluxer .env for Compose Manager Plus.
|
||||
# The stack .env lives outside the git clone. This script does not commit it.
|
||||
#
|
||||
# Usage, on Unraid, after the fluxer stack exists:
|
||||
# bash scripts/init-compose-env.sh chat.example.com
|
||||
#
|
||||
# Or write to an explicit file:
|
||||
# bash scripts/init-compose-env.sh chat.example.com /path/to/.env
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DOMAIN="${1:-}"
|
||||
OUT="${2:-}"
|
||||
|
||||
if [[ -z "$DOMAIN" ]]; then
|
||||
echo "Usage: bash scripts/init-compose-env.sh chat.example.com [output-file]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DOMAIN="${DOMAIN#https://}"
|
||||
DOMAIN="${DOMAIN#http://}"
|
||||
DOMAIN="${DOMAIN%%/*}"
|
||||
DOMAIN="${DOMAIN%%:*}"
|
||||
|
||||
if [[ ! "$DOMAIN" =~ ^[A-Za-z0-9]([A-Za-z0-9.-]*[A-Za-z0-9])?$ ]]; then
|
||||
echo "Domain must be a hostname such as chat.example.com." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -z "$OUT" && -d /boot/config/plugins/compose.manager/projects/fluxer ]]; then
|
||||
OUT="/boot/config/plugins/compose.manager/projects/fluxer/.env"
|
||||
fi
|
||||
|
||||
if [[ -z "$OUT" ]]; then
|
||||
echo "The Compose Manager stack folder was not found." >&2
|
||||
echo "Create the fluxer stack first, or pass an output file as the second argument." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -f "$OUT" ]] && grep -q '^POSTGRES_PASSWORD=.\+' "$OUT"; then
|
||||
echo "Refusing to replace secrets already in $OUT" >&2
|
||||
echo "Delete that file first if you really want a new one." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tmp="$(mktemp)"
|
||||
cleanup() { rm -f "$tmp" "${tmp}.vapid"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
hex32() { openssl rand -hex 32; }
|
||||
|
||||
{
|
||||
echo "FLUXER_SETTINGS_LOADED=true"
|
||||
echo "FLUXER_DOMAIN=$DOMAIN"
|
||||
echo "FLUXER_EDGE_BIND=0.0.0.0:18080"
|
||||
echo "FLUXER_APPDATA=/mnt/user/appdata/fluxer"
|
||||
echo "COMPOSE_PROJECT_NAME=fluxer"
|
||||
echo "FLUXER_S3_ACCESS_KEY=fluxer"
|
||||
echo "LIVEKIT_API_KEY=fluxer"
|
||||
echo "POSTGRES_PASSWORD=$(hex32)"
|
||||
echo "MEILI_MASTER_KEY=$(hex32)"
|
||||
echo "FLUXER_S3_SECRET_KEY=$(hex32)"
|
||||
echo "LIVEKIT_API_SECRET=$(hex32)"
|
||||
echo "FLUXER_SUDO_MODE_SECRET=$(hex32)"
|
||||
echo "FLUXER_CONNECTION_INITIATION_SECRET=$(hex32)"
|
||||
echo "FLUXER_PROFILE_PSEUDONYM_SECRET=$(hex32)"
|
||||
echo "FLUXER_GATEWAY_RPC_AUTH_TOKEN=$(hex32)"
|
||||
echo "FLUXER_ERLANG_COOKIE=$(hex32)"
|
||||
echo "FLUXER_MEDIA_PROXY_SECRET_KEY=$(hex32)"
|
||||
echo "FLUXER_ADMIN_SECRET_KEY_BASE=$(hex32)"
|
||||
echo "FLUXER_ADMIN_OAUTH_CLIENT_SECRET=$(hex32)"
|
||||
echo "FLUXER_SETUP_TOKEN=$(hex32)"
|
||||
echo "FLUXER_MEDIA_PROXY_UPLOAD_RELAY_SECRET_BASE64=$(openssl rand -base64 32 | tr -d '\n')"
|
||||
echo "FLUXER_ACTIVITYPUB_SIGNING_KEY_BASE64=$(openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -outform DER 2>/dev/null | base64 | tr -d '\n')"
|
||||
openssl ecparam -name prime256v1 -genkey -noout -out "${tmp}.vapid" 2>/dev/null
|
||||
pub="$(openssl ec -in "${tmp}.vapid" -pubout -outform DER 2>/dev/null | tail -c 65 | base64 | tr '/+' '_-' | tr -d '=\n')"
|
||||
priv="$(openssl ec -in "${tmp}.vapid" -outform DER 2>/dev/null | tail -c +8 | head -c 32 | base64 | tr '/+' '_-' | tr -d '=\n')"
|
||||
echo "FLUXER_VAPID_PUBLIC_KEY=$pub"
|
||||
echo "FLUXER_VAPID_PRIVATE_KEY=$priv"
|
||||
echo "FLUXER_POSTGRES_MEMORY_LIMIT=1gb"
|
||||
echo "FLUXER_POSTGRES_MEMORY_RESERVATION=256mb"
|
||||
echo "FLUXER_POSTGRES_SHM_SIZE=256mb"
|
||||
echo "FLUXER_POSTGRES_SHARED_BUFFERS=128MB"
|
||||
echo "FLUXER_POSTGRES_EFFECTIVE_CACHE_SIZE=512MB"
|
||||
echo "FLUXER_POSTGRES_MAINTENANCE_WORK_MEM=64MB"
|
||||
echo "FLUXER_POSTGRES_MAX_WAL_SIZE=512MB"
|
||||
echo "FLUXER_API_MEMORY_LIMIT=768mb"
|
||||
echo "FLUXER_API_MEMORY_RESERVATION=256mb"
|
||||
echo "FLUXER_WORKER_MEMORY_LIMIT=768mb"
|
||||
echo "FLUXER_WORKER_MEMORY_RESERVATION=256mb"
|
||||
echo "FLUXER_GATEWAY_MEMORY_LIMIT=512mb"
|
||||
echo "FLUXER_GATEWAY_MEMORY_RESERVATION=256mb"
|
||||
echo "FLUXER_MEILISEARCH_MEMORY_LIMIT=512mb"
|
||||
echo "FLUXER_MEILISEARCH_MAX_INDEXING_MEMORY=128mb"
|
||||
echo "FLUXER_SEAWEEDFS_MEMORY_LIMIT=512mb"
|
||||
echo "FLUXER_SEAWEEDFS_GOMEMLIMIT=384MiB"
|
||||
echo "FLUXER_MEDIA_PROXY_MEMORY_LIMIT=512mb"
|
||||
} > "$tmp"
|
||||
|
||||
mkdir -p "$(dirname "$OUT")"
|
||||
install -m 600 "$tmp" "$OUT"
|
||||
echo "Wrote $OUT"
|
||||
echo "Show the admin token with:"
|
||||
echo " awk -F= '\$1==\"FLUXER_SETUP_TOKEN\"{print \$2}' \"$OUT\""
|
||||
Reference in new issue
Block a user