From c1274c7d002ca0acf1cd104121772d844d8b1197 Mon Sep 17 00:00:00 2001 From: Sushant Date: Mon, 22 Jul 2024 19:32:55 +0530 Subject: [PATCH] Sdded code Rsbbit suggestions --- .../linux/docker/deployment/deploy-local.sh | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/devops/linux/docker/deployment/deploy-local.sh b/devops/linux/docker/deployment/deploy-local.sh index ff6de8e9b..d39ffb102 100755 --- a/devops/linux/docker/deployment/deploy-local.sh +++ b/devops/linux/docker/deployment/deploy-local.sh @@ -74,56 +74,58 @@ install_sdkman_and_java_sbt_maven() { } hostname_setup() { - pushd "$JEMPI_HOME/devops/linux/docker/deployment/" + pushd "$JEMPI_HOME/devops/linux/docker/deployment/" || exit echo "Setting up hostname & IP address in Hosts file" source hostname-setup.sh - popd + popd || exit } run_enviroment_configuration_and_helper_script(){ # Navigate to environment configuration directory echo "Navigate to environment configuration directory" - pushd "$JEMPI_HOME/devops/linux/docker/conf/env/" + pushd "$JEMPI_HOME/devops/linux/docker/conf/env/" || exit # shellcheck source=path/to/create-env-linux-low-1.sh source "$JEMPI_ENV_CONFIGURATION" - popd + popd || exit # Running Docker helper scripts echo "Running Docker helper scripts " - pushd "$JEMPI_HOME/devops/linux/docker/helper/scripts/" + pushd "$JEMPI_HOME/devops/linux/docker/helper/scripts/" || exit source x-swarm-a-set-insecure-registries.sh - popd + popd || exit } - initialize_swarm(){ if docker info | grep -q "Swarm: active"; then echo "Docker Swarm is running." else echo "Docker Swarm is not running." echo "Initialize Swarm on node1" - pushd "$JEMPI_HOME/devops/linux/docker/deployment/common" + pushd "$JEMPI_HOME/devops/linux/docker/deployment/common" || exit source b-swarm-1-init-node1.sh - popd + popd || exit fi } + create_registry(){ - pushd "$JEMPI_HOME/devops/linux/docker/deployment/common" + pushd "$JEMPI_HOME/devops/linux/docker/deployment/common" || exit echo "Create Docker registry" source c-registry-1-create.sh - popd + popd || exit } + copy_ha_proxy(){ - pushd "$JEMPI_HOME/devops/linux/docker/" + pushd "$JEMPI_HOME/devops/linux/docker/" || exit source conf.env echo "Updating haproxy cfg file" cp conf/haproxy/*.* ${DATA_HAPROXY_DIR} - popd + popd || exit } + pull_docker_images_and_push_local(){ # Navigate to Docker directory - pushd "$JEMPI_HOME/devops/linux/docker/deployment/common" + pushd "$JEMPI_HOME/devops/linux/docker/deployment/common" || exit # Pull Docker images from hub echo "Pull Docker images from hub" source a-images-1-pull-from-hub.sh @@ -131,32 +133,35 @@ pull_docker_images_and_push_local(){ # Push Docker images to the registry echo "Push Docker images to the registry" source c-registry-2-push-hub-images.sh - popd + popd || exit } + build_all_stack_and_reboot(){ # Build and reboot the entire stack echo "Build and reboot the entire stack" - pushd "$JEMPI_HOME/devops/linux/docker/deployment/build_and_reboot" + pushd "$JEMPI_HOME/devops/linux/docker/deployment/build_and_reboot" || exit yes | source d-stack-1-build-all-reboot.sh - popd + popd || exit } + initialize_db_build_all_stack_and_reboot(){ echo "Create DB and Deploy" pushd "$JEMPI_HOME/devops/linux/docker/deployment/install_from_scratch" || exit yes | source d-stack-1-create-db-build-all-reboot.sh - popd + popd || exit } + restore_db(){ echo "Are you sure you want to restore the Dgraph and Postgres database? It will wipe all data and restore from backup (Ctrl+Y for Yes, any other key for No)" read -rsn1 -p "> " answer # Call the confirm function if [[ $answer == $'\x19' ]]; then - pushd "$JEMPI_HOME/devops/linux/docker/backup_restore" + pushd "$JEMPI_HOME/devops/linux/docker/backup_restore" || exit echo "Starting Dgraph database restore..." bash restore-dgraph-postgres.sh echo "Database Dgraph and Postgres restore completed." - popd + popd || exit else echo "Database restore cancelled. Moving ahead without restore." # Continue with the rest of your script