fix(postiz,ente,lobehub): address testing feedback

- postiz: add postiz-rebuild helper for env changes & social provider setup
- ente: rewrite ente-setup Step 4 to use direct SQL instead of flaky CLI
- ente: improve ente-upgrade-subscription to bypass interactive prompts
- lobehub: replace broken ParadeDB APT repo (402) with GitHub release .deb
This commit is contained in:
MickLesk
2026-04-02 18:10:25 +02:00
parent 679a514f86
commit 81dcba7758
5 changed files with 96 additions and 17 deletions

View File

@@ -339,6 +339,9 @@ cat <<'SETUP' >/usr/local/bin/ente-setup
set -e set -e
LOCAL_IP=$(hostname -I | awk '{print $1}') LOCAL_IP=$(hostname -I | awk '{print $1}')
DB_NAME="$(grep -A4 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')"
DB_PASS="$(grep -A5 '^db:' /opt/ente/server/museum.yaml | awk '/password:/{print $2}')"
echo "=== Ente First-Time Setup ===" echo "=== Ente First-Time Setup ==="
echo "" echo ""
read -r -p "Enter your account email: " EMAIL read -r -p "Enter your account email: " EMAIL
@@ -358,9 +361,12 @@ for i in $(seq 1 10); do
if [ -n "$OTT" ]; then break; fi if [ -n "$OTT" ]; then break; fi
sleep 1 sleep 1
done done
if [ -z "$OTT" ]; then
OTT=$(journalctl -u ente-museum --no-pager -n 200 2>/dev/null | grep -oP 'ott:\s*\K\d+' | tail -1)
fi
if [ -z "$OTT" ]; then if [ -z "$OTT" ]; then
echo "Could not auto-detect code. Searching all recent codes..." echo "Could not auto-detect code. Searching all recent codes..."
journalctl -u ente-museum --no-pager -n 200 | grep "Verification code" | tail -5 journalctl -u ente-museum --no-pager -n 200 | grep -i "Verification code\|ott" | tail -5
echo "" echo ""
echo "Enter the code shown above in the web UI, then press ENTER." echo "Enter the code shown above in the web UI, then press ENTER."
read -r -p "Press ENTER after verification..." read -r -p "Press ENTER after verification..."
@@ -371,9 +377,7 @@ else
read -r -p "Press ENTER after you verified the code..." read -r -p "Press ENTER after you verified the code..."
fi fi
DB_NAME="$(grep -A4 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')" USER_ID=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT user_id FROM users WHERE email = '$(echo "$EMAIL" | sed "s/'/''/g")' ORDER BY user_id LIMIT 1;")
DB_PASS="$(grep -A5 '^db:' /opt/ente/server/museum.yaml | awk '/password:/{print $2}')"
USER_ID=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT user_id FROM users ORDER BY user_id LIMIT 1;")
if [ -z "$USER_ID" ]; then if [ -z "$USER_ID" ]; then
echo "Error: No verified users found in database." echo "Error: No verified users found in database."
echo "Make sure you completed the verification step in the web UI." echo "Make sure you completed the verification step in the web UI."
@@ -384,27 +388,56 @@ echo "Found user ID: $USER_ID"
echo "" echo ""
echo "Step 3/4: Whitelisting admin in museum.yaml..." echo "Step 3/4: Whitelisting admin in museum.yaml..."
if grep -q "^internal:" /opt/ente/server/museum.yaml; then if grep -q "^internal:" /opt/ente/server/museum.yaml; then
sed -i "/^ admin:/d" /opt/ente/server/museum.yaml if ! grep -qF "$EMAIL" /opt/ente/server/museum.yaml; then
sed -i "/^internal:/a\\ admin: $USER_ID" /opt/ente/server/museum.yaml sed -i "/admins:/a\\ - $EMAIL" /opt/ente/server/museum.yaml
fi
else else
printf '\ninternal:\n admin: %s\n' "$USER_ID" >> /opt/ente/server/museum.yaml printf '\ninternal:\n admins:\n - %s\n' "$EMAIL" >> /opt/ente/server/museum.yaml
fi fi
systemctl restart ente-museum systemctl restart ente-museum
sleep 2 sleep 2
echo "Done." echo "Done."
echo "" echo ""
echo "Step 4/4: Adding account to Ente CLI & upgrading subscription..." echo "Step 4/4: Upgrading subscription..."
mkdir -p /opt/ente_data/photos PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "UPDATE subscriptions SET storage_in_mbs_per_plan = 10737418240, expiry_time = 2524608000000000 WHERE user_id = ${USER_ID};" 2>/dev/null
export ENTE_CLI_SECRETS_PATH=/opt/ente/cli-config/secrets.txt ROWS=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT count(*) FROM subscriptions WHERE user_id = ${USER_ID};" 2>/dev/null)
printf 'photos\n/opt/ente_data/photos\n' | ente account add if [ "$ROWS" = "0" ]; then
ente admin update-subscription -a "$EMAIL" -u "$EMAIL" --no-limit True PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "INSERT INTO subscriptions (user_id, storage_in_mbs_per_plan, expiry_time, product_id, payment_provider, transaction_id, original_transaction_id) VALUES (${USER_ID}, 10737418240, 2524608000000000, 'self_hosted_unlimited', 'admin', 'admin_setup', 'admin_setup');" 2>/dev/null
fi
echo "Subscription upgraded to unlimited storage."
echo "" echo ""
echo "=== Setup Complete ===" echo "=== Setup Complete ==="
echo "You can now use Ente Photos/Auth with unlimited storage." echo "You can now use Ente Photos/Auth with unlimited storage."
echo "Access Ente Photos at: http://${LOCAL_IP}:3000"
SETUP SETUP
chmod +x /usr/local/bin/ente-setup chmod +x /usr/local/bin/ente-setup
cat <<'EOF' >/usr/local/bin/ente-upgrade-subscription
#!/usr/bin/env bash
if [ -z "$1" ]; then
echo "Usage: ente-upgrade-subscription <email>"
echo "Example: ente-upgrade-subscription user@example.com"
exit 1
fi
EMAIL="$1"
DB_NAME="$(grep -A4 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')"
DB_PASS="$(grep -A5 '^db:' /opt/ente/server/museum.yaml | awk '/password:/{print $2}')"
echo "Upgrading subscription for: $EMAIL"
USER_ID=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT user_id FROM users WHERE email = '$(echo "$EMAIL" | sed "s/'/''/g")' ORDER BY user_id LIMIT 1;")
if [ -z "$USER_ID" ]; then
echo "Error: User not found in database."
exit 1
fi
PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "UPDATE subscriptions SET storage_in_mbs_per_plan = 10737418240, expiry_time = 2524608000000000 WHERE user_id = ${USER_ID};" 2>/dev/null
ROWS=$(PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -tAc "SELECT count(*) FROM subscriptions WHERE user_id = ${USER_ID};" 2>/dev/null)
if [ "$ROWS" = "0" ]; then
PGPASSWORD="$DB_PASS" psql -h 127.0.0.1 -U ente -d "$DB_NAME" -c "INSERT INTO subscriptions (user_id, storage_in_mbs_per_plan, expiry_time, product_id, payment_provider, transaction_id, original_transaction_id) VALUES (${USER_ID}, 10737418240, 2524608000000000, 'self_hosted_unlimited', 'admin', 'admin_setup', 'admin_setup');" 2>/dev/null
fi
echo "Done. Subscription upgraded to unlimited storage for: $EMAIL"
EOF
chmod +x /usr/local/bin/ente-upgrade-subscription
msg_ok "Created helper scripts" msg_ok "Created helper scripts"
motd_ssh motd_ssh

View File

@@ -18,11 +18,20 @@ $STD apt install -y \
build-essential build-essential
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Adding ParadeDB Repository" PG_VERSION="17" PG_MODULES="pgvector" setup_postgresql
curl -fsSL https://packagecloud.io/install/repositories/paradedb/paradedb/script.deb.sh | $STD bash
msg_ok "Added ParadeDB Repository" msg_info "Installing pg_search from ParadeDB"
ARCH=$(dpkg --print-architecture)
CODENAME=$(. /etc/os-release && echo "${VERSION_CODENAME:-bookworm}")
PDB_VERSION=$(curl -fsSL "https://api.github.com/repos/paradedb/paradedb/releases/latest" | grep -oP '"tag_name":\s*"\K[^"]+')
PDB_VERSION_NUM="${PDB_VERSION#v}"
DEB_NAME="postgresql-17-pg-search_${PDB_VERSION_NUM}-1PARADEDB-${CODENAME}_${ARCH}.deb"
DEB_URL="https://github.com/paradedb/paradedb/releases/download/${PDB_VERSION}/${DEB_NAME}"
curl -fsSL -o "/tmp/${DEB_NAME}" "$DEB_URL"
$STD dpkg -i "/tmp/${DEB_NAME}" || $STD apt install -f -y
rm -f "/tmp/${DEB_NAME}"
msg_ok "Installed pg_search from ParadeDB"
PG_VERSION="17" PG_MODULES="pgvector,pg-search" setup_postgresql
PG_DB_NAME="lobehub" PG_DB_USER="lobehub" PG_DB_EXTENSIONS="vector,pg_search" setup_postgresql_db PG_DB_NAME="lobehub" PG_DB_USER="lobehub" PG_DB_EXTENSIONS="vector,pg_search" setup_postgresql_db
NODE_VERSION="24" setup_nodejs NODE_VERSION="24" setup_nodejs

View File

@@ -152,6 +152,39 @@ EOF
systemctl enable -q --now redis-server postiz-temporal postiz-backend postiz-frontend postiz-orchestrator systemctl enable -q --now redis-server postiz-temporal postiz-backend postiz-frontend postiz-orchestrator
msg_ok "Created Services" msg_ok "Created Services"
msg_info "Creating Helper Scripts"
cat <<'EOF' >/usr/local/bin/postiz-rebuild
#!/usr/bin/env bash
echo "=== Postiz Rebuild ==="
echo "Stopping services..."
systemctl stop postiz-orchestrator postiz-frontend postiz-backend
cd /opt/postiz
set -a && source /opt/postiz/.env && set +a
export NODE_OPTIONS="--max-old-space-size=4096"
echo "Building application (this may take a while)..."
pnpm run build
BUILD_RC=$?
unset NODE_OPTIONS
if [[ $BUILD_RC -ne 0 ]]; then
echo "ERROR: Build failed! Check the output above."
echo "Starting services with previous build..."
systemctl start postiz-backend postiz-frontend postiz-orchestrator
exit 1
fi
echo "Running database migrations..."
pnpm run prisma-db-push
echo "Starting services..."
systemctl start postiz-backend postiz-frontend postiz-orchestrator
echo "=== Rebuild complete ==="
EOF
chmod +x /usr/local/bin/postiz-rebuild
msg_ok "Created Helper Scripts"
msg_info "Configuring Nginx" msg_info "Configuring Nginx"
cat <<EOF >/etc/nginx/sites-available/postiz cat <<EOF >/etc/nginx/sites-available/postiz
server { server {

View File

@@ -36,6 +36,10 @@
"text": "First-Start: Run `ente-setup` — it guides you through account creation, verification, and admin configuration", "text": "First-Start: Run `ente-setup` — it guides you through account creation, verification, and admin configuration",
"type": "warning" "type": "warning"
}, },
{
"text": "To upgrade subscription later: `ente-upgrade-subscription user@example.com`",
"type": "info"
},
{ {
"text": "For CLI admin docs see https://ente.io/help/self-hosting/administration/cli", "text": "For CLI admin docs see https://ente.io/help/self-hosting/administration/cli",
"type": "info" "type": "info"

View File

@@ -37,7 +37,7 @@
"type": "warning" "type": "warning"
}, },
{ {
"text": "NEXT_PUBLIC_* variables are baked at build time. If you change the IP/URL, rebuild with: cd /opt/postiz && pnpm run build", "text": "NEXT_PUBLIC_* variables are baked at build time. If you change the IP/URL or add social provider keys, rebuild with: postiz-rebuild",
"type": "info" "type": "info"
} }
] ]