Browse Source

Added branch support in configuration and improved installation logic

- Added branch variables for all repositories (TICKETS_BRANCH, BACKEND_BRANCH, etc.) to the bin/install.cfg.example file.
- The bin/install.sh script now uses branch variables from the config instead of hardcoding:
  * Replaced hardcoded branches with dynamic parameters $..._BRANCH
  * Simplified the structure of update_repository calls with alignment
- Added interactive check for the existence of install.cfg:
  * Implemented 3 input attempts with handling for invalid responses
  * Automatic creation of the file from the example upon confirmation
- Added forced termination after creating settings_vars.py
  with a reminder about the need to configure PostgreSQL
- Improved error handling with explicit exit codes (exit 0/1)

These changes allow for flexible branch configuration through the config file
and make the installation process more user-friendly through checks and prompts.
blezz-tech 1 month ago
parent
commit
e97a0fdd3c
2 changed files with 60 additions and 23 deletions
  1. 24 2
      bin/install.cfg.example
  2. 36 21
      bin/install.sh

+ 24 - 2
bin/install.cfg.example

@@ -2,11 +2,33 @@
 TICKETS="https://git.sharix-app.org/ShariX_Open/sharix-open-tickets.git"
 BACKEND="https://git.sharix-app.org/ShariX_Open/sharix-open-backend.git"
 CONFIG="https://git.sharix-app.org/ShariX_Open/sharix-open-config.git"
+
+#use sharix open user model for integration with sharix platform
+USER_MODEL="https://git.sharix-app.org/ShariX_Open/sharix-open-user-model.git"
+
 #design-template should be forked if you need to change design in web interface
 DESIGN_TEMPLATE="https://git.sharix-app.org/ShariX_Open/sharix-open-webapp-design-template.git"
+
 #most likely webservice-running should be forked from Open
 WEBSERVICE_RUNNING="https://git.sharix-app.org/ShariX_Open/sharix-open-webservice-running.git"
+
 #landing should be forked or re-made for any new service
 LANDING="https://git.sharix-app.org/ShariX_Open/sharix-open-landing.git"
-#use sharix open user model for integration with sharix platform
-USER_MODEL="https://git.sharix-app.org/ShariX_Open/sharix-open-user-model.git"
+
+
+#Branches for repos
+TICKETS_BRANCH="master"
+BACKEND_BRANCH="metasynced_module"
+CONFIG_BRANCH="master"
+
+USER_MODEL_BRANCH="master"
+
+WEBSERVICE_RUNNING_BRANCH="unstable"
+
+DESIGN_TEMPLATE_BRANCH="unstable"
+
+LANDING_BRANCH="landing_module"
+
+
+#Create test users
+TEST_USERS=true

+ 36 - 21
bin/install.sh

@@ -1,19 +1,33 @@
 #!/bin/bash
 
-source bin/install.cfg
+if [ -f bin/install.cfg ]; then
+    echo "File install.cfg already exists"
+else
+    attempts=0
+    max_attempts=3
+
+    while [ $attempts -lt $max_attempts ]; do
+        read -p "File install.cfg does not exist. Do you want to create it? (y/n) [default: y]: " answer
+
+        if [[ "$answer" == "y" || "$answer" == "Y" ]]; then
+            cp bin/install.cfg.example bin/install.cfg
+            echo "File install.cfg was successfully created"
+            exit 0
+        elif [[ "$answer" == "n" || "$answer" == "N" ]]; then
+            echo "Error: You need to create the file manually and then continue."
+            echo "cp /bin/install.cfg.example to /bin/install.cfg with your settings."
+            exit 1
+        else
+            attempts=$((attempts + 1))
+            echo "Invalid input. Please enter 'y' or 'n'. Attempt $attempts of $max_attempts."
+        fi
+    done
 
-# Command line argument handler
-while [[ "$#" -gt 0 ]]; do
-    case $1 in
-        --test-users) 
-            export TEST_USERS=true
-            echo "Test users flag set"
-            shift ;;
-        *) 
-            echo "Unknown parameter: $1"
-            shift ;;
-    esac
-done
+    echo "Exceeded maximum attempts. Exiting."
+    exit 1
+fi
+
+source bin/install.cfg
 
 # Function to check if a repository exists and perform git pull or git clone
 update_repository() {
@@ -35,14 +49,13 @@ update_repository() {
 }
 
 # Update repositories
-update_repository "$TICKETS" "tickets" "master"
-update_repository "$BACKEND" "dbsynce" "metasynced_module"
-update_repository "$CONFIG" "conf" "master"
-update_repository "$DESIGN_TEMPLATE" "design_template" "unstable"
-update_repository "$WEBSERVICE_RUNNING" "webservice_running" "unstable"
-update_repository "$LANDING" "landing" "landing_module"
-update_repository "$USER_MODEL" "user" "master"
-update_repository "$WEBAPP_BASE" "design_template" "unstable"
+update_repository "$TICKETS"            "tickets"            "$TICKETS_BRANCH"
+update_repository "$BACKEND"            "dbsynce"            "$BACKEND_BRANCH"
+update_repository "$CONFIG"             "conf"               "$CONFIG_BRANCH"
+update_repository "$DESIGN_TEMPLATE"    "design_template"    "$DESIGN_TEMPLATE_BRANCH"
+update_repository "$WEBSERVICE_RUNNING" "webservice_running" "$WEBSERVICE_RUNNING_BRANCH"
+update_repository "$LANDING"            "landing"            "$LANDING_BRANCH"
+update_repository "$USER_MODEL"         "user"               "$USER_MODEL_BRANCH"
 git pull
 
 # Create a Python virtual environment and activate it
@@ -59,6 +72,8 @@ if [ -f core/settings_vars.py ]; then
 else
     cp core/_settings_vars.py core/settings_vars.py
     echo "File settings_vars.py was successfully created"
+    echo "Write the connection settings for the PostgreSQL database."
+    exit
 fi
 
 # Run Django migrations and other commands