Initial commit: MinIO WebUI - Complete implementation
- Backend: Express.js API with MinIO CLI integration - Frontend: React with Material-UI for non-technical users - Features: Bucket management, user creation, storage monitoring - Security: JWT auth, IP filtering, encrypted passwords - Docker support for easy deployment - Automated weekly storage reports - Setup and deployment scripts included
This commit is contained in:
Executable
+224
@@ -0,0 +1,224 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "======================================"
|
||||
echo "MinIO WebUI Setup Script"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check prerequisites
|
||||
check_command() {
|
||||
if ! command -v $1 &> /dev/null; then
|
||||
echo -e "${RED}Error: $1 is required but not installed.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking prerequisites..."
|
||||
check_command node
|
||||
check_command npm
|
||||
check_command mc
|
||||
|
||||
echo -e "${GREEN}✓ All prerequisites installed${NC}"
|
||||
echo ""
|
||||
|
||||
# Create .env file from template
|
||||
if [ ! -f .env ]; then
|
||||
echo "Creating .env file..."
|
||||
cp .env.example .env
|
||||
echo -e "${GREEN}✓ Created .env file${NC}"
|
||||
else
|
||||
echo -e "${YELLOW}! .env file already exists${NC}"
|
||||
fi
|
||||
|
||||
# Generate secure passwords
|
||||
echo ""
|
||||
echo "Generating secure credentials..."
|
||||
ADMIN_PASSWORD=$(openssl rand -base64 24)
|
||||
JWT_SECRET=$(openssl rand -base64 64 | tr -d '\n')
|
||||
|
||||
echo ""
|
||||
echo -e "${YELLOW}Generated Admin Password:${NC} $ADMIN_PASSWORD"
|
||||
echo -e "${YELLOW}Please save this password securely!${NC}"
|
||||
echo ""
|
||||
|
||||
# Hash the password using Node.js
|
||||
echo "Hashing admin password..."
|
||||
ADMIN_HASH=$(node -e "
|
||||
const bcrypt = require('bcrypt');
|
||||
bcrypt.hash('$ADMIN_PASSWORD', 12).then(hash => console.log(hash));
|
||||
" 2>/dev/null)
|
||||
|
||||
if [ -z "$ADMIN_HASH" ]; then
|
||||
# If bcrypt is not available, install it temporarily
|
||||
echo "Installing bcrypt temporarily..."
|
||||
npm install bcrypt --no-save
|
||||
ADMIN_HASH=$(node -e "
|
||||
const bcrypt = require('bcrypt');
|
||||
bcrypt.hash('$ADMIN_PASSWORD', 12).then(hash => console.log(hash));
|
||||
")
|
||||
npm uninstall bcrypt --no-save
|
||||
fi
|
||||
|
||||
# Update .env file
|
||||
echo "Updating .env file..."
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
sed -i '' "s|ADMIN_PASSWORD_HASH=.*|ADMIN_PASSWORD_HASH=$ADMIN_HASH|" .env
|
||||
sed -i '' "s|JWT_SECRET=.*|JWT_SECRET=$JWT_SECRET|" .env
|
||||
else
|
||||
# Linux
|
||||
sed -i "s|ADMIN_PASSWORD_HASH=.*|ADMIN_PASSWORD_HASH=$ADMIN_HASH|" .env
|
||||
sed -i "s|JWT_SECRET=.*|JWT_SECRET=$JWT_SECRET|" .env
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ Updated .env file with secure credentials${NC}"
|
||||
|
||||
# Configure MinIO connection
|
||||
echo ""
|
||||
echo "MinIO Configuration"
|
||||
echo "=================="
|
||||
read -p "Enter MinIO alias name (default: kopiaminio): " MINIO_ALIAS
|
||||
MINIO_ALIAS=${MINIO_ALIAS:-kopiaminio}
|
||||
|
||||
read -p "Enter MinIO endpoint (e.g., https://minio.example.com): " MINIO_ENDPOINT
|
||||
read -p "Enter MinIO access key: " MINIO_ACCESS_KEY
|
||||
read -s -p "Enter MinIO secret key: " MINIO_SECRET_KEY
|
||||
echo ""
|
||||
|
||||
# Update .env with MinIO settings
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s|DEFAULT_MINIO_ALIAS=.*|DEFAULT_MINIO_ALIAS=$MINIO_ALIAS|" .env
|
||||
sed -i '' "s|MINIO_ENDPOINT=.*|MINIO_ENDPOINT=$MINIO_ENDPOINT|" .env
|
||||
sed -i '' "s|MINIO_ACCESS_KEY=.*|MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY|" .env
|
||||
sed -i '' "s|MINIO_SECRET_KEY=.*|MINIO_SECRET_KEY=$MINIO_SECRET_KEY|" .env
|
||||
else
|
||||
sed -i "s|DEFAULT_MINIO_ALIAS=.*|DEFAULT_MINIO_ALIAS=$MINIO_ALIAS|" .env
|
||||
sed -i "s|MINIO_ENDPOINT=.*|MINIO_ENDPOINT=$MINIO_ENDPOINT|" .env
|
||||
sed -i "s|MINIO_ACCESS_KEY=.*|MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY|" .env
|
||||
sed -i "s|MINIO_SECRET_KEY=.*|MINIO_SECRET_KEY=$MINIO_SECRET_KEY|" .env
|
||||
fi
|
||||
|
||||
# Configure IP restrictions
|
||||
echo ""
|
||||
echo "IP Restriction Configuration"
|
||||
echo "==========================="
|
||||
read -p "Enable IP restrictions? (y/N): " ENABLE_IP
|
||||
if [[ "$ENABLE_IP" =~ ^[Yy]$ ]]; then
|
||||
read -p "Enter allowed IPs (comma-separated, e.g., 192.168.1.0/24,10.0.0.5): " ALLOWED_IPS
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s|ENABLE_IP_RESTRICTION=.*|ENABLE_IP_RESTRICTION=true|" .env
|
||||
sed -i '' "s|ALLOWED_IPS=.*|ALLOWED_IPS=$ALLOWED_IPS|" .env
|
||||
else
|
||||
sed -i "s|ENABLE_IP_RESTRICTION=.*|ENABLE_IP_RESTRICTION=true|" .env
|
||||
sed -i "s|ALLOWED_IPS=.*|ALLOWED_IPS=$ALLOWED_IPS|" .env
|
||||
fi
|
||||
else
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s|ENABLE_IP_RESTRICTION=.*|ENABLE_IP_RESTRICTION=false|" .env
|
||||
else
|
||||
sed -i "s|ENABLE_IP_RESTRICTION=.*|ENABLE_IP_RESTRICTION=false|" .env
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure email (optional)
|
||||
echo ""
|
||||
echo "Email Configuration (for automated reports)"
|
||||
echo "=========================================="
|
||||
read -p "Configure email for reports? (y/N): " CONFIGURE_EMAIL
|
||||
if [[ "$CONFIGURE_EMAIL" =~ ^[Yy]$ ]]; then
|
||||
read -p "SMTP Host: " SMTP_HOST
|
||||
read -p "SMTP Port (default: 587): " SMTP_PORT
|
||||
SMTP_PORT=${SMTP_PORT:-587}
|
||||
read -p "SMTP User: " SMTP_USER
|
||||
read -s -p "SMTP Password: " SMTP_PASS
|
||||
echo ""
|
||||
read -p "Report recipient email: " REPORT_RECIPIENT
|
||||
read -p "Report sender email: " REPORT_SENDER
|
||||
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s|SMTP_HOST=.*|SMTP_HOST=$SMTP_HOST|" .env
|
||||
sed -i '' "s|SMTP_PORT=.*|SMTP_PORT=$SMTP_PORT|" .env
|
||||
sed -i '' "s|SMTP_USER=.*|SMTP_USER=$SMTP_USER|" .env
|
||||
sed -i '' "s|SMTP_PASS=.*|SMTP_PASS=$SMTP_PASS|" .env
|
||||
sed -i '' "s|REPORT_RECIPIENT=.*|REPORT_RECIPIENT=$REPORT_RECIPIENT|" .env
|
||||
sed -i '' "s|REPORT_SENDER=.*|REPORT_SENDER=$REPORT_SENDER|" .env
|
||||
else
|
||||
sed -i "s|SMTP_HOST=.*|SMTP_HOST=$SMTP_HOST|" .env
|
||||
sed -i "s|SMTP_PORT=.*|SMTP_PORT=$SMTP_PORT|" .env
|
||||
sed -i "s|SMTP_USER=.*|SMTP_USER=$SMTP_USER|" .env
|
||||
sed -i "s|SMTP_PASS=.*|SMTP_PASS=$SMTP_PASS|" .env
|
||||
sed -i "s|REPORT_RECIPIENT=.*|REPORT_RECIPIENT=$REPORT_RECIPIENT|" .env
|
||||
sed -i "s|REPORT_SENDER=.*|REPORT_SENDER=$REPORT_SENDER|" .env
|
||||
fi
|
||||
fi
|
||||
|
||||
# Install dependencies
|
||||
echo ""
|
||||
echo "Installing dependencies..."
|
||||
echo "========================="
|
||||
|
||||
# Backend dependencies
|
||||
echo "Installing backend dependencies..."
|
||||
cd backend
|
||||
npm ci
|
||||
cd ..
|
||||
echo -e "${GREEN}✓ Backend dependencies installed${NC}"
|
||||
|
||||
# Frontend dependencies
|
||||
echo "Installing frontend dependencies..."
|
||||
cd frontend
|
||||
npm ci
|
||||
echo -e "${GREEN}✓ Frontend dependencies installed${NC}"
|
||||
|
||||
# Build frontend
|
||||
echo ""
|
||||
echo "Building frontend..."
|
||||
npm run build
|
||||
cd ..
|
||||
echo -e "${GREEN}✓ Frontend built successfully${NC}"
|
||||
|
||||
# Create necessary directories
|
||||
echo ""
|
||||
echo "Creating directories..."
|
||||
mkdir -p logs temp ssl
|
||||
echo -e "${GREEN}✓ Directories created${NC}"
|
||||
|
||||
# Generate self-signed SSL certificate for development
|
||||
echo ""
|
||||
read -p "Generate self-signed SSL certificate for development? (y/N): " GEN_SSL
|
||||
if [[ "$GEN_SSL" =~ ^[Yy]$ ]]; then
|
||||
echo "Generating self-signed SSL certificate..."
|
||||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
|
||||
-keyout ssl/key.pem \
|
||||
-out ssl/cert.pem \
|
||||
-subj "/C=US/ST=State/L=City/O=Organization/CN=localhost"
|
||||
echo -e "${GREEN}✓ SSL certificate generated${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "======================================"
|
||||
echo -e "${GREEN}Setup completed successfully!${NC}"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
echo "Important information:"
|
||||
echo "---------------------"
|
||||
echo -e "Admin Password: ${YELLOW}$ADMIN_PASSWORD${NC}"
|
||||
echo -e "Please save this password securely!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "-----------"
|
||||
echo "1. Review and adjust settings in .env file"
|
||||
echo "2. Start the application:"
|
||||
echo " - Development: npm run dev (in both backend and frontend folders)"
|
||||
echo " - Production: docker-compose up -d"
|
||||
echo "3. Access the WebUI at http://localhost:3000 (or configured port)"
|
||||
echo ""
|
||||
echo "For more information, see the README.md file."
|
||||
Reference in New Issue
Block a user