]> PHS Git Server - phs-stack.git/commitdiff
Adding setup scripts.
authorcharleswrayjr <charleswrayjr@gmail.com>
Thu, 4 Sep 2025 02:27:49 +0000 (21:27 -0500)
committercharleswrayjr <charleswrayjr@gmail.com>
Thu, 4 Sep 2025 02:27:49 +0000 (21:27 -0500)
get-latest-code.sh [new file with mode: 0755]
init-docker.sh [new file with mode: 0755]
setup-volumes.sh [new file with mode: 0755]

diff --git a/get-latest-code.sh b/get-latest-code.sh
new file mode 100755 (executable)
index 0000000..186554d
--- /dev/null
@@ -0,0 +1,61 @@
+#!/bin/bash
+
+BRANCH=${1:-master}  # Use the first argument as the branch, default to 'master' if not provided
+DO_FETCH=${2:-nofetch}
+CURRENT_DIR=$(pwd)
+
+# Function to check branch and prompt
+check_branch_and_prompt() {
+    local dir=$1
+    
+    local display_dir=$dir
+    if [ "$dir" == "." ]; then
+        display_dir="phs-stack"
+    fi
+
+    cd $dir
+    current_branch=$(git rev-parse --abbrev-ref HEAD)
+    if [ "$current_branch" != "$BRANCH" ]; then
+        echo -e "\033[1m[$display_dir]\033[22m Warning: You are on branch '$current_branch' instead of '$BRANCH' in '$display_dir'."
+        echo -ne "\033[1m[$display_dir]\033[22m Press 'Enter' to checkout and pull '$BRANCH', 's' to skip, or 'q' / Ctrl-C to quit the script: "
+        while true; do
+            read -n 1 -s user_input
+            if [ "$user_input" == "s" ]; then
+                echo -e "\033[1m[$display_dir]\033[22m Skipping $dir..."
+                echo
+                cd $CURRENT_DIR
+                return
+            elif [ "$user_input" == "q" ]; then
+                echo
+                echo -e "\033[1m[$display_dir]\033[22m Cancelling..."
+                exit 1
+            elif [ "$user_input" == "" ]; then
+                break
+            else
+                echo -ne "\033[1m[$display_dir]\033[22m Invalid input. Press 'Enter' to checkout and pull '$BRANCH', 's' to skip, or 'q' / Ctrl-C to quit the script: "
+            fi
+        done
+    fi
+    
+    echo
+    if [ "$DO_FETCH" == "fetch" ]; then
+        echo git fetch
+        git fetch
+    fi
+    echo git checkout $BRANCH --
+    git checkout $BRANCH --
+    echo git pull origin $BRANCH
+    git pull origin $BRANCH;
+    cd $CURRENT_DIR
+    echo
+}
+
+echo -e "Checking out branch \033[1m'$BRANCH'\033[22m on all volumes, including the phs-stack directory..."
+echo
+check_branch_and_prompt .
+check_branch_and_prompt volumes/phs-api
+#check_branch_and_prompt volumes/phs-app
+check_branch_and_prompt volumes/phs-employee
+#check_branch_and_prompt volumes/phs-customer
+check_branch_and_prompt volumes/phs-admin
+echo All done.
\ No newline at end of file
diff --git a/init-docker.sh b/init-docker.sh
new file mode 100755 (executable)
index 0000000..ca5481f
--- /dev/null
@@ -0,0 +1,41 @@
+#!/bin/bash
+phs_env="DEV"
+imagever_db="1.3"
+imagever_api="1.8"
+imagever_ionic="1.6"
+imagever_jobs="1.3"
+
+# Make sure we are logged into Docker Hub
+docker login
+
+host=$(hostname)
+if [ "$host" == "wrayhome" ]; then
+   echo "Starting Production Stack"
+   phs_env="PRODUCTION"
+else
+   echo "Starting Dev Stack"
+fi 
+
+echo "Enter module to restart, e.g. jobs, or api, or all to restart the entire stack"
+read module
+
+echo "Enter S to stop the module(s) and not restart it, else just hit enter"
+read stop_only
+
+if [ "$module" == "all" ]; then
+   echo "Make sure stack is shut down.  Safely ignore errors if stack is not even up"
+   PHS_ENV=$phs_env IMAGEVER_JOBS=$imagever_jobs IMAGEVER_API=$imagever_api IMAGEVER_DB=$imagever_db IMAGEVER_IONIC=$imagever_ionic docker-compose down --remove-orphans
+
+   if [ "$stop_only" == "" ]; then
+      echo "Bringing up the stack."
+      PHS_ENV=$phs_env IMAGEVER_JOBS=$imagever_jobs IMAGEVER_API=$imagever_api IMAGEVER_DB=$imagever_db IMAGEVER_IONIC=$imagever_ionic docker-compose up -d --build;
+   fi
+else
+   echo "Shutting down $module..."
+   PHS_ENV=$phs_env IMAGEVER_JOBS=$imagever_jobs IMAGEVER_API=$imagever_api IMAGEVER_DB=$imagever_db IMAGEVER_IONIC=$imagever_ionic docker-compose rm -s -v -f $module
+
+   if [ "$stop_only" == "" ]; then
+      echo "Bringing up $module..."
+      PHS_ENV=$phs_env IMAGEVER_JOBS=$imagever_jobs IMAGEVER_API=$imagever_api IMAGEVER_DB=$imagever_db IMAGEVER_IONIC=$imagever_ionic docker-compose up -d --build $module;
+   fi
+fi
diff --git a/setup-volumes.sh b/setup-volumes.sh
new file mode 100755 (executable)
index 0000000..c6d3ec0
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+if [ -d "./volumes" ] 
+then
+   echo "volumes folder exists.  Good"
+else
+   mkdir volumes
+   cd volumes
+   echo "Created volumes folder."
+   echo "Getting all code..."
+   git clone git@github.com:charleswrayjr/clr-api.git
+   git clone git@github.com:charleswrayjr/clr-employee.git
+fi