mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-29 21:19:25 +02:00
- Add DOZZLE_PORT env var (optional, defaults to 9999) so the admin app knows the actual Dozzle port when it's been remapped - Pass DOZZLE_PORT through compose env → AdonisJS env → Inertia shared props → SettingsLayout sidebar link - Remove hardcoded '9999' from SettingsLayout.tsx - Fix update_nomad.sh success message to read admin port from the existing compose file instead of hardcoding 8080 - Also fixes the update script saying 'installation completed' instead of 'update completed'
159 lines
8.3 KiB
Bash
159 lines
8.3 KiB
Bash
#!/bin/bash
|
|
|
|
# Project N.O.M.A.D. Update Script
|
|
|
|
###################################################################################################################################################################################################
|
|
|
|
# Script | Project N.O.M.A.D. Update Script
|
|
# Version | 1.0.1
|
|
# Author | Crosstalk Solutions, LLC
|
|
# Website | https://crosstalksolutions.com
|
|
|
|
###################################################################################################################################################################################################
|
|
# #
|
|
# Color Codes #
|
|
# #
|
|
###################################################################################################################################################################################################
|
|
|
|
RESET='\033[0m'
|
|
YELLOW='\033[1;33m'
|
|
WHITE_R='\033[39m' # Same as GRAY_R for terminals with white background.
|
|
GRAY_R='\033[39m'
|
|
RED='\033[1;31m' # Light Red.
|
|
GREEN='\033[1;32m' # Light Green.
|
|
|
|
###################################################################################################################################################################################################
|
|
# #
|
|
# Functions #
|
|
# #
|
|
###################################################################################################################################################################################################
|
|
|
|
check_has_sudo() {
|
|
if sudo -n true 2>/dev/null; then
|
|
echo -e "${GREEN}#${RESET} User has sudo permissions.\\n"
|
|
else
|
|
echo "User does not have sudo permissions"
|
|
header_red
|
|
echo -e "${RED}#${RESET} This script requires sudo permissions to run. Please run the script with sudo.\\n"
|
|
echo -e "${RED}#${RESET} For example: sudo bash $(basename "$0")"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_is_bash() {
|
|
if [[ -z "$BASH_VERSION" ]]; then
|
|
header_red
|
|
echo -e "${RED}#${RESET} This script requires bash to run. Please run the script using bash.\\n"
|
|
echo -e "${RED}#${RESET} For example: bash $(basename "$0")"
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}#${RESET} This script is running in bash.\\n"
|
|
}
|
|
|
|
check_is_debian_based() {
|
|
if [[ ! -f /etc/debian_version ]]; then
|
|
header_red
|
|
echo -e "${RED}#${RESET} This script is designed to run on Debian-based systems only.\\n"
|
|
echo -e "${RED}#${RESET} Please run this script on a Debian-based system and try again."
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}#${RESET} This script is running on a Debian-based system.\\n"
|
|
}
|
|
|
|
get_update_confirmation(){
|
|
read -p "This script will update Project N.O.M.A.D. and its dependencies on your machine. No data loss is expected, but you should always back up your data before proceeding. Are you sure you want to continue? (y/n): " choice
|
|
case "$choice" in
|
|
y|Y )
|
|
echo -e "${GREEN}#${RESET} User chose to continue with the update."
|
|
;;
|
|
n|N )
|
|
echo -e "${RED}#${RESET} User chose not to continue with the update."
|
|
exit 0
|
|
;;
|
|
* )
|
|
echo "Invalid Response"
|
|
echo "User chose not to continue with the update."
|
|
exit 0
|
|
;;
|
|
esac
|
|
}
|
|
|
|
ensure_docker_installed_and_running() {
|
|
if ! command -v docker &> /dev/null; then
|
|
echo -e "${RED}#${RESET} Docker is not installed. This is unexpected, as Project N.O.M.A.D. requires Docker to run. Did you mean to use the install script instead of the update script?"
|
|
exit 1
|
|
fi
|
|
|
|
if ! systemctl is-active --quiet docker; then
|
|
echo -e "${RED}#${RESET} Docker is not running. Attempting to start Docker..."
|
|
sudo systemctl start docker
|
|
if ! systemctl is-active --quiet docker; then
|
|
echo -e "${RED}#${RESET} Failed to start Docker. Please start Docker and try again."
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
ensure_docker_compose_file_exists() {
|
|
if [ ! -f "/opt/project-nomad/compose.yml" ]; then
|
|
echo -e "${RED}#${RESET} compose.yml file not found. Please ensure it exists at /opt/project-nomad/compose.yml."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
force_recreate() {
|
|
echo -e "${YELLOW}#${RESET} Pulling the latest Docker images..."
|
|
if ! docker compose -p project-nomad -f /opt/project-nomad/compose.yml pull; then
|
|
echo -e "${RED}#${RESET} Failed to pull the latest Docker images. Please check your network connection and the Docker registry status, then try again."
|
|
exit 1
|
|
fi
|
|
|
|
echo -e "${YELLOW}#${RESET} Forcing recreation of containers..."
|
|
if ! docker compose -p project-nomad -f /opt/project-nomad/compose.yml up -d --force-recreate; then
|
|
echo -e "${RED}#${RESET} Failed to recreate containers. Please check the Docker logs for more details."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
get_local_ip() {
|
|
local_ip_address=$(hostname -I | awk '{print $1}')
|
|
if [[ -z "$local_ip_address" ]]; then
|
|
echo -e "${RED}#${RESET} Unable to determine local IP address. Please check your network configuration."
|
|
# Don't exit if we can't determine the local IP address, it's not critical for the installation
|
|
fi
|
|
}
|
|
|
|
success_message() {
|
|
# Read the admin port from the existing compose file (handles remapped ports)
|
|
local admin_port
|
|
admin_port=$(grep -A1 'container_name: nomad_admin' /opt/project-nomad/compose.yml | head -1)
|
|
# Fallback: parse the ports binding for the admin service
|
|
admin_port=$(awk '/container_name: nomad_admin/{found=1} found && /ports:/{getline; print; exit}' /opt/project-nomad/compose.yml 2>/dev/null | sed -n 's/.*"\([0-9]*\):.*/\1/p')
|
|
admin_port="${admin_port:-8080}"
|
|
|
|
echo -e "${GREEN}#${RESET} Project N.O.M.A.D update 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}/opt/project-nomad/start_nomad.sh${RESET}\\n"
|
|
echo -e "${GREEN}#${RESET} You can now access the management interface at http://localhost:${admin_port} or http://${local_ip_address}:${admin_port}\\n"
|
|
echo -e "${GREEN}#${RESET} Thank you for supporting Project N.O.M.A.D!\\n"
|
|
}
|
|
|
|
###################################################################################################################################################################################################
|
|
# #
|
|
# Main Script #
|
|
# #
|
|
###################################################################################################################################################################################################
|
|
|
|
# Pre-flight checks
|
|
check_is_debian_based
|
|
check_is_bash
|
|
check_has_sudo
|
|
|
|
# Main update
|
|
get_update_confirmation
|
|
ensure_docker_installed_and_running
|
|
ensure_docker_compose_file_exists
|
|
force_recreate
|
|
get_local_ip
|
|
success_message
|