mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
build: compose and install script updates for disk-collector sidecar
This commit is contained in:
parent
5113cc3eed
commit
a4e6a9bd9f
|
|
@ -38,7 +38,6 @@ START_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-
|
||||||
STOP_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/stop_nomad.sh"
|
STOP_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/stop_nomad.sh"
|
||||||
UPDATE_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/update_nomad.sh"
|
UPDATE_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/update_nomad.sh"
|
||||||
WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh"
|
WAIT_FOR_IT_SCRIPT_URL="https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh"
|
||||||
COLLECT_DISK_INFO_SCRIPT_URL="https://raw.githubusercontent.com/Crosstalk-Solutions/project-nomad/refs/heads/main/install/collect_disk_info.sh"
|
|
||||||
|
|
||||||
script_option_debug='true'
|
script_option_debug='true'
|
||||||
accepted_terms='false'
|
accepted_terms='false'
|
||||||
|
|
@ -381,12 +380,6 @@ create_nomad_directory(){
|
||||||
sudo touch "${NOMAD_DIR}/storage/logs/admin.log"
|
sudo touch "${NOMAD_DIR}/storage/logs/admin.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_disk_info_file() {
|
|
||||||
# Disk info file MUST be created before the admin container starts.
|
|
||||||
# Otherwise, Docker will assume we meant to mount a directory and will create an empty directory at the mount point
|
|
||||||
echo '{}' > /tmp/nomad-disk-info.json
|
|
||||||
}
|
|
||||||
|
|
||||||
download_management_compose_file() {
|
download_management_compose_file() {
|
||||||
local compose_file_path="${NOMAD_DIR}/compose.yml"
|
local compose_file_path="${NOMAD_DIR}/compose.yml"
|
||||||
|
|
||||||
|
|
@ -463,24 +456,6 @@ download_sidecar_files() {
|
||||||
echo -e "${GREEN}#${RESET} Sidecar updater script downloaded successfully to $sidecar_script_path.\\n"
|
echo -e "${GREEN}#${RESET} Sidecar updater script downloaded successfully to $sidecar_script_path.\\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
download_and_start_collect_disk_info_script() {
|
|
||||||
local collect_disk_info_script_path="${NOMAD_DIR}/collect_disk_info.sh"
|
|
||||||
|
|
||||||
echo -e "${YELLOW}#${RESET} Downloading collect_disk_info script...\\n"
|
|
||||||
if ! curl -fsSL "$COLLECT_DISK_INFO_SCRIPT_URL" -o "$collect_disk_info_script_path"; then
|
|
||||||
echo -e "${RED}#${RESET} Failed to download the collect_disk_info script. Please check the URL and try again."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
chmod +x "$collect_disk_info_script_path"
|
|
||||||
echo -e "${GREEN}#${RESET} collect_disk_info script downloaded successfully to $collect_disk_info_script_path.\\n"
|
|
||||||
|
|
||||||
# Start script in background and store PID for easy removal on uninstall
|
|
||||||
echo -e "${YELLOW}#${RESET} Starting collect_disk_info script in the background...\\n"
|
|
||||||
nohup bash "$collect_disk_info_script_path" > /dev/null 2>&1 &
|
|
||||||
echo $! > "${NOMAD_DIR}/nomad-collect-disk-info.pid"
|
|
||||||
echo -e "${GREEN}#${RESET} collect_disk_info script started successfully.\\n"
|
|
||||||
}
|
|
||||||
|
|
||||||
download_helper_scripts() {
|
download_helper_scripts() {
|
||||||
local start_script_path="${NOMAD_DIR}/start_nomad.sh"
|
local start_script_path="${NOMAD_DIR}/start_nomad.sh"
|
||||||
local stop_script_path="${NOMAD_DIR}/stop_nomad.sh"
|
local stop_script_path="${NOMAD_DIR}/stop_nomad.sh"
|
||||||
|
|
@ -609,7 +584,6 @@ download_wait_for_it_script
|
||||||
download_entrypoint_script
|
download_entrypoint_script
|
||||||
download_sidecar_files
|
download_sidecar_files
|
||||||
download_helper_scripts
|
download_helper_scripts
|
||||||
download_and_start_collect_disk_info_script
|
|
||||||
download_management_compose_file
|
download_management_compose_file
|
||||||
start_management_containers
|
start_management_containers
|
||||||
verify_gpu_setup
|
verify_gpu_setup
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ services:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/project-nomad/storage:/app/storage
|
- /opt/project-nomad/storage:/app/storage
|
||||||
- /tmp/nomad-disk-info.json:/app/storage/nomad-disk-info.json
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # Allows the admin service to communicate with the Host's Docker daemon
|
- /var/run/docker.sock:/var/run/docker.sock # Allows the admin service to communicate with the Host's Docker daemon
|
||||||
- ./entrypoint.sh:/usr/local/bin/entrypoint.sh
|
- ./entrypoint.sh:/usr/local/bin/entrypoint.sh
|
||||||
- ./wait-for-it.sh:/usr/local/bin/wait-for-it.sh
|
- ./wait-for-it.sh:/usr/local/bin/wait-for-it.sh
|
||||||
|
|
@ -95,6 +94,14 @@ services:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # Allows communication with the Host's Docker daemon
|
- /var/run/docker.sock:/var/run/docker.sock # Allows communication with the Host's Docker daemon
|
||||||
- /opt/project-nomad:/opt/project-nomad # Writable access required so the updater can set the correct image tag in compose.yml
|
- /opt/project-nomad:/opt/project-nomad # Writable access required so the updater can set the correct image tag in compose.yml
|
||||||
- nomad-update-shared:/shared # Shared volume for communication with admin container
|
- nomad-update-shared:/shared # Shared volume for communication with admin container
|
||||||
|
disk-collector:
|
||||||
|
image: ghcr.io/crosstalk-solutions/project-nomad-disk-collector:latest
|
||||||
|
pull_policy: always
|
||||||
|
container_name: nomad_disk_collector
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- /:/host:ro,rslave # Read-only view of host FS with rslave propagation so /sys and /proc submounts are visible
|
||||||
|
- /opt/project-nomad/storage:/storage
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
nomad-update-shared:
|
nomad-update-shared:
|
||||||
|
|
|
||||||
40
install/migrate-disk-collector.md
Normal file
40
install/migrate-disk-collector.md
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# Project N.O.M.A.D. — About the Disk Collector Migration Script
|
||||||
|
|
||||||
|
This script migrates your Project N.O.M.A.D. installation from the old host-based disk info collector to the new disk-collector sidecar. It modifies `/opt/project-nomad/compose.yml` to add the new service and remove the old bind mount, then restarts the full compose stack to apply the changes.
|
||||||
|
|
||||||
|
### Why the Migration?
|
||||||
|
The new disk-collector sidecar provides a more robust and scalable way to collect disk information from the host. It removes the original bind mount to `/tmp/nomad-disk-info.json`, which was fragile and prone to issues on host reboots.
|
||||||
|
|
||||||
|
The original host-based collector relied on a process running on the host that wrote disk info to a file, which was then read by the admin container via a bind mount. This approach had several drawbacks:
|
||||||
|
- The host process could fail or be killed, leading to stale or missing disk info.
|
||||||
|
- The bind mount to `/tmp/nomad-disk-info.json` was cleared on host reboots, causing Docker to create a directory at the mount point instead of a file.
|
||||||
|
- Necessitated a tighter coupling to the host, which would make more flexible future deployment options tougher to achieve.
|
||||||
|
|
||||||
|
The migration script automates the necessary changes to your compose configuration and ensures a smooth transition to the new architecture.
|
||||||
|
|
||||||
|
### Why does Nomad need the nomad-disk-info.json file?
|
||||||
|
Nomad uses the disk info stored and updated in `nomad-disk-info.json` to allow users to view disk usage and availability within the Nomad "Command Center". While not critical to the core functionality of Nomad, it provides a more pleasant experience for users with limited storage space and/or who aren't familiar with command-line tools and Linux management.
|
||||||
|
|
||||||
|
### Why a separate container?
|
||||||
|
The disk-collector runs in a separate container to isolate its functionality from the main admin container. This separation provides several benefits:
|
||||||
|
- **Stability**: If the disk-collector encounters an issue or crashes, it won't affect the main admin container and vice versa.
|
||||||
|
- **Security**: The main admin container already has significant host access via the Docker socket, storage directory, and host.docker.internal. Additionally, Nomad may add more features in the future that support multi-user environments and/or more network exposure, so isolating the disk-collector reduces the exposure of the host filesystem (even if read-only) to just the one container, which has a very limited scope of functionality and access.
|
||||||
|
- **Modularity**: Because having the host disk info is not a critical component of Nomad's core functionality, isolating it in a sidecar allows users who don't need/want the disk info features to simply not run that container, without impacting the main admin container or other services. It also allows for more flexible future development of the disk-collector without needing to modify the main admin container.
|
||||||
|
|
||||||
|
### What if I don't want to run the migration script?
|
||||||
|
No worries - you can replicate the changes manually by editing your `/opt/project-nomad/compose.yml` to add the new disk-collector service and remove the old bind mount from the admin service, then restarting your compose stack. The migration script just automates these steps and ensures they're done correctly, but the underlying changes are straightforward if you prefer to do it yourself. Just be sure to back up your `compose.yml` before making any changes.
|
||||||
|
|
||||||
|
Here's the disk-collector service configuration to add to your `compose.yml`:
|
||||||
|
|
||||||
|
```yml
|
||||||
|
disk-collector:
|
||||||
|
image: ghcr.io/crosstalk-solutions/project-nomad-disk-collector:latest
|
||||||
|
pull_policy: always
|
||||||
|
container_name: nomad_disk_collector
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- /:/host:ro,rslave # Read-only view of host FS with rslave propagation so /sys and /proc submounts are visible
|
||||||
|
- /opt/project-nomad/storage:/storage
|
||||||
|
```
|
||||||
|
|
||||||
|
and remove the `- /tmp/nomad-disk-info.json:/app/storage/nomad-disk-info.json` bind mount from the admin service volumes.
|
||||||
248
install/migrate-disk-collector.sh
Executable file
248
install/migrate-disk-collector.sh
Executable file
|
|
@ -0,0 +1,248 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Project N.O.M.A.D. — Disk Collector Migration Script
|
||||||
|
#
|
||||||
|
# Script | Project N.O.M.A.D. Disk Collector Migration Script
|
||||||
|
# Version | 1.0.0
|
||||||
|
# Author | Crosstalk Solutions, LLC
|
||||||
|
# Website | https://crosstalksolutions.com
|
||||||
|
#
|
||||||
|
# PURPOSE:
|
||||||
|
# One-time migration from the host-based disk info collector to the
|
||||||
|
# disk-collector Docker sidecar. The old approach used a nohup background
|
||||||
|
# process that wrote to /tmp/nomad-disk-info.json, which was bind-mounted
|
||||||
|
# into the admin container. This broke on host reboots because /tmp is
|
||||||
|
# cleared and Docker would create a directory at the mount point instead of a file.
|
||||||
|
#
|
||||||
|
# The new approach uses a disk-collector sidecar container that reads host
|
||||||
|
# disk info via the /:/host:ro,rslave bind-mount pattern (same pattern as Prometheus
|
||||||
|
# node-exporter, and no SYS_ADMIN or privileged capabilities required) and writes directly to
|
||||||
|
# /opt/project-nomad/storage/nomad-disk-info.json, which the admin container
|
||||||
|
# already reads via its existing storage bind-mount. Thus, no admin image update
|
||||||
|
# or new volume mounts required.
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Color Codes
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
RESET='\033[0m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
RED='\033[1;31m'
|
||||||
|
GREEN='\033[1;32m'
|
||||||
|
WHITE_R='\033[39m'
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Constants
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
NOMAD_DIR="/opt/project-nomad"
|
||||||
|
COMPOSE_FILE="${NOMAD_DIR}/compose.yml"
|
||||||
|
COMPOSE_PROJECT_NAME="project-nomad"
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Pre-flight Checks
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
check_is_bash() {
|
||||||
|
if [[ -z "$BASH_VERSION" ]]; then
|
||||||
|
echo -e "${RED}#${RESET} This script must be run with bash."
|
||||||
|
echo -e "${RED}#${RESET} Example: bash $(basename "$0")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}#${RESET} Running in bash.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_has_sudo() {
|
||||||
|
if sudo -n true 2>/dev/null; then
|
||||||
|
echo -e "${GREEN}#${RESET} Sudo permissions confirmed.\n"
|
||||||
|
else
|
||||||
|
echo -e "${RED}#${RESET} This script requires sudo permissions."
|
||||||
|
echo -e "${RED}#${RESET} Example: sudo bash $(basename "$0")"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
check_confirmation() {
|
||||||
|
echo -e "${YELLOW}#${RESET} This script migrates your Project N.O.M.A.D. installation from the"
|
||||||
|
echo -e "${YELLOW}#${RESET} host-based disk info collector to the new disk-collector sidecar."
|
||||||
|
echo -e "${YELLOW}#${RESET} It will modify compose.yml and restart the full compose stack"
|
||||||
|
echo -e "${YELLOW}#${RESET} to drop the old /tmp bind mount and start the disk-collector sidecar."
|
||||||
|
echo -e "${YELLOW}#${RESET} Please ensure you have a backup of your data before proceeding."
|
||||||
|
read -rp "Do you want to continue? (y/N) " response
|
||||||
|
if [[ ! "$response" =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "${RED}#${RESET} Aborting. No changes have been made."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}#${RESET} Confirmation received. Proceeding with migration...\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_docker_running() {
|
||||||
|
if ! command -v docker &>/dev/null; then
|
||||||
|
echo -e "${RED}#${RESET} Docker is not installed. Cannot proceed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! systemctl is-active --quiet docker; then
|
||||||
|
echo -e "${RED}#${RESET} Docker is not running. Please start Docker and try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}#${RESET} Docker is running.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_compose_file() {
|
||||||
|
if [[ ! -f "$COMPOSE_FILE" ]]; then
|
||||||
|
echo -e "${RED}#${RESET} compose.yml not found at ${COMPOSE_FILE}."
|
||||||
|
echo -e "${RED}#${RESET} Project N.O.M.A.D. does not appear to be installed or compose.yml is missing."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}#${RESET} Found compose.yml at ${COMPOSE_FILE}.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 1: Stop old host process
|
||||||
|
stop_old_host_process() {
|
||||||
|
local pid_file="${NOMAD_DIR}/nomad-collect-disk-info.pid"
|
||||||
|
|
||||||
|
if [[ -f "$pid_file" ]]; then
|
||||||
|
echo -e "${YELLOW}#${RESET} Stopping old collect-disk-info background process..."
|
||||||
|
local pid
|
||||||
|
pid=$(cat "$pid_file")
|
||||||
|
if kill "$pid" 2>/dev/null; then
|
||||||
|
echo -e "${GREEN}#${RESET} Process ${pid} stopped.\n"
|
||||||
|
else
|
||||||
|
echo -e "${YELLOW}#${RESET} Process ${pid} was not running (already stopped).\n"
|
||||||
|
fi
|
||||||
|
rm -f "$pid_file"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}#${RESET} No old collect-disk-info PID file found — nothing to stop.\n"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 2: Backup compose.yml
|
||||||
|
backup_compose_file() {
|
||||||
|
local backup="${COMPOSE_FILE}.bak.$(date +%Y%m%d%H%M%S)"
|
||||||
|
echo -e "${YELLOW}#${RESET} Backing up compose.yml to ${backup}..."
|
||||||
|
if cp "$COMPOSE_FILE" "$backup"; then
|
||||||
|
echo -e "${GREEN}#${RESET} Backup created at ${backup}.\n"
|
||||||
|
else
|
||||||
|
echo -e "${RED}#${RESET} Failed to create backup. Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 3: Remove old bind-mount from admin volumes
|
||||||
|
remove_old_bind_mount() {
|
||||||
|
if ! grep -q 'nomad-disk-info\.json' "$COMPOSE_FILE"; then
|
||||||
|
echo -e "${GREEN}#${RESET} Old /tmp/nomad-disk-info.json bind-mount not found — already removed.\n"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Removing old /tmp/nomad-disk-info.json bind-mount from admin volumes..."
|
||||||
|
sed -i '/\/tmp\/nomad-disk-info\.json:\/app\/storage\/nomad-disk-info\.json/d' "$COMPOSE_FILE"
|
||||||
|
|
||||||
|
if grep -q 'nomad-disk-info\.json' "$COMPOSE_FILE"; then
|
||||||
|
echo -e "${RED}#${RESET} Failed to remove old bind-mount from compose.yml. Please remove it manually:"
|
||||||
|
echo -e "${WHITE_R} - /tmp/nomad-disk-info.json:/app/storage/nomad-disk-info.json${RESET}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}#${RESET} Old bind-mount removed.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 4: Add disk-collector service block
|
||||||
|
add_disk_collector_service() {
|
||||||
|
if grep -q 'disk-collector:' "$COMPOSE_FILE"; then
|
||||||
|
echo -e "${GREEN}#${RESET} disk-collector service already present in compose.yml — skipping.\n"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Adding disk-collector service to compose.yml..."
|
||||||
|
|
||||||
|
# Insert the disk-collector service block before the top-level `volumes:` key
|
||||||
|
awk '/^volumes:/{
|
||||||
|
print " disk-collector:"
|
||||||
|
print " image: ghcr.io/crosstalk-solutions/project-nomad-disk-collector:latest"
|
||||||
|
print " pull_policy: always"
|
||||||
|
print " container_name: nomad_disk_collector"
|
||||||
|
print " restart: unless-stopped"
|
||||||
|
print " volumes:"
|
||||||
|
print " - /:/host:ro,rslave # Read-only view of host FS with rslave propagation so /sys and /proc submounts are visible"
|
||||||
|
print " - /opt/project-nomad/storage:/storage # Shared storage dir — disk info written here is read by the admin container"
|
||||||
|
print ""
|
||||||
|
}
|
||||||
|
{print}' "$COMPOSE_FILE" > "${COMPOSE_FILE}.tmp" && mv "${COMPOSE_FILE}.tmp" "$COMPOSE_FILE"
|
||||||
|
|
||||||
|
if ! grep -q 'disk-collector:' "$COMPOSE_FILE"; then
|
||||||
|
echo -e "${RED}#${RESET} Failed to add disk-collector service. Please add it manually before the top-level volumes: key."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo -e "${GREEN}#${RESET} disk-collector service added.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 5 — Pull new image and restart the full stack
|
||||||
|
# This will re-create the admin container and drop the old /tmp bind, and
|
||||||
|
# also starts the new disk-collector sidecar we just added to compose.yml
|
||||||
|
restart_stack() {
|
||||||
|
echo -e "${YELLOW}#${RESET} Pulling latest images (including disk-collector)..."
|
||||||
|
if ! docker compose -p "$COMPOSE_PROJECT_NAME" -f "$COMPOSE_FILE" pull; then
|
||||||
|
echo -e "${RED}#${RESET} Failed to pull images. Check your network connection."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}#${RESET} Images pulled.\n"
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Restarting stack..."
|
||||||
|
if ! docker compose -p "$COMPOSE_PROJECT_NAME" -f "$COMPOSE_FILE" up -d; then
|
||||||
|
echo -e "${RED}#${RESET} Failed to bring the stack up."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo -e "${GREEN}#${RESET} Stack restarted.\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Step 6: Verify
|
||||||
|
verify_disk_collector_running() {
|
||||||
|
sleep 3
|
||||||
|
if docker ps --filter "name=^nomad_disk_collector$" --filter "status=running" --format '{{.Names}}' | grep -qx "nomad_disk_collector"; then
|
||||||
|
echo -e "${GREEN}#${RESET} disk-collector container is running.\n"
|
||||||
|
else
|
||||||
|
echo -e "${RED}#${RESET} disk-collector container does not appear to be running."
|
||||||
|
echo -e "${RED}#${RESET} Check its logs with: docker logs nomad_disk_collector"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Main
|
||||||
|
echo -e "${GREEN}#########################################################################${RESET}"
|
||||||
|
echo -e "${GREEN}#${RESET} Project N.O.M.A.D. — Disk Collector Migration Script ${GREEN}#${RESET}"
|
||||||
|
echo -e "${GREEN}#########################################################################${RESET}\n"
|
||||||
|
|
||||||
|
check_is_bash
|
||||||
|
check_has_sudo
|
||||||
|
check_confirmation
|
||||||
|
check_docker_running
|
||||||
|
check_compose_file
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Step 1: Stopping old host process...\n"
|
||||||
|
stop_old_host_process
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Step 2: Backing up compose.yml...\n"
|
||||||
|
backup_compose_file
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Step 3: Removing old bind-mount...\n"
|
||||||
|
remove_old_bind_mount
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Step 4: Adding disk-collector service...\n"
|
||||||
|
add_disk_collector_service
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Step 5: Pulling images and restarting stack...\n"
|
||||||
|
restart_stack
|
||||||
|
|
||||||
|
echo -e "${YELLOW}#${RESET} Step 6: Verifying disk-collector is running...\n"
|
||||||
|
verify_disk_collector_running
|
||||||
|
|
||||||
|
echo -e "${GREEN}#########################################################################${RESET}"
|
||||||
|
echo -e "${GREEN}#${RESET} Migration completed successfully!"
|
||||||
|
echo -e "${GREEN}#${RESET}"
|
||||||
|
echo -e "${GREEN}#${RESET} The disk-collector sidecar is now running and will update disk info"
|
||||||
|
echo -e "${GREEN}#${RESET} every 2 minutes. The /api/system/info endpoint will return disk data"
|
||||||
|
echo -e "${GREEN}#${RESET} after the first collector write (~5 seconds after startup)."
|
||||||
|
echo -e "${GREEN}#${RESET}"
|
||||||
|
echo -e "${GREEN}#########################################################################${RESET}\n"
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
|
|
||||||
NOMAD_DIR="/opt/project-nomad"
|
NOMAD_DIR="/opt/project-nomad"
|
||||||
MANAGEMENT_COMPOSE_FILE="${NOMAD_DIR}/compose.yml"
|
MANAGEMENT_COMPOSE_FILE="${NOMAD_DIR}/compose.yml"
|
||||||
COLLECT_DISK_INFO_PID="/var/run/nomad-collect-disk-info.pid"
|
|
||||||
DISK_INFO_FILE="/tmp/nomad-disk-info.json"
|
|
||||||
|
|
||||||
###################################################################################################################################################################################################
|
###################################################################################################################################################################################################
|
||||||
# #
|
# #
|
||||||
|
|
@ -77,24 +75,6 @@ ensure_docker_installed() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
try_remove_disk_info_script() {
|
|
||||||
echo "Checking for running collect-disk-info script..."
|
|
||||||
if [ -f "$COLLECT_DISK_INFO_PID" ]; then
|
|
||||||
echo "Stopping collect-disk-info script..."
|
|
||||||
kill "$(cat "$COLLECT_DISK_INFO_PID")"
|
|
||||||
rm -f "$COLLECT_DISK_INFO_PID"
|
|
||||||
echo "collect-disk-info script stopped."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
try_remove_disk_info_file() {
|
|
||||||
if [ -f "$DISK_INFO_FILE" ]; then
|
|
||||||
echo "Removing disk info file..."
|
|
||||||
rm -f "$DISK_INFO_FILE"
|
|
||||||
echo "Disk info file removed."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
storage_cleanup() {
|
storage_cleanup() {
|
||||||
read -p "Do you want to delete the Project N.O.M.A.D. storage directory (${NOMAD_DIR})? This is best if you want to start a completely fresh install. This will PERMANENTLY DELETE all stored Nomad data and can't be undone! (y/N): " delete_dir_choice
|
read -p "Do you want to delete the Project N.O.M.A.D. storage directory (${NOMAD_DIR})? This is best if you want to start a completely fresh install. This will PERMANENTLY DELETE all stored Nomad data and can't be undone! (y/N): " delete_dir_choice
|
||||||
case "$delete_dir_choice" in
|
case "$delete_dir_choice" in
|
||||||
|
|
@ -135,12 +115,6 @@ uninstall_nomad() {
|
||||||
echo "Removing project-nomad_nomad-update-shared volume if it exists..."
|
echo "Removing project-nomad_nomad-update-shared volume if it exists..."
|
||||||
docker volume rm project-nomad_nomad-update-shared 2>/dev/null && echo "Volume removed." || echo "Volume already removed or not found."
|
docker volume rm project-nomad_nomad-update-shared 2>/dev/null && echo "Volume removed." || echo "Volume already removed or not found."
|
||||||
|
|
||||||
# Try to stop the collect-disk-info script if it's running
|
|
||||||
try_remove_disk_info_script
|
|
||||||
|
|
||||||
# Try to remove the disk info file if it exists
|
|
||||||
try_remove_disk_info_file
|
|
||||||
|
|
||||||
# Prompt user for storage cleanup and handle it if so
|
# Prompt user for storage cleanup and handle it if so
|
||||||
storage_cleanup
|
storage_cleanup
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user