-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·75 lines (61 loc) · 2.01 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·75 lines (61 loc) · 2.01 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
#!/bin/bash
# Navigate to the project directory
cd "$(dirname "$0")"
# --- Step 1: Virtual Environment and Dependencies ---
echo "Step 1: Setting up virtual environment and installing dependencies..."
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
source venv/bin/activate
pip install -r requirements.txt
# --- Step 2: Docker Services ---
echo "Step 2: Starting MySQL and Adminer services..."
cd mysql_docker
# Check if docker-compose is available
if ! command -v docker-compose &> /dev/null
then
# Check if docker compose (with a space) is available
if ! command -v docker compose &> /dev/null
then
echo "Error: Neither 'docker-compose' nor 'docker compose' could be found."
echo "Please install Docker Compose and try again."
exit 1
fi
# Use "docker compose" syntax
docker compose up -d
else
# Use "docker-compose" syntax
docker-compose up -d
fi
cd ..
# --- Step 3: Wait for MySQL to be ready ---
echo "Step 3: Waiting for MySQL database to be ready..."
# Read .env file to get database credentials
set -o allexport
source .env
set +o allexport
retries=30
while ! mysql -h $DB_HOST -P $DB_PORT -u $DB_USER -p$DB_PASSWORD -e "SELECT 1" &> /dev/null; do
retries=$((retries-1))
if [ $retries -eq 0 ]; then
echo "Error: MySQL database is not ready after 30 seconds. Please check the docker logs in the mysql_docker directory."
exit 1
fi
echo "Waiting for MySQL... ($retries retries left)"
sleep 1
done
echo "MySQL is ready."
# --- Step 4: Initialize Database and Create Admin ---
echo "Step 4: Initializing database schema and creating admin user..."
flask init-db
flask create-admin
# --- Completion ---
echo "
Setup Complete!
Next Steps:
1. The MySQL database and Adminer are running in the background.
2. You can now start the main application by running: ./run.sh
3. Access the web application at http://<your_server_ip>:5000
4. Access the Adminer database manager at http://<your_server_ip>:8080
"