-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql-demo.sh
More file actions
executable file
·112 lines (98 loc) · 3.84 KB
/
mysql-demo.sh
File metadata and controls
executable file
·112 lines (98 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# S3-Compatible API Java with MySQL Demo Script
echo "🚀 S3-Compatible API Java with MySQL Demo"
echo "==========================================="
echo "📋 This demo shows how to run S3-proxy-java with MySQL database"
echo ""
# Check if MySQL is available
if command -v mysql >/dev/null 2>&1; then
echo "✅ MySQL client found"
else
echo "❌ MySQL client not found. Please install MySQL or MariaDB client"
echo " Ubuntu/Debian: sudo apt-get install mysql-client"
echo " CentOS/RHEL: sudo yum install mysql"
echo " macOS: brew install mysql-client"
exit 1
fi
echo ""
echo "📦 Building the project..."
mvn clean package -DskipTests
# Check if build was successful
if [ $? -eq 0 ]; then
echo "✅ Build successful!"
echo ""
echo "🔧 MySQL Configuration"
echo "======================"
echo ""
echo "Before running the service with MySQL, please ensure:"
echo "1. MySQL server is running"
echo "2. Database 's3proxy' exists (or will be auto-created)"
echo "3. Set the following environment variables:"
echo ""
echo " export SPRING_PROFILES_ACTIVE=mysql"
echo " export MYSQL_USERNAME=your_username"
echo " export MYSQL_PASSWORD=your_password"
echo ""
# Check for environment variables
if [ -z "$MYSQL_USERNAME" ] || [ -z "$MYSQL_PASSWORD" ]; then
echo "⚠️ MySQL credentials not found in environment variables"
echo " Using default values - you may need to adjust them"
echo ""
export MYSQL_USERNAME=${MYSQL_USERNAME:-root}
export MYSQL_PASSWORD=${MYSQL_PASSWORD:-}
export SPRING_PROFILES_ACTIVE=mysql
echo " Current settings:"
echo " - Username: $MYSQL_USERNAME"
echo " - Password: [${MYSQL_PASSWORD:+SET}${MYSQL_PASSWORD:-NOT SET}]"
echo ""
else
echo "✅ MySQL credentials found in environment"
export SPRING_PROFILES_ACTIVE=mysql
fi
echo "🗄️ Database Setup Commands"
echo "=========================="
echo "If you need to create the database and user, run:"
echo ""
echo "mysql -u root -p << EOF"
echo "CREATE DATABASE IF NOT EXISTS s3proxy CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
echo "CREATE USER IF NOT EXISTS 's3proxy'@'%' IDENTIFIED BY 'secure_password';"
echo "GRANT ALL PRIVILEGES ON s3proxy.* TO 's3proxy'@'%';"
echo "FLUSH PRIVILEGES;"
echo "EOF"
echo ""
echo "🏃♂️ Starting S3-Compatible API Service with MySQL..."
echo "Service will be available at: http://localhost:8080"
echo ""
echo "📊 Database features:"
echo " ✅ Automatic table creation with optimized indexes"
echo " ✅ Connection pooling for performance"
echo " ✅ UTF-8 character set support"
echo " ✅ Foreign key constraints for data integrity"
echo ""
echo "🔗 S3-Compatible endpoints:"
echo " PUT /{bucket}/{key}"
echo " GET /{bucket}/{key}"
echo " DELETE /{bucket}/{key}"
echo " HEAD /{bucket}"
echo " HEAD /{bucket}/{key}"
echo ""
echo "💡 Make sure you also have MinIO running:"
echo " - MINIO_ENDPOINT=${MINIO_ENDPOINT:-http://localhost:9000}"
echo " - MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}"
echo " - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}"
echo ""
echo "📚 See MYSQL_CONFIGURATION.md for detailed MySQL setup instructions"
echo ""
echo "🔄 To switch back to H2 database:"
echo " unset SPRING_PROFILES_ACTIVE"
echo " # or export SPRING_PROFILES_ACTIVE=h2"
echo ""
echo "Press Ctrl+C to stop the service"
echo "Starting in 3 seconds..."
sleep 3
# Run the application with MySQL profile
java -jar target/s3-proxy-java-0.1.0.jar
else
echo "❌ Build failed! Please check the errors above."
exit 1
fi