mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-03-31 06:24:18 -04:00
fix(ente): auto-whitelist admin by user_id from database
The admin CLI requires the user to be whitelisted via their numeric user_id in museum.yaml's internal.admin field. The helper script ente-upgrade-subscription now: 1. Looks up user_id from PostgreSQL by email 2. Adds internal.admin to museum.yaml if not present 3. Restarts museum 4. Runs the subscription upgrade This replaces the previous approach that incorrectly assumed the first user was auto-admin (that fallback only works when internal section is completely absent AND was unreliable).
This commit is contained in:
@@ -309,7 +309,22 @@ if [ -z "$1" ]; then
|
||||
exit 1
|
||||
fi
|
||||
EMAIL="$1"
|
||||
echo "Upgrading subscription for: $EMAIL"
|
||||
DB_NAME="$(grep -A1 '^db:' /opt/ente/server/museum.yaml | awk '/name:/{print $2}')"
|
||||
DB_USER="$(grep -A2 '^db:' /opt/ente/server/museum.yaml | awk '/user:/{print $2}')"
|
||||
USER_ID=$(psql -U "$DB_USER" -d "$DB_NAME" -tAc "SELECT user_id FROM users WHERE email='$EMAIL' LIMIT 1;")
|
||||
if [ -z "$USER_ID" ]; then
|
||||
echo "Error: No user found with email $EMAIL"
|
||||
exit 1
|
||||
fi
|
||||
echo "Found user ID: $USER_ID for $EMAIL"
|
||||
if ! grep -q "^internal:" /opt/ente/server/museum.yaml; then
|
||||
printf '\ninternal:\n admin: %s\n' "$USER_ID" >> /opt/ente/server/museum.yaml
|
||||
echo "Added admin entry to museum.yaml"
|
||||
systemctl restart ente-museum
|
||||
sleep 2
|
||||
else
|
||||
echo "internal: section already exists in museum.yaml — verify admin is set"
|
||||
fi
|
||||
ente admin update-subscription -a "$EMAIL" -u "$EMAIL" --no-limit True
|
||||
EOF
|
||||
chmod +x /usr/local/bin/ente-upgrade-subscription
|
||||
|
||||
@@ -41,15 +41,11 @@
|
||||
"type": "warning"
|
||||
},
|
||||
{
|
||||
"text": "First-Start: The first registered user automatically becomes admin",
|
||||
"type": "info"
|
||||
},
|
||||
{
|
||||
"text": "First-Start: Add your account to the CLI: `ente account add` (export dir: any path, e.g. /photos)",
|
||||
"text": "First-Start: Add your account to the CLI first: `ente account add` (export dir: any path, e.g. /photos)",
|
||||
"type": "warning"
|
||||
},
|
||||
{
|
||||
"text": "First-Start: Remove the subscription limit: `ente admin update-subscription -a <email> -u <email> --no-limit True`",
|
||||
"text": "First-Start: Whitelist admin and remove subscription limit: `ente-upgrade-subscription <email>`",
|
||||
"type": "warning"
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user