#!/bin/sh # # Ente on Unraid: setup helper. # # Run this in the Unraid terminal BEFORE installing the Ente-Server template: # # sh -c "$(curl -fsSL https://raw.githubusercontent.com/YoshiroMaximus/unraid-templates/main/ente/setup.sh)" # # It generates all required secrets, writes /mnt/user/appdata/ente/museum.yaml, # and prints the matching values to use in your PostgreSQL and MinIO containers. set -e CONFIG_DIR=/mnt/user/appdata/ente CONFIG_FILE=$CONFIG_DIR/museum.yaml if [ -f "$CONFIG_FILE" ]; then echo "ERROR: $CONFIG_FILE already exists. Delete it first to start over." exit 1 fi if [ -d "$CONFIG_FILE" ]; then echo "ERROR: $CONFIG_FILE is a directory (created by Docker starting without a config)." echo "Remove it with: rmdir $CONFIG_FILE" exit 1 fi gen_password () { head -c 21 /dev/urandom | base64 | tr -d '\n'; } gen_key () { head -c 32 /dev/urandom | base64 | tr -d '\n'; } gen_hash () { head -c 64 /dev/urandom | base64 | tr -d '\n'; } gen_jwt () { head -c 32 /dev/urandom | base64 | tr -d '\n' | tr '+/' '-_'; } DEFAULT_IP=$(ip -4 route get 1 2>/dev/null | awk '{for(i=1;i<=NF;i++) if($i=="src") print $(i+1)}' | head -n1) printf "Unraid LAN IP [%s]: " "${DEFAULT_IP:-none detected}" read -r SERVER_IP SERVER_IP=${SERVER_IP:-$DEFAULT_IP} if [ -z "$SERVER_IP" ]; then echo "ERROR: could not detect an IP, please re-run and enter it." exit 1 fi printf "MinIO API port [3200]: " read -r MINIO_PORT MINIO_PORT=${MINIO_PORT:-3200} PG_PASS=$(gen_password) MINIO_USER=ente MINIO_PASS=$(gen_password) mkdir -p "$CONFIG_DIR" cat >"$CONFIG_FILE" </dev/null; then printf "Create the b2-eu-cen bucket now via MinIO at %s:%s? Requires MinIO to be running already. (y/N): " "$SERVER_IP" "$MINIO_PORT" read -r choice case "$choice" in y|Y) docker run --rm --entrypoint sh minio/mc -c \ "mc alias set ente http://$SERVER_IP:$MINIO_PORT '$MINIO_USER' '$MINIO_PASS' && mc mb -p ente/b2-eu-cen" \ && echo "Bucket created." \ || echo "Bucket creation failed. Create 'b2-eu-cen' via the MinIO console instead." ;; esac fi echo "Done. Install order: PostgreSQL, MinIO (+ bucket), Ente-Server, Ente-Web."