mirror of
https://github.com/community-scripts/ProxmoxVED.git
synced 2026-04-05 08:54:03 -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
|
||||
|
||||
Reference in New Issue
Block a user