From d7967d0d74ebaea4cdb3249c6bacf11888781940 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Fri, 25 Jul 2025 23:06:09 -0700 Subject: [PATCH] feat(install): add start & stop helper scripts --- install/install_nomad.sh | 24 ++++++++++++++++++++++++ install/start_nomad.sh | 27 +++++++++++++++++++++++++++ install/stop_nomad.sh | 26 ++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 install/start_nomad.sh create mode 100644 install/stop_nomad.sh diff --git a/install/install_nomad.sh b/install/install_nomad.sh index c76c118..4ed783f 100644 --- a/install/install_nomad.sh +++ b/install/install_nomad.sh @@ -31,6 +31,8 @@ GREEN='\033[1;32m' # Light Green. WHIPTAIL_TITLE="Project N.O.M.A.D Installation" MANAGEMENT_COMPOSE_FILE_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/management_compose.yaml" ENTRYPOINT_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/entrypoint.sh" +START_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/start_nomad.sh" +STOP_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/stop_nomad.sh" WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh" script_option_debug='true' @@ -274,6 +276,26 @@ download_entrypoint_script() { echo -e "${GREEN}#${RESET} entrypoint script downloaded successfully to $entrypoint_script_path.\\n" } +download_start_stop_scripts() { + local start_script_path="${nomad_dir}/start_nomad.sh" + local stop_script_path="${nomad_dir}/stop_nomad.sh" + + echo -e "${YELLOW}#${RESET} Downloading start and stop scripts...\\n" + if ! curl -fsSL "$START_SCRIPT_URL" -o "$start_script_path"; then + echo -e "${RED}#${RESET} Failed to download the start script. Please check the URL and try again." + exit 1 + fi + chmod +x "$start_script_path" + + if ! curl -fsSL "$STOP_SCRIPT_URL" -o "$stop_script_path"; then + echo -e "${RED}#${RESET} Failed to download the stop script. Please check the URL and try again." + exit 1 + fi + chmod +x "$stop_script_path" + + echo -e "${GREEN}#${RESET} Start and stop scripts downloaded successfully to $start_script_path and $stop_script_path.\\n" +} + start_management_containers() { echo -e "${YELLOW}#${RESET} Starting management containers using docker compose...\\n" if ! sudo docker compose -f "${nomad_dir}/docker-compose-management.yml" up -d; then @@ -294,6 +316,7 @@ get_local_ip() { success_message() { echo -e "${GREEN}#${RESET} Project N.O.M.A.D installation completed successfully!\\n" echo -e "${GREEN}#${RESET} Installation files are located at /opt/project-nomad\\n\n" + echo -e "${GREEN}#${RESET} Project N.O.M.A.D's Command Center should automatically start whenever your device reboots. However, if you need to start it manually, you can always do so by running: ${WHITE_R}${nomad_dir}/start_nomad.sh${RESET}\\n" echo -e "${GREEN}#${RESET} You can now access the management interface at http://localhost:8080 or http://${local_ip_address}:8080\\n" echo -e "${GREEN}#${RESET} Thank you for supporting Project N.O.M.A.D!\\n" } @@ -318,6 +341,7 @@ ensure_docker_installed create_nomad_directory download_wait_for_it_script download_entrypoint_script +download_start_stop_scripts download_management_compose_file start_management_containers get_local_ip diff --git a/install/start_nomad.sh b/install/start_nomad.sh new file mode 100644 index 0000000..f17f805 --- /dev/null +++ b/install/start_nomad.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +echo "Finding Project N.O.M.A.D containers..." + +# -a to include all containers (running and stopped) +containers=$(docker ps -a --filter "name=^nomad_" --format "{{.Names}}") + +if [ -z "$containers" ]; then + echo "No containers found for Project N.O.M.A.D. Is it installed?" + exit 0 +fi + +echo "Found the following containers:" +echo "$containers" +echo "" + +for container in $containers; do + echo "Starting container: $container" + if docker start "$container"; then + echo "✓ Successfully started $container" + else + echo "✗ Failed to start $container" + fi + echo "" +done + +echo "Finished initiating start of all Project N.O.M.A.D containers." diff --git a/install/stop_nomad.sh b/install/stop_nomad.sh new file mode 100644 index 0000000..5d46289 --- /dev/null +++ b/install/stop_nomad.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +echo "Finding running Docker containers for Project N.O.M.A.D..." + +containers=$(docker ps --filter "name=^nomad_" --format "{{.Names}}") + +if [ -z "$containers" ]; then + echo "No running containers found for Project N.O.M.A.D." + exit 0 +fi + +echo "Found the following running containers:" +echo "$containers" +echo "" + +for container in $containers; do + echo "Gracefully stopping container: $container" + if docker stop "$container"; then + echo "✓ Successfully stopped $container" + else + echo "✗ Failed to stop $container" + fi + echo "" +done + +echo "Finished initiating graceful shutdown of all Project N.O.M.A.D containers."