#!/bin/bash # Dynamically determine the project directory PROJECT_DIR=$(dirname "$(realpath "$0")") echo "Setting up the project in $PROJECT_DIR..." # Step 1: Create a virtual environment if [ ! -d "$PROJECT_DIR/venv" ]; then echo "Creating a virtual environment..." python3 -m venv "$PROJECT_DIR/venv" else echo "Virtual environment already exists." fi # Step 2: Activate the virtual environment echo "Activating the virtual environment..." source "$PROJECT_DIR/venv/bin/activate" # Step 3: Install dependencies echo "Installing dependencies..." pip install --upgrade pip pip install -r "$PROJECT_DIR/requirements.txt" # Ensure Gunicorn is installed if ! "$PROJECT_DIR/venv/bin/gunicorn" --version &>/dev/null; then echo "Installing Gunicorn..." pip install gunicorn else echo "Gunicorn is already installed." fi # Step 4: Create a systemd service SERVICE_FILE="/etc/systemd/system/gogmilestone.service" if [ ! -f "$SERVICE_FILE" ]; then echo "Creating systemd service..." sudo bash -c "cat > $SERVICE_FILE" <