@@ -12,7 +12,7 @@ PROJECT_DIR="$(dirname "$(dirname "$SCRIPT_DIR")")"
1212# Define variables for paths relative to the script's directory
1313FLASK_APP_PATH=" ${FLASK_APP_PATH:- $PROJECT_DIR / app.py} "
1414REQUIREMENTS_FILE=" ${REQUIREMENTS_FILE:- $PROJECT_DIR / requirements.txt} "
15- FLASK_PORT=" ${FLASK_PORT:- 5050 } "
15+ FLASK_PORT=" ${FLASK_PORT:- 5000 } "
1616LOG_FILE=" /home/$( whoami) /logs/systemdashboard_flask.log"
1717USERNAME=" $( whoami) "
1818
@@ -24,7 +24,6 @@ mkdir -p "$LOG_DIR"
2424CONDA_PATHS=(" /home/$USERNAME /miniconda3" " /home/$USERNAME /anaconda3" )
2525CONDA_FOUND=false
2626
27- # Find which Conda is installed and set $CONDA_EXECUTABLE
2827for CONDA_PATH in " ${CONDA_PATHS[@]} " ; do
2928 if [ -d " $CONDA_PATH " ]; then
3029 CONDA_FOUND=true
@@ -52,14 +51,13 @@ source "$CONDA_SETUP_SCRIPT"
5251CONDA_ENV_NAME=" dashboar"
5352
5453echo " Conda environment name: $CONDA_ENV_NAME "
55- echo $CONDA_EXECUTABLE
54+
5655# Check if the Conda environment exists and create it if not
5756if ! conda info --envs | awk ' {print $1}' | grep -q " ^$CONDA_ENV_NAME $" ; then
5857 log_message " Conda environment '$CONDA_ENV_NAME ' not found. Creating it..."
5958 conda create -n " $CONDA_ENV_NAME " python=3.10 -y
6059
6160 log_message " Activating Conda environment '$CONDA_ENV_NAME ' and installing requirements."
62- # Use `conda run` to execute commands in the environment
6361 conda run -n " $CONDA_ENV_NAME " pip install -r " $REQUIREMENTS_FILE "
6462else
6563 log_message " Activating existing Conda environment '$CONDA_ENV_NAME '."
@@ -74,17 +72,31 @@ export FLASK_ENV=development # or production
7472
7573# Check if Flask app is running
7674if ! pgrep -f " flask run --host=0.0.0.0 --port=$FLASK_PORT " > /dev/null; then
77- # git pull in FLASK_APP_PATH directory
78- current_dir=$( pwd)
79- cd " $PROJECT_DIR "
80- git init
81- git remote add origin https://github.com/codeperfectplus/SystemGuard.git
82- if ! git pull; then
83- log_message " Failed to pull updates from Git repository."
84- cd " $current_dir "
85- exit 1
86- fi
87- cd " $current_dir "
75+ log_message " Flask app is not running. Checking repository and starting it..."
76+
77+ # # Navigate to project directory
78+ # current_dir=$(pwd)
79+ # cd "$PROJECT_DIR" || exit
80+
81+ # # Initialize git and pull updates
82+ # if [ ! -d ".git" ]; then
83+ # git init
84+ # fi
85+ # git remote remove origin 2>/dev/null
86+ # git remote add origin https://github.com/codeperfectplus/SystemGuard.git
87+
88+ # # Apply stashed changes if any
89+ # if git stash list | grep -q 'stash@{0}'; then
90+ # log_message "Applying stashed changes..."
91+ # git stash pop
92+ # fi
93+ # # Fetch and pull the latest changes from the main branch
94+ # if ! git pull origin main; then
95+ # log_message "Failed to pull updates from Git repository."
96+ # cd "$current_dir" || exit
97+ # fi
98+
99+ # cd "$current_dir" || exit
88100
89101 log_message " Starting Flask app..."
90102 # Ensure environment activation and `flask` command
0 commit comments