Setup fix
This commit is contained in:
51
setup.sh
51
setup.sh
@@ -59,17 +59,32 @@ check_docker() {
|
|||||||
install_dependencies() {
|
install_dependencies() {
|
||||||
print_status "Installing Python dependencies..."
|
print_status "Installing Python dependencies..."
|
||||||
|
|
||||||
|
# Detect Python environment
|
||||||
|
PYTHON_CMD="python3"
|
||||||
|
PIP_CMD="pip3"
|
||||||
|
|
||||||
|
# Check if we're in a virtual environment
|
||||||
|
if [[ -n "$VIRTUAL_ENV" ]]; then
|
||||||
|
print_status "Detected virtual environment: $VIRTUAL_ENV"
|
||||||
|
PIP_CMD="pip"
|
||||||
|
elif [[ -f "venv/bin/activate" ]]; then
|
||||||
|
print_status "Detected local virtual environment"
|
||||||
|
source venv/bin/activate
|
||||||
|
PIP_CMD="pip"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if pip is available
|
# Check if pip is available
|
||||||
if ! command -v pip3 &> /dev/null; then
|
if ! command -v $PIP_CMD &> /dev/null; then
|
||||||
print_error "pip3 is not installed. Please install pip3 first"
|
print_error "pip is not available. Please install pip first"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install requirements
|
# Install requirements with appropriate flags
|
||||||
if [[ -f "requirements.txt" ]]; then
|
if [[ -f "requirements.txt" ]]; then
|
||||||
pip3 install -r requirements.txt
|
$PIP_CMD install -r requirements.txt --break-system-packages || $PIP_CMD install -r requirements.txt
|
||||||
else
|
else
|
||||||
pip3 install flask flask-cors docker requests python-dotenv
|
$PIP_CMD install flask flask-cors docker requests python-dotenv --break-system-packages || \
|
||||||
|
$PIP_CMD install flask flask-cors docker requests python-dotenv
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print_status "Dependencies installed successfully"
|
print_status "Dependencies installed successfully"
|
||||||
@@ -101,9 +116,20 @@ setup_environment() {
|
|||||||
initialize_database() {
|
initialize_database() {
|
||||||
print_status "Initializing database..."
|
print_status "Initializing database..."
|
||||||
|
|
||||||
|
# Detect Python command
|
||||||
|
PYTHON_CMD="python3"
|
||||||
|
if [[ -n "$VIRTUAL_ENV" ]] || [[ -f "venv/bin/activate" ]]; then
|
||||||
|
if [[ -f "venv/bin/activate" ]]; then
|
||||||
|
source venv/bin/activate
|
||||||
|
PYTHON_CMD="python"
|
||||||
|
else
|
||||||
|
PYTHON_CMD="python"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Create database if it doesn't exist
|
# Create database if it doesn't exist
|
||||||
if [[ ! -f "dashboard.db" ]]; then
|
if [[ ! -f "dashboard.db" ]]; then
|
||||||
python3 -c "
|
$PYTHON_CMD -c "
|
||||||
import database
|
import database
|
||||||
db = database.DatabaseManager()
|
db = database.DatabaseManager()
|
||||||
db.init_db()
|
db.init_db()
|
||||||
@@ -132,11 +158,22 @@ kill_existing_processes() {
|
|||||||
launch_application() {
|
launch_application() {
|
||||||
print_status "Launching Docker Dashboard..."
|
print_status "Launching Docker Dashboard..."
|
||||||
|
|
||||||
|
# Detect Python command
|
||||||
|
PYTHON_CMD="python3"
|
||||||
|
if [[ -n "$VIRTUAL_ENV" ]] || [[ -f "venv/bin/activate" ]]; then
|
||||||
|
if [[ -f "venv/bin/activate" ]]; then
|
||||||
|
source venv/bin/activate
|
||||||
|
PYTHON_CMD="python"
|
||||||
|
else
|
||||||
|
PYTHON_CMD="python"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Create logs directory
|
# Create logs directory
|
||||||
mkdir -p logs
|
mkdir -p logs
|
||||||
|
|
||||||
# Launch the application in background
|
# Launch the application in background
|
||||||
nohup python3 api.py > logs/dashboard.log 2>&1 &
|
nohup $PYTHON_CMD api.py > logs/dashboard.log 2>&1 &
|
||||||
|
|
||||||
# Get the process ID
|
# Get the process ID
|
||||||
APP_PID=$!
|
APP_PID=$!
|
||||||
|
|||||||
Reference in New Issue
Block a user