Add comprehensive API documentation to Cloudron setup instructions
- Added detailed API endpoint information in SETUP-INSTRUCTIONS.md - Documented API usage with Ente CLI - Enhanced routing configuration for auth/cast/accounts apps - Updated to version 0.1.64
This commit is contained in:
93
admin-helper.sh
Normal file
93
admin-helper.sh
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/bin/bash
|
||||
# Ente Admin Helper Script for Cloudron
|
||||
# This script simplifies admin operations in the Cloudron terminal
|
||||
|
||||
MUSEUM_BIN="/app/data/ente/server/museum"
|
||||
|
||||
# Check if museum binary exists
|
||||
if [ ! -f "$MUSEUM_BIN" ]; then
|
||||
echo "Error: Museum binary not found at $MUSEUM_BIN"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to update user subscription
|
||||
update_subscription() {
|
||||
local user_email="$1"
|
||||
local storage_gb="$2"
|
||||
local valid_days="$3"
|
||||
|
||||
if [ -z "$user_email" ] || [ -z "$storage_gb" ] || [ -z "$valid_days" ]; then
|
||||
echo "Usage: $0 update-subscription <user-email> <storage-gb> <valid-days>"
|
||||
echo "Example: $0 update-subscription user@example.com 100 365"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Updating subscription for: $user_email"
|
||||
echo "Storage: ${storage_gb}GB"
|
||||
echo "Valid for: ${valid_days} days"
|
||||
|
||||
cd /app/data/ente/server
|
||||
|
||||
# Use environment variables for database connection
|
||||
export DB_HOST="$CLOUDRON_POSTGRESQL_HOST"
|
||||
export DB_PORT="$CLOUDRON_POSTGRESQL_PORT"
|
||||
export DB_NAME="$CLOUDRON_POSTGRESQL_DATABASE"
|
||||
export DB_USERNAME="$CLOUDRON_POSTGRESQL_USERNAME"
|
||||
export DB_PASSWORD="$CLOUDRON_POSTGRESQL_PASSWORD"
|
||||
|
||||
# Museum admin commands need specific syntax
|
||||
"$MUSEUM_BIN" admin update-subscription "$user_email" "$storage_gb" "$valid_days"
|
||||
}
|
||||
|
||||
# Function to get user details
|
||||
get_user_details() {
|
||||
local user_email="$1"
|
||||
|
||||
if [ -z "$user_email" ]; then
|
||||
echo "Usage: $0 get-user <user-email>"
|
||||
return 1
|
||||
fi
|
||||
|
||||
cd /app/data/ente/server
|
||||
|
||||
"$MUSEUM_BIN" admin get-user-details --user "$user_email"
|
||||
}
|
||||
|
||||
# Function to list all users
|
||||
list_users() {
|
||||
cd /app/data/ente/server
|
||||
|
||||
# Connect to PostgreSQL and list users
|
||||
PGPASSWORD="$CLOUDRON_POSTGRESQL_PASSWORD" psql \
|
||||
-h "$CLOUDRON_POSTGRESQL_HOST" \
|
||||
-p "$CLOUDRON_POSTGRESQL_PORT" \
|
||||
-U "$CLOUDRON_POSTGRESQL_USERNAME" \
|
||||
-d "$CLOUDRON_POSTGRESQL_DATABASE" \
|
||||
-c "SELECT email, storage_bonus, subscription_expiry FROM users ORDER BY email;"
|
||||
}
|
||||
|
||||
# Main command handler
|
||||
case "$1" in
|
||||
"update-subscription")
|
||||
update_subscription "$2" "$3" "$4"
|
||||
;;
|
||||
"get-user")
|
||||
get_user_details "$2"
|
||||
;;
|
||||
"list-users")
|
||||
list_users
|
||||
;;
|
||||
*)
|
||||
echo "Ente Admin Helper"
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " $0 update-subscription <user-email> <storage-gb> <valid-days>"
|
||||
echo " $0 get-user <user-email>"
|
||||
echo " $0 list-users"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 update-subscription user@example.com 100 365"
|
||||
echo " $0 get-user user@example.com"
|
||||
echo " $0 list-users"
|
||||
;;
|
||||
esac
|
Reference in New Issue
Block a user