Skip to content

Commit 658283f

Browse files
feat: bash script created
1 parent c8a4666 commit 658283f

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

dashboard.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ FLASK_APP_PATH="${FLASK_APP_PATH:-$SCRIPT_DIR/app.py}"
88
REQUIREMENTS_FILE="${REQUIREMENTS_FILE:-$SCRIPT_DIR/requirements.txt}"
99
FLASK_PORT="${FLASK_PORT:-5050}"
1010
LOG_FILE="${SCRIPT_DIR}/my_script.log"
11+
USERNAME="$(whoami)"
12+
CONDA_PATH="/home/$USERNAME/miniconda3"
1113

12-
# Full path to Conda setup script
13-
CONDA_SETUP_SCRIPT="/home/deepak/miniconda3/etc/profile.d/conda.sh"
14+
# Find the Conda setup script dynamically
15+
if [ -z "$CONDA_PATH" ]; then
16+
echo "Conda not found in PATH. Ensure Conda is installed and added to PATH." >> "$LOG_FILE"
17+
exit 1
18+
fi
19+
20+
# Derive the path to the Conda setup script
21+
CONDA_SETUP_SCRIPT="/home/$USERNAME/miniconda3/etc/profile.d/conda.sh"
1422

1523
# Check if Conda setup script exists
1624
if [ ! -f "$CONDA_SETUP_SCRIPT" ]; then
@@ -21,14 +29,20 @@ fi
2129
# Initialize Conda
2230
source "$CONDA_SETUP_SCRIPT"
2331

24-
# Activate the Conda environment
32+
# Define Conda environment name
2533
CONDA_ENV_NAME="systemdashboard"
26-
if conda env list | grep -q "$CONDA_ENV_NAME"; then
34+
35+
# Check if the Conda environment exists and create it if not
36+
if ! conda env list | grep -q "$CONDA_ENV_NAME"; then
37+
echo "Conda environment '$CONDA_ENV_NAME' not found. Creating it..." >> "$LOG_FILE"
38+
conda create -n "$CONDA_ENV_NAME" python=3.10 -y
2739
echo "Activating Conda environment '$CONDA_ENV_NAME'" >> "$LOG_FILE"
2840
conda activate "$CONDA_ENV_NAME"
41+
echo "Installing required packages" >> "$LOG_FILE"
42+
pip install -r "$REQUIREMENTS_FILE"
2943
else
30-
echo "Conda environment '$CONDA_ENV_NAME' not found." >> "$LOG_FILE"
31-
exit 1
44+
echo "Activating existing Conda environment '$CONDA_ENV_NAME'" >> "$LOG_FILE"
45+
conda activate "$CONDA_ENV_NAME"
3246
fi
3347

3448
# Continue with the rest of your script

0 commit comments

Comments
 (0)