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
+214
@@ -0,0 +1,214 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "======================================"
|
||||
echo "MinIO WebUI Deployment Script"
|
||||
echo "======================================"
|
||||
echo ""
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Check if running as root (not recommended)
|
||||
if [ "$EUID" -eq 0 ]; then
|
||||
echo -e "${YELLOW}Warning: Running as root is not recommended${NC}"
|
||||
read -p "Continue anyway? (y/N): " CONTINUE_ROOT
|
||||
if [[ ! "$CONTINUE_ROOT" =~ ^[Yy]$ ]]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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 docker
|
||||
check_command docker-compose
|
||||
check_command mc
|
||||
|
||||
echo -e "${GREEN}✓ All prerequisites installed${NC}"
|
||||
|
||||
# Check .env file
|
||||
if [ ! -f .env ]; then
|
||||
echo -e "${RED}Error: .env file not found. Please run setup.sh first.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Deployment options
|
||||
echo ""
|
||||
echo "Deployment Options"
|
||||
echo "=================="
|
||||
echo "1. Quick deployment (docker-compose)"
|
||||
echo "2. Production deployment with SSL"
|
||||
echo "3. Update existing deployment"
|
||||
echo "4. Stop deployment"
|
||||
echo ""
|
||||
read -p "Select option (1-4): " DEPLOY_OPTION
|
||||
|
||||
case $DEPLOY_OPTION in
|
||||
1)
|
||||
echo ""
|
||||
echo "Starting quick deployment..."
|
||||
echo "============================"
|
||||
|
||||
# Build and start containers
|
||||
docker-compose build
|
||||
docker-compose up -d
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Deployment completed!${NC}"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo "- Frontend: http://localhost"
|
||||
echo "- Backend API: http://localhost:3000"
|
||||
echo ""
|
||||
docker-compose ps
|
||||
;;
|
||||
|
||||
2)
|
||||
echo ""
|
||||
echo "Production Deployment with SSL"
|
||||
echo "=============================="
|
||||
|
||||
# Check for SSL certificates
|
||||
if [ ! -f ssl/cert.pem ] || [ ! -f ssl/key.pem ]; then
|
||||
echo -e "${YELLOW}SSL certificates not found.${NC}"
|
||||
echo "Options:"
|
||||
echo "1. Use Let's Encrypt (recommended for production)"
|
||||
echo "2. Use existing certificates"
|
||||
echo "3. Generate self-signed certificate (development only)"
|
||||
read -p "Select option (1-3): " SSL_OPTION
|
||||
|
||||
case $SSL_OPTION in
|
||||
1)
|
||||
read -p "Enter your domain name: " DOMAIN
|
||||
read -p "Enter your email: " EMAIL
|
||||
|
||||
# Install certbot if not present
|
||||
if ! command -v certbot &> /dev/null; then
|
||||
echo "Installing certbot..."
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
brew install certbot
|
||||
else
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y certbot
|
||||
fi
|
||||
fi
|
||||
|
||||
# Generate Let's Encrypt certificate
|
||||
sudo certbot certonly --standalone \
|
||||
-d $DOMAIN \
|
||||
--non-interactive \
|
||||
--agree-tos \
|
||||
--email $EMAIL
|
||||
|
||||
# Copy certificates
|
||||
sudo cp /etc/letsencrypt/live/$DOMAIN/fullchain.pem ssl/cert.pem
|
||||
sudo cp /etc/letsencrypt/live/$DOMAIN/privkey.pem ssl/key.pem
|
||||
sudo chown $(whoami):$(whoami) ssl/*.pem
|
||||
;;
|
||||
|
||||
2)
|
||||
read -p "Path to certificate file: " CERT_PATH
|
||||
read -p "Path to private key file: " KEY_PATH
|
||||
cp $CERT_PATH ssl/cert.pem
|
||||
cp $KEY_PATH ssl/key.pem
|
||||
;;
|
||||
|
||||
3)
|
||||
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"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Build and start with proxy profile
|
||||
echo "Building containers..."
|
||||
docker-compose build
|
||||
|
||||
echo "Starting services..."
|
||||
docker-compose --profile proxy up -d
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Production deployment completed!${NC}"
|
||||
echo ""
|
||||
echo "Services:"
|
||||
echo "- HTTPS: https://localhost"
|
||||
echo "- HTTP (redirects to HTTPS): http://localhost"
|
||||
echo ""
|
||||
docker-compose ps
|
||||
;;
|
||||
|
||||
3)
|
||||
echo ""
|
||||
echo "Updating deployment..."
|
||||
echo "====================="
|
||||
|
||||
# Pull latest changes
|
||||
read -p "Pull latest changes from git? (y/N): " PULL_GIT
|
||||
if [[ "$PULL_GIT" =~ ^[Yy]$ ]]; then
|
||||
git pull
|
||||
fi
|
||||
|
||||
# Rebuild containers
|
||||
echo "Rebuilding containers..."
|
||||
docker-compose build
|
||||
|
||||
# Restart services
|
||||
echo "Restarting services..."
|
||||
docker-compose down
|
||||
docker-compose up -d
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Update completed!${NC}"
|
||||
docker-compose ps
|
||||
;;
|
||||
|
||||
4)
|
||||
echo ""
|
||||
echo "Stopping deployment..."
|
||||
echo "===================="
|
||||
|
||||
docker-compose down
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}✓ Services stopped${NC}"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo -e "${RED}Invalid option${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Show logs option
|
||||
echo ""
|
||||
read -p "View logs? (y/N): " VIEW_LOGS
|
||||
if [[ "$VIEW_LOGS" =~ ^[Yy]$ ]]; then
|
||||
echo ""
|
||||
echo "Showing logs (Ctrl+C to exit)..."
|
||||
echo "================================"
|
||||
docker-compose logs -f
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Deployment script completed!"
|
||||
echo ""
|
||||
echo "Useful commands:"
|
||||
echo "- View logs: docker-compose logs -f"
|
||||
echo "- View specific service: docker-compose logs -f backend"
|
||||
echo "- Restart services: docker-compose restart"
|
||||
echo "- Stop services: docker-compose down"
|
||||
echo "- Remove everything: docker-compose down -v"
|
||||
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