fix: Resolve API connection issues and add Quick Start features
- Fix API URL configuration to use relative paths (fixes localhost:8080 error) - Add Quick Start Wizard to dashboard for guided bucket/user setup - Create bash scripts for automated bucket and user creation - Add quickstart.sh for interactive setup experience - Update documentation with correct ports and new features - Improve user onboarding with step-by-step wizard This addresses: - Connection refused errors when creating users/policies - WebSocket connection issues - Need for easy one-step setup process - Port configuration clarity in documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Executable
+232
@@ -0,0 +1,232 @@
|
||||
#!/bin/bash
|
||||
|
||||
# MinIO WebUI Quickstart Script
|
||||
# This script helps you quickly set up MinIO WebUI with an initial bucket and user
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Default values
|
||||
MINIO_URL="${MINIO_URL:-http://localhost:9000}"
|
||||
WEBUI_URL="${WEBUI_URL:-http://localhost:7510}"
|
||||
FRONTEND_URL="${FRONTEND_URL:-http://localhost:3000}"
|
||||
|
||||
# Function to print colored output
|
||||
print_header() {
|
||||
echo -e "\n${BLUE}===================================================${NC}"
|
||||
echo -e "${BLUE}$1${NC}"
|
||||
echo -e "${BLUE}===================================================${NC}"
|
||||
}
|
||||
|
||||
print_status() {
|
||||
echo -e "${GREEN}[✓]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[✗]${NC} $1"
|
||||
}
|
||||
|
||||
print_info() {
|
||||
echo -e "${YELLOW}[i]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if a service is running
|
||||
check_service() {
|
||||
local name=$1
|
||||
local url=$2
|
||||
|
||||
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "200\|401\|403"; then
|
||||
print_status "$name is running at $url"
|
||||
return 0
|
||||
else
|
||||
print_error "$name is not accessible at $url"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to wait for service
|
||||
wait_for_service() {
|
||||
local name=$1
|
||||
local url=$2
|
||||
local max_attempts=30
|
||||
local attempt=0
|
||||
|
||||
print_info "Waiting for $name to start..."
|
||||
|
||||
while [ $attempt -lt $max_attempts ]; do
|
||||
if curl -s -o /dev/null -w "%{http_code}" "$url" | grep -q "200\|401\|403"; then
|
||||
print_status "$name is ready!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
sleep 2
|
||||
attempt=$((attempt + 1))
|
||||
echo -n "."
|
||||
done
|
||||
|
||||
echo
|
||||
print_error "$name failed to start within 60 seconds"
|
||||
return 1
|
||||
}
|
||||
|
||||
# Main quickstart function
|
||||
quickstart() {
|
||||
print_header "MinIO WebUI Quickstart"
|
||||
echo "This script will help you set up MinIO WebUI with initial data"
|
||||
echo
|
||||
|
||||
# Check if docker-compose is available
|
||||
if command -v docker-compose &> /dev/null; then
|
||||
print_info "Docker Compose detected"
|
||||
|
||||
# Ask if user wants to start services
|
||||
read -p "Do you want to start MinIO WebUI services? (y/n): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
print_info "Starting services with docker-compose..."
|
||||
docker-compose up -d
|
||||
|
||||
# Wait for services to start
|
||||
wait_for_service "MinIO" "$MINIO_URL"
|
||||
wait_for_service "Backend API" "$WEBUI_URL"
|
||||
wait_for_service "Frontend" "$FRONTEND_URL"
|
||||
fi
|
||||
else
|
||||
# Check if services are already running
|
||||
print_info "Checking if services are running..."
|
||||
|
||||
if ! check_service "Backend API" "$WEBUI_URL/api/health"; then
|
||||
print_error "Backend API is not running. Please start it first:"
|
||||
echo " cd backend && npm run dev"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
print_header "Initial Setup"
|
||||
|
||||
# Ask for admin credentials
|
||||
print_info "Please enter MinIO admin credentials"
|
||||
read -p "Admin username: " ADMIN_USER
|
||||
read -s -p "Admin password: " ADMIN_PASS
|
||||
echo
|
||||
echo
|
||||
|
||||
# Ask if user wants to create initial bucket and user
|
||||
read -p "Would you like to create an initial bucket and user? (y/n): " -n 1 -r
|
||||
echo
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
# Get setup preferences
|
||||
echo
|
||||
read -p "Enter bucket name (or press Enter for auto-generated): " BUCKET_NAME
|
||||
read -p "Enter username (or press Enter for auto-generated): " USER_NAME
|
||||
|
||||
echo
|
||||
print_info "Select access level:"
|
||||
echo " 1) Read Only"
|
||||
echo " 2) Write Only"
|
||||
echo " 3) Read & Write (default)"
|
||||
read -p "Choice [1-3]: " POLICY_CHOICE
|
||||
|
||||
case $POLICY_CHOICE in
|
||||
1) POLICY_TYPE="readonly" ;;
|
||||
2) POLICY_TYPE="writeonly" ;;
|
||||
*) POLICY_TYPE="readwrite" ;;
|
||||
esac
|
||||
|
||||
# Run the create-bucket-with-user script
|
||||
echo
|
||||
print_info "Creating bucket and user..."
|
||||
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
if [ -f "$SCRIPT_DIR/create-bucket-with-user.sh" ]; then
|
||||
"$SCRIPT_DIR/create-bucket-with-user.sh" \
|
||||
${BUCKET_NAME:+-b "$BUCKET_NAME"} \
|
||||
${USER_NAME:+-u "$USER_NAME"} \
|
||||
-p "$POLICY_TYPE" \
|
||||
-a "$WEBUI_URL" \
|
||||
--admin-user "$ADMIN_USER" \
|
||||
--admin-pass "$ADMIN_PASS"
|
||||
else
|
||||
print_error "create-bucket-with-user.sh script not found"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
print_header "Setup Complete!"
|
||||
echo
|
||||
print_info "MinIO WebUI is ready to use!"
|
||||
echo
|
||||
echo "Access the web interface at: ${FRONTEND_URL}"
|
||||
echo "API endpoint: ${WEBUI_URL}"
|
||||
echo "MinIO endpoint: ${MINIO_URL}"
|
||||
echo
|
||||
echo "Next steps:"
|
||||
echo " 1. Open ${FRONTEND_URL} in your browser"
|
||||
echo " 2. Log in with your MinIO admin credentials"
|
||||
echo " 3. Use the Quick Start button on the dashboard for guided setup"
|
||||
echo " 4. Explore buckets, users, and policies pages"
|
||||
echo
|
||||
print_status "Happy storage management! 🚀"
|
||||
}
|
||||
|
||||
# Function to show help
|
||||
show_help() {
|
||||
echo "MinIO WebUI Quickstart Script"
|
||||
echo
|
||||
echo "Usage: $0 [options]"
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help Show this help message"
|
||||
echo " --minio-url <url> MinIO endpoint (default: http://localhost:9000)"
|
||||
echo " --webui-url <url> WebUI API endpoint (default: http://localhost:7510)"
|
||||
echo " --frontend-url <url> Frontend URL (default: http://localhost:3000)"
|
||||
echo
|
||||
echo "Environment variables:"
|
||||
echo " MINIO_URL MinIO endpoint URL"
|
||||
echo " WEBUI_URL WebUI backend API URL"
|
||||
echo " FRONTEND_URL Frontend application URL"
|
||||
echo
|
||||
echo "Example:"
|
||||
echo " $0"
|
||||
echo " $0 --minio-url http://minio.local:9000"
|
||||
echo
|
||||
}
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
--minio-url)
|
||||
MINIO_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--webui-url)
|
||||
WEBUI_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
--frontend-url)
|
||||
FRONTEND_URL="$2"
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Run quickstart
|
||||
quickstart
|
||||
Reference in New Issue
Block a user