Skip to content

Commit d7967d0

Browse files
committed
feat(install): add start & stop helper scripts
1 parent fd7a1fd commit d7967d0

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

install/install_nomad.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ GREEN='\033[1;32m' # Light Green.
3131
WHIPTAIL_TITLE="Project N.O.M.A.D Installation"
3232
MANAGEMENT_COMPOSE_FILE_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/management_compose.yaml"
3333
ENTRYPOINT_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/entrypoint.sh"
34+
START_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/start_nomad.sh"
35+
STOP_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/master/install/stop_nomad.sh"
3436
WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh"
3537

3638
script_option_debug='true'
@@ -274,6 +276,26 @@ download_entrypoint_script() {
274276
echo -e "${GREEN}#${RESET} entrypoint script downloaded successfully to $entrypoint_script_path.\\n"
275277
}
276278

279+
download_start_stop_scripts() {
280+
local start_script_path="${nomad_dir}/start_nomad.sh"
281+
local stop_script_path="${nomad_dir}/stop_nomad.sh"
282+
283+
echo -e "${YELLOW}#${RESET} Downloading start and stop scripts...\\n"
284+
if ! curl -fsSL "$START_SCRIPT_URL" -o "$start_script_path"; then
285+
echo -e "${RED}#${RESET} Failed to download the start script. Please check the URL and try again."
286+
exit 1
287+
fi
288+
chmod +x "$start_script_path"
289+
290+
if ! curl -fsSL "$STOP_SCRIPT_URL" -o "$stop_script_path"; then
291+
echo -e "${RED}#${RESET} Failed to download the stop script. Please check the URL and try again."
292+
exit 1
293+
fi
294+
chmod +x "$stop_script_path"
295+
296+
echo -e "${GREEN}#${RESET} Start and stop scripts downloaded successfully to $start_script_path and $stop_script_path.\\n"
297+
}
298+
277299
start_management_containers() {
278300
echo -e "${YELLOW}#${RESET} Starting management containers using docker compose...\\n"
279301
if ! sudo docker compose -f "${nomad_dir}/docker-compose-management.yml" up -d; then
@@ -294,6 +316,7 @@ get_local_ip() {
294316
success_message() {
295317
echo -e "${GREEN}#${RESET} Project N.O.M.A.D installation completed successfully!\\n"
296318
echo -e "${GREEN}#${RESET} Installation files are located at /opt/project-nomad\\n\n"
319+
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"
297320
echo -e "${GREEN}#${RESET} You can now access the management interface at http://localhost:8080 or http://${local_ip_address}:8080\\n"
298321
echo -e "${GREEN}#${RESET} Thank you for supporting Project N.O.M.A.D!\\n"
299322
}
@@ -318,6 +341,7 @@ ensure_docker_installed
318341
create_nomad_directory
319342
download_wait_for_it_script
320343
download_entrypoint_script
344+
download_start_stop_scripts
321345
download_management_compose_file
322346
start_management_containers
323347
get_local_ip

install/start_nomad.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
echo "Finding Project N.O.M.A.D containers..."
4+
5+
# -a to include all containers (running and stopped)
6+
containers=$(docker ps -a --filter "name=^nomad_" --format "{{.Names}}")
7+
8+
if [ -z "$containers" ]; then
9+
echo "No containers found for Project N.O.M.A.D. Is it installed?"
10+
exit 0
11+
fi
12+
13+
echo "Found the following containers:"
14+
echo "$containers"
15+
echo ""
16+
17+
for container in $containers; do
18+
echo "Starting container: $container"
19+
if docker start "$container"; then
20+
echo "✓ Successfully started $container"
21+
else
22+
echo "✗ Failed to start $container"
23+
fi
24+
echo ""
25+
done
26+
27+
echo "Finished initiating start of all Project N.O.M.A.D containers."

install/stop_nomad.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
echo "Finding running Docker containers for Project N.O.M.A.D..."
4+
5+
containers=$(docker ps --filter "name=^nomad_" --format "{{.Names}}")
6+
7+
if [ -z "$containers" ]; then
8+
echo "No running containers found for Project N.O.M.A.D."
9+
exit 0
10+
fi
11+
12+
echo "Found the following running containers:"
13+
echo "$containers"
14+
echo ""
15+
16+
for container in $containers; do
17+
echo "Gracefully stopping container: $container"
18+
if docker stop "$container"; then
19+
echo "✓ Successfully stopped $container"
20+
else
21+
echo "✗ Failed to stop $container"
22+
fi
23+
echo ""
24+
done
25+
26+
echo "Finished initiating graceful shutdown of all Project N.O.M.A.D containers."

0 commit comments

Comments
 (0)