JCC-CSScheduler/executor/doc/execute.sh

52 lines
1.5 KiB
Bash

#!/bin/bash
# Set installation directory
MINICONDA_INSTALL_DIR="$HOME/miniconda3"
CONDA_ENV_NAME="py310env"
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
REQUIREMENTS_FILE="$SCRIPT_PATH/requirement.txt"
SCRIPT_DIR="$SCRIPT_PATH"
START_SCRIPT="start.sh"
# Miniconda installation URL (Linux 64-bit)
MINICONDA_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
# Download Miniconda installer
echo "Downloading Miniconda..."
wget -q $MINICONDA_URL -O /tmp/miniconda.sh
# Install Miniconda
echo "Installing Miniconda..."
bash /tmp/miniconda.sh -b -p $MINICONDA_INSTALL_DIR
# Initialize Conda
echo "Initializing Conda..."
$MINICONDA_INSTALL_DIR/bin/conda init
# Create Python 3.10 environment
echo "Creating Conda environment with Python 3.10..."
$MINICONDA_INSTALL_DIR/bin/conda create -n $CONDA_ENV_NAME python=3.10 -y
# Activate environment and install dependencies
echo "Activating Conda environment and installing dependencies..."
source $MINICONDA_INSTALL_DIR/bin/activate $CONDA_ENV_NAME
# Ensure requirements file exists
if [[ -f $REQUIREMENTS_FILE ]]; then
echo "Installing dependencies from $REQUIREMENTS_FILE..."
pip install -r $REQUIREMENTS_FILE
else
echo "Requirements file not found at $REQUIREMENTS_FILE"
fi
# Execute startup script
if [[ -f $START_SCRIPT ]]; then
echo "Executing startup script $START_SCRIPT..."
cd $SCRIPT_DIR
bash $START_SCRIPT
else
echo "Startup script not found at $START_SCRIPT"
fi
# Clean up temporary files
rm /tmp/miniconda.sh