From 56237a855737c5ed0cb342c6e616810391496086 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:34:19 +0000 Subject: [PATCH 2/7] Update installer to always use Docker Compose v2 for Debian 11-13 Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com> --- README.md | 26 ++++--- hblink3-docker-install.sh | 155 ++++++++++++++++++++++++-------------- 2 files changed, 113 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index c2af85a..df32bc5 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # HBlink3 Docker Installer -**Version 1.5.0** - Debian 10 / 11 / 12 / 13 (Trixie) Support!! +**Version 1.5.0** - Debian 11 / 12 / 13 (Trixie) Support!! ======= -This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debian 10, 11, 12, and 13 (Trixie). +This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debian 11, 12, and 13 (Trixie). -**Note:** Debian 12 (Bookworm) and 13 (Trixie) support has been added with proper PEP 668 compliant Python package management using virtual environments, and docker-compose compatibility. HBMonv2 now runs in an isolated Python virtual environment on Debian 12+. See [CHANGELOG.md](CHANGELOG.md) for version history and updates. +**Important:** This installer requires Docker Compose v2 (provided by the docker-compose-plugin package). The legacy docker-compose v1 standalone package is not supported. The installer automatically installs Docker Engine and Docker Compose v2 from the official Docker repositories. + +**Note:** Debian 12 (Bookworm) and 13 (Trixie) support has been added with proper PEP 668 compliant Python package management using virtual environments. HBMonv2 now runs in an isolated Python virtual environment on Debian 12+. See [CHANGELOG.md](CHANGELOG.md) for version history and updates. ![HBlink](img/HBLINK_logoV1.png "HBlink") @@ -29,7 +31,9 @@ This installer includes all the usual libs and packages including docker, apache install this on a 'clean machine'. The script is destructive and is not designed to be used on an exisiting machine that has other software on it! YOU HAVE BEEN WARNED! ### Prerequisite -The host system must be running Debian 10, 11, 12, or 13 (Trixie). The installer has been tested on these Debian versions and works on most architectures. The system requires, at a minimum; 1 core, 512mb of ram, the required spec to run docker and additional processes! The system must be up-to-date and have Git installed. You can install Git from the CLI. +The host system must be running Debian 11, 12, or 13 (Trixie). **Debian 10 is no longer supported** due to the requirement for Docker Compose v2. The installer has been tested on these Debian versions and works on most architectures. The system requires, at a minimum; 1 core, 512mb of ram, the required spec to run docker and additional processes! The system must be up-to-date and have Git installed. You can install Git from the CLI. + +**Docker Compose v2:** This installer exclusively uses Docker Compose v2 from the official Docker repositories. The docker-compose-plugin package is automatically installed, providing the `docker compose` command (note the space). A compatibility wrapper is also created to support the legacy `docker-compose` command (with hyphen) for backward compatibility with existing scripts. Note* If you get Locale error(s) (LC_CTYPE=UTF-8, which is wrong) can happen when you login over ssh from a Mac to a linux box, and your terminal automatically sets environment variables. There's a checkbox for that. Uncheck it, and you're good to go. @@ -38,7 +42,7 @@ Make sure your system is up-to-date and pull Git from the apt repo. apt-get install -y git ``` ### Installation -1. Preferably a clean Debian 10, 11, 12, or 13 (Trixie) system. Make sure your system is up to date with the latest apt repository database. You must be super user "root" to run this installer successfully. +1. Preferably a clean Debian 11, 12, or 13 (Trixie) system. **Debian 10 is no longer supported.** Make sure your system is up to date with the latest apt repository database. You must be super user "root" to run this installer successfully. ```sh apt update sudo su @@ -105,15 +109,15 @@ The uninstall script will: ```sh cd /etc/hblink3 ``` -10. You can only interact with HBlink3 in this directory. Use the following commands to interact with the installation. We use -docker-compose to run the docker container! +10. You can only interact with HBlink3 in this directory. Use the following commands to interact with the installation. This installer uses Docker Compose v2 (docker-compose-plugin): ```sh -docker-compose up -d -docker-compose down -docker-compose restart -docker-compose pull +docker compose up -d # Start containers (Docker Compose v2) +docker compose down # Stop containers +docker compose restart # Restart containers +docker compose pull # Update images sudo nano docker-compose.yml ``` +**Note:** The legacy `docker-compose` command (with hyphen) also works via a compatibility wrapper that forwards to `docker compose`, but using `docker compose` (with space) is recommended as the official Docker Compose v2 syntax. 11. Edit your configuration before deployment! ```sh nano hblink.cfg diff --git a/hblink3-docker-install.sh b/hblink3-docker-install.sh index 79ee003..34ec281 100755 --- a/hblink3-docker-install.sh +++ b/hblink3-docker-install.sh @@ -22,18 +22,19 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ################################################################################## # -# A tool to install HBlink3 Docker with Debian 10-13 / Ubuntu 20.04 support. +# A tool to install HBlink3 Docker with Debian 11, 12, and 13 support. # This essentially is a HBlink3 server fully installed with dashboard ready to go. -# Step 1: Install Debian 10, 11, 12, or 13 (Trixie) or Ubuntu 20.04 and make sure it has internet and is up to date. +# Step 1: Install Debian 11, 12, or 13 (Trixie) and make sure it has internet and is up to date. # Step 2: Run this script on the computer. # Step 3: Reboot after installation. -# This is a docker version and you can use the following comands to control / maintain your server +# This is a docker version and you can use the following commands to control / maintain your server # cd /etc/hblink3 -# docker-compose up -d (starts the hblink3 docker container) -# docker-compose down (shuts down the hblink container and stops the service) -# docker-compose pull (updates the container to the latest docker image) +# docker compose up -d (starts the hblink3 docker container) - Note: uses Docker Compose v2 +# docker compose down (shuts down the hblink container and stops the service) +# docker compose pull (updates the container to the latest docker image) +# For backward compatibility, docker-compose (with hyphen) is also supported via a wrapper script # systemctl |stop|start|restart|status hbmon (controls the HBMonv2 dash service) -# logs can be found in var/log/hblink or docker comand "docker container logs hblink" +# logs can be found in var/log/hblink or docker command "docker container logs hblink" #Lets begin------------------------------------------------------------------------------------------------- if [ "$EUID" -ne 0 ]; then @@ -44,7 +45,7 @@ fi if [ ! -e "/etc/debian_version" ] then echo "" - echo "This script is only tested in Debian 10, 11, 12 & 13 (Trixie)." + echo "This script is only tested in Debian 11, 12 & 13 (Trixie)." exit 0 fi DIRDIR=$(pwd) @@ -85,86 +86,112 @@ install_docker_and_dependencies() { sleep 2 # Remove old Docker versions if present - apt-get remove docker docker-engine docker.io containerd runc 2>/dev/null || true + echo "Removing old Docker versions if present..." + apt-get remove docker docker-engine docker.io containerd runc docker-compose 2>/dev/null || true # Add Docker GPG key + echo "Adding Docker GPG key..." curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ]; then + echo "ERROR: Failed to download Docker GPG key" + exit 1 + fi + # Add Docker repository + echo "Adding Docker repository..." echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - # Install Docker + # Install Docker Engine from official Docker repositories + echo "Installing Docker Engine from official Docker repositories..." apt-get update - apt-get install -y docker-ce docker-ce-cli containerd.io + if ! apt-get install -y docker-ce docker-ce-cli containerd.io; then + echo "ERROR: Failed to install Docker Engine" + echo "Please check your internet connection and Debian version compatibility" + exit 1 + fi - # Install docker-compose based on Debian version - if [ $version -ge 12 ]; then - # For Debian 12+ use docker-compose-plugin or install from GitHub - # Note: We prefer docker-compose-plugin from apt repos when available for security - if apt-get install -y docker-compose-plugin 2>/dev/null; then - echo "docker-compose-plugin installed successfully" - # Create wrapper script for docker-compose command compatibility - # docker-compose-plugin provides 'docker compose' but scripts use 'docker-compose' - # Note: Using single quotes in heredoc ('EOF') prevents variable expansion for robustness - if [ ! -f /usr/local/bin/docker-compose ]; then - echo "Creating docker-compose wrapper script..." - # Create wrapper that forwards all commands to 'docker compose' - # Exit on failure is intentional - without this wrapper, all control scripts will fail - if cat > /usr/local/bin/docker-compose << 'EOF' + # Verify Docker is installed + if ! command -v docker &> /dev/null; then + echo "ERROR: Docker installation failed - docker command not found" + exit 1 + fi + + # Install Docker Compose v2 plugin from official Docker repositories + echo "Installing Docker Compose v2 plugin from official Docker repositories..." + if ! apt-get install -y docker-compose-plugin; then + echo "ERROR: Failed to install docker-compose-plugin from Docker repositories" + echo "This installer only supports Docker Compose v2" + exit 1 + fi + + # Verify Docker Compose v2 is installed + if ! docker compose version &> /dev/null; then + echo "ERROR: Docker Compose v2 installation failed - 'docker compose' command not working" + exit 1 + fi + + # Create wrapper script for backward compatibility with docker-compose command + # This allows existing scripts using 'docker-compose' to work with 'docker compose' + echo "Creating docker-compose wrapper for backward compatibility..." + if [ ! -f /usr/local/bin/docker-compose ]; then + if cat > /usr/local/bin/docker-compose << 'EOF' #!/bin/sh # Wrapper script to provide docker-compose command using docker compose plugin exec docker compose "$@" EOF - then - chmod +x /usr/local/bin/docker-compose - echo "docker-compose wrapper created successfully" - else - echo "ERROR: Failed to create docker-compose wrapper script" - exit 1 - fi - else - # Skip wrapper creation if docker-compose already exists - # This preserves existing installations (from apt or manual install) - echo "docker-compose command already exists, skipping wrapper creation" - fi - else - echo "Installing docker-compose from GitHub releases..." - # Fallback to GitHub releases for official Docker Compose binary - # Downloaded from official Docker GitHub repository over HTTPS - curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m) -o /usr/local/bin/docker-compose + then chmod +x /usr/local/bin/docker-compose - ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose 2>/dev/null || true + echo "docker-compose wrapper created successfully" + else + echo "ERROR: Failed to create docker-compose wrapper script" + exit 1 fi else - # For Debian 10-11 use apt package - apt-get install -y docker-compose + echo "docker-compose command already exists at /usr/local/bin/docker-compose" + fi + + # Verify the wrapper works + if ! /usr/local/bin/docker-compose version &> /dev/null; then + echo "ERROR: docker-compose wrapper verification failed" + exit 1 fi # Enable and start Docker + echo "Enabling and starting Docker service..." systemctl enable docker systemctl start docker + + # Verify Docker service is running + if ! systemctl is-active --quiet docker; then + echo "ERROR: Docker service failed to start" + exit 1 + fi + figlet "docker.io" echo "Set userland-proxy to false..." echo '{ "userland-proxy": false}' > /etc/docker/daemon.json + systemctl restart docker + sleep 2 } - if [ $VERSION = 10 ] || [ $VERSION = 11 ]; then + if [ $VERSION = 11 ] || [ $VERSION = 12 ] || [ $VERSION = 13 ]; then + echo "Installing for Debian $VERSION with Docker Compose v2..." install_docker_and_dependencies $VERSION - - elif [ $VERSION = 12 ] || [ $VERSION = 13 ]; then - # Debian 12 (Bookworm) and 13 (Trixie) support - echo "Installing for Debian $VERSION..." - install_docker_and_dependencies $VERSION - + elif [ $VERSION = 10 ]; then + echo "ERROR: Debian 10 is no longer supported by this installer" + echo "This installer now requires Debian 11, 12, or 13 for Docker Compose v2 support" + echo "Please upgrade your system to Debian 11 or later" + exit 1 else - echo "-------------------------------------------------------------------------------------------" - echo "Operating system not supported! Please check you are running Debian 10-13. Exiting....." - echo "-------------------------------------------------------------------------------------------" - exit 0 -fi + echo "-------------------------------------------------------------------------------------------" + echo "Operating system not supported! Please check you are running Debian 11, 12, or 13. Exiting....." + echo "-------------------------------------------------------------------------------------------" + exit 0 + fi echo "Done." echo "------------------------------------------------------------------------------" echo "Installing control scripts /usr/local/sbin....." @@ -896,6 +923,7 @@ figlet "WhipTAIL'" hblink-initial-setup sleep 1 echo "Done." +sleep 2 echo "" echo "" echo "*************************************************************************" @@ -920,6 +948,19 @@ echo "" echo " Your IP address is $LOCAL_IP " echo "" echo " Your running on $ARC with Debian $VERSION " +echo "" +echo "------------------------------------------------------------------------------" +echo " Installed Versions " +echo "------------------------------------------------------------------------------" +echo "Docker version:" +docker --version +echo "" +echo "Docker Compose version:" +docker compose version +echo "" +echo "Note: This installation uses Docker Compose v2 (docker compose command)" +echo " The legacy docker-compose v1 is not supported" +echo "------------------------------------------------------------------------------" echo "" echo " Thanks for using this script. " echo " Copyright © 2024 Shane Daley - M0VUB " From e277e1da5316df6271254ec7c42ed719d846dea0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:35:28 +0000 Subject: [PATCH 3/7] Fix remaining Debian 10 reference in README Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df32bc5..2431020 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debia Parrot is built into this install (Default disabled, see below how to enable the parrot feature! ### Destructive Installer -This is a destructive installer and is recommended to be built on a freshly installed machine running Debian 10, 11, 12, or 13 (Trixie). +This is a destructive installer and is recommended to be built on a freshly installed machine running Debian 11, 12, or 13 (Trixie). ### Docker Multi-Arch build Docker container pre-built for multi-arch! From 4a7d71c339bcbecc569d38d0ee09140eb986e2fe Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:36:35 +0000 Subject: [PATCH 4/7] Clean up remaining Debian 10 references in comments Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com> --- README.md | 2 +- hblink3-docker-install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2431020..3282b74 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ Within this installation includes the new HBMonv2 by Weldek SP2ONG - The systemd service automatically uses the virtual environment's Python interpreter - This approach eliminates "externally-managed-environment" errors and conflicts with system packages -**Debian 10-11:** Standard pip installation to system Python is used for backward compatibility. +**Debian 11:** Standard pip installation to system Python is used for backward compatibility, as PEP 668 restrictions don't apply to Debian 11. This ensures clean, maintainable installations that follow modern Python best practices while maintaining compatibility with older Debian versions. diff --git a/hblink3-docker-install.sh b/hblink3-docker-install.sh index 34ec281..bc3d6ca 100755 --- a/hblink3-docker-install.sh +++ b/hblink3-docker-install.sh @@ -280,7 +280,7 @@ pip_install() { return 1 fi else - # For Debian 10-11, use standard pip installation + # For Debian 11, use standard pip installation (pre-PEP 668) echo "Installing Python packages for Debian $VERSION: $args" if pip3 install $args; then echo "Successfully installed: $args" From 0246fe7c278cfe8e0d0cbe0c2a1268beb2705461 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:38:08 +0000 Subject: [PATCH 5/7] Fix grammar: 'Your running' to 'You're running' Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com> --- hblink3-docker-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hblink3-docker-install.sh b/hblink3-docker-install.sh index bc3d6ca..bda2f16 100755 --- a/hblink3-docker-install.sh +++ b/hblink3-docker-install.sh @@ -947,7 +947,7 @@ echo " https://github.com/ShaYmez/hblink3-docker-install " echo "" echo " Your IP address is $LOCAL_IP " echo "" -echo " Your running on $ARC with Debian $VERSION " +echo " You're running on $ARC with Debian $VERSION " echo "" echo "------------------------------------------------------------------------------" echo " Installed Versions " From 73cceaf4443a6ebaadd291911f6df55aa98c00d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:41:08 +0000 Subject: [PATCH 6/7] Simplify installer for modern approach - remove version-specific duplications Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com> --- README.md | 6 +- hblink3-docker-install.sh | 133 +++++++++++++++----------------------- 2 files changed, 55 insertions(+), 84 deletions(-) diff --git a/README.md b/README.md index 3282b74..5b8363c 100644 --- a/README.md +++ b/README.md @@ -146,15 +146,13 @@ Within this installation includes the new HBMonv2 by Weldek SP2ONG ### Technical Details - Python Package Management -**Debian 12+ (Bookworm/Trixie):** The installer uses modern Python package management following PEP 668 standards: +The installer uses modern Python package management following PEP 668 standards for all supported Debian versions: - HBMonv2 runs in an isolated Python virtual environment at `/opt/HBMonv2/venv` - All Python dependencies are installed within this virtual environment, avoiding system-wide package conflicts - The systemd service automatically uses the virtual environment's Python interpreter - This approach eliminates "externally-managed-environment" errors and conflicts with system packages -**Debian 11:** Standard pip installation to system Python is used for backward compatibility, as PEP 668 restrictions don't apply to Debian 11. - -This ensures clean, maintainable installations that follow modern Python best practices while maintaining compatibility with older Debian versions. +This ensures clean, maintainable installations that follow modern Python best practices across all Debian versions. ## Easy Installation And Upgrade The installation can be upgraded either by the use of a future scripts or by manually backing up your configuration and re-running the install script. Also the ability and really cool feature of docker-compose is that its easy to update the container with fresh images! Run by a simple command. Make sure you are in the /etc/hblink3 dir. diff --git a/hblink3-docker-install.sh b/hblink3-docker-install.sh index bda2f16..4b0eabb 100755 --- a/hblink3-docker-install.sh +++ b/hblink3-docker-install.sh @@ -53,17 +53,11 @@ LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | EXTERNAL_IP=$(curl -s --connect-timeout 5 https://ipecho.net/plain 2>/dev/null || echo "Unable to detect") ARC=$(lscpu | grep Arch | awk '{print $2}') VERSION=$(sed 's/\..*//' /etc/debian_version) -ARMv7l=https://get.docker.com | sh -ARMv8l=https://get.docker.com | sh -X32=https://get.docker.com | sh -X64=https://get.docker.com | sh INSDIR=/opt/tmp/ HBLINKTMP=/opt/tmp/hblink3 HBMONDIR=/opt/HBMonv2/ HBDIR=/etc/hblink3/ -DEP="wget curl git sudo python3 python3-dev python3-pip libffi-dev libssl-dev conntrack sed cargo apache2 php snapd figlet ca-certificates gnupg lsb-release" -DEP1="wget curl git sudo python3 python3-dev python3-pip libffi-dev libssl-dev conntrack sed cargo apache2 php snapd figlet ca-certificates gnupg lsb-release" -DEP2="wget sudo curl git python3 python3-dev python3-pip libffi-dev libssl-dev conntrack sed cargo apache2 php php-mysqli snapd figlet ca-certificates gnupg lsb-release" +DEP="wget curl git sudo python3 python3-dev python3-pip python3-venv libffi-dev libssl-dev conntrack sed cargo apache2 php snapd figlet ca-certificates gnupg lsb-release" HBGITREPO=https://github.com/ShaYmez/hblink3.git HBGITMONREPO=https://github.com/ShaYmez/HBMonv2.git echo "" @@ -75,14 +69,10 @@ install_docker_and_dependencies() { local version=$1 echo "Detected Debian version: $version" - # Install base dependencies + # Install base dependencies (python3-venv is included for all versions for consistency) + echo "Installing dependencies..." apt-get update - # For Debian 12+, add python3-venv to dependencies (PEP 668 compliance) - if [ $version -ge 12 ]; then - apt-get install -y $DEP python3-venv - else - apt-get install -y $DEP - fi + apt-get install -y $DEP sleep 2 # Remove old Docker versions if present @@ -262,64 +252,49 @@ echo "Installing HBMonv2 configuration....." echo "------------------------------------------------------------------------------" sleep 2 -# Helper function to install pip packages with Debian 12+ compatibility +# Helper function to install pip packages in virtual environment pip_install() { local args="$@" - if [ $VERSION -ge 12 ]; then - # For Debian 12+, use virtual environment (PEP 668 compliant) - echo "Installing Python packages for Debian $VERSION: $args" - if [ -z "$VIRTUAL_ENV" ]; then - echo "ERROR: Virtual environment not activated" - return 1 - fi - if pip3 install $args; then - echo "Successfully installed: $args" - return 0 - else - echo "ERROR: Failed to install: $args" - return 1 - fi + echo "Installing Python packages: $args" + if [ -z "$VIRTUAL_ENV" ]; then + echo "ERROR: Virtual environment not activated" + return 1 + fi + if pip3 install $args; then + echo "Successfully installed: $args" + return 0 else - # For Debian 11, use standard pip installation (pre-PEP 668) - echo "Installing Python packages for Debian $VERSION: $args" - if pip3 install $args; then - echo "Successfully installed: $args" - return 0 - else - echo "ERROR: Failed to install: $args" - return 1 - fi + echo "ERROR: Failed to install: $args" + return 1 fi } echo "Installing Python dependencies..." cd $HBMONDIR -# For Debian 12+, create and use a virtual environment (modern PEP 668 compliant approach) -if [ $VERSION -ge 12 ]; then - echo "Creating Python virtual environment for Debian $VERSION..." - - # Create virtual environment - if [ ! -d "$HBMONDIR/venv" ]; then - python3 -m venv "$HBMONDIR/venv" || { echo "ERROR: Failed to create virtual environment"; exit 1; } - echo "Virtual environment created successfully at $HBMONDIR/venv" - else - echo "Virtual environment already exists at $HBMONDIR/venv" - fi - - # Activate virtual environment - source "$HBMONDIR/venv/bin/activate" || { echo "ERROR: Failed to activate virtual environment"; exit 1; } - # Verify activation by checking VIRTUAL_ENV is set - if [ -z "$VIRTUAL_ENV" ]; then - echo "ERROR: Virtual environment activation failed - VIRTUAL_ENV not set" - exit 1 - fi - echo "Virtual environment activated" - - # Upgrade pip in the virtual environment - if ! pip3 install --upgrade pip; then - echo "WARNING: Failed to upgrade pip in virtual environment, continuing with existing version..." - fi +# Create and use a virtual environment (modern approach for all Debian versions) +echo "Creating Python virtual environment..." + +# Create virtual environment +if [ ! -d "$HBMONDIR/venv" ]; then + python3 -m venv "$HBMONDIR/venv" || { echo "ERROR: Failed to create virtual environment"; exit 1; } + echo "Virtual environment created successfully at $HBMONDIR/venv" +else + echo "Virtual environment already exists at $HBMONDIR/venv" +fi + +# Activate virtual environment +source "$HBMONDIR/venv/bin/activate" || { echo "ERROR: Failed to activate virtual environment"; exit 1; } +# Verify activation by checking VIRTUAL_ENV is set +if [ -z "$VIRTUAL_ENV" ]; then + echo "ERROR: Virtual environment activation failed - VIRTUAL_ENV not set" + exit 1 +fi +echo "Virtual environment activated" + +# Upgrade pip in the virtual environment +if ! pip3 install --upgrade pip; then + echo "WARNING: Failed to upgrade pip in virtual environment, continuing with existing version..." fi # Install setuptools and wheel first @@ -401,25 +376,23 @@ LOG_NAME = 'hbmon.log' EOF cp utils/hbmon.service /lib/systemd/system/ - # For Debian 12+, update the service file to use virtual environment - if [ $VERSION -ge 12 ]; then - echo "Updating hbmon.service to use virtual environment..." - # Update ExecStart to use venv Python (only if not already using venv) - if ! grep -q "$HBMONDIR/venv/bin/python3" /lib/systemd/system/hbmon.service; then - # Replace common Python interpreter paths with venv path - sed -i "s|ExecStart=/usr/bin/python3|ExecStart=$HBMONDIR/venv/bin/python3|g" /lib/systemd/system/hbmon.service - sed -i "s|ExecStart=python3 |ExecStart=$HBMONDIR/venv/bin/python3 |g" /lib/systemd/system/hbmon.service - - # Verify the service file was updated correctly - if grep -q "ExecStart=$HBMONDIR/venv/bin/python3" /lib/systemd/system/hbmon.service; then - echo "Service file updated to use virtual environment" - else - echo "WARNING: Service file update may not have completed correctly" - echo "Please manually verify /lib/systemd/system/hbmon.service uses $HBMONDIR/venv/bin/python3" - fi + # Update the service file to use virtual environment (for all Debian versions) + echo "Updating hbmon.service to use virtual environment..." + # Update ExecStart to use venv Python (only if not already using venv) + if ! grep -q "$HBMONDIR/venv/bin/python3" /lib/systemd/system/hbmon.service; then + # Replace common Python interpreter paths with venv path + sed -i "s|ExecStart=/usr/bin/python3|ExecStart=$HBMONDIR/venv/bin/python3|g" /lib/systemd/system/hbmon.service + sed -i "s|ExecStart=python3 |ExecStart=$HBMONDIR/venv/bin/python3 |g" /lib/systemd/system/hbmon.service + + # Verify the service file was updated correctly + if grep -q "ExecStart=$HBMONDIR/venv/bin/python3" /lib/systemd/system/hbmon.service; then + echo "Service file updated to use virtual environment" else - echo "Service file already configured to use virtual environment" + echo "WARNING: Service file update may not have completed correctly" + echo "Please manually verify /lib/systemd/system/hbmon.service uses $HBMONDIR/venv/bin/python3" fi + else + echo "Service file already configured to use virtual environment" fi cp utils/lastheard /etc/cron.daily/ From 9ecafe79598faa0d75f6b1bf03a320edc362e4b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 14 Dec 2025 00:46:17 +0000 Subject: [PATCH 7/7] Add Ubuntu 22.04 and 24.04 LTS support, remove Ubuntu 20.04 Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com> --- README.md | 16 +++---- hblink3-docker-install.sh | 97 ++++++++++++++++++++++++++++++++------- 2 files changed, 89 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5b8363c..2243d27 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # HBlink3 Docker Installer -**Version 1.5.0** - Debian 11 / 12 / 13 (Trixie) Support!! +**Version 1.5.0** - Debian 11 / 12 / 13 and Ubuntu 22.04 / 24.04 LTS Support!! ======= -This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debian 11, 12, and 13 (Trixie). +This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debian 11, 12, 13 and Ubuntu 22.04, 24.04 LTS. **Important:** This installer requires Docker Compose v2 (provided by the docker-compose-plugin package). The legacy docker-compose v1 standalone package is not supported. The installer automatically installs Docker Engine and Docker Compose v2 from the official Docker repositories. -**Note:** Debian 12 (Bookworm) and 13 (Trixie) support has been added with proper PEP 668 compliant Python package management using virtual environments. HBMonv2 now runs in an isolated Python virtual environment on Debian 12+. See [CHANGELOG.md](CHANGELOG.md) for version history and updates. +**Note:** Debian 12 (Bookworm) and 13 (Trixie) along with Ubuntu 22.04 and 24.04 LTS are fully supported with proper PEP 668 compliant Python package management using virtual environments. HBMonv2 now runs in an isolated Python virtual environment. See [CHANGELOG.md](CHANGELOG.md) for version history and updates. ![HBlink](img/HBLINK_logoV1.png "HBlink") @@ -14,7 +14,7 @@ This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debia Parrot is built into this install (Default disabled, see below how to enable the parrot feature! ### Destructive Installer -This is a destructive installer and is recommended to be built on a freshly installed machine running Debian 11, 12, or 13 (Trixie). +This is a destructive installer and is recommended to be built on a freshly installed machine running Debian 11, 12, 13 or Ubuntu 22.04, 24.04 LTS. ### Docker Multi-Arch build Docker container pre-built for multi-arch! @@ -31,7 +31,7 @@ This installer includes all the usual libs and packages including docker, apache install this on a 'clean machine'. The script is destructive and is not designed to be used on an exisiting machine that has other software on it! YOU HAVE BEEN WARNED! ### Prerequisite -The host system must be running Debian 11, 12, or 13 (Trixie). **Debian 10 is no longer supported** due to the requirement for Docker Compose v2. The installer has been tested on these Debian versions and works on most architectures. The system requires, at a minimum; 1 core, 512mb of ram, the required spec to run docker and additional processes! The system must be up-to-date and have Git installed. You can install Git from the CLI. +The host system must be running Debian 11, 12, 13 or Ubuntu 22.04, 24.04 LTS. **Debian 10 and Ubuntu 20.04 are no longer supported** due to the requirement for Docker Compose v2 and modern Python package management. The installer has been tested on these OS versions and works on most architectures. The system requires, at a minimum; 1 core, 512mb of ram, the required spec to run docker and additional processes! The system must be up-to-date and have Git installed. You can install Git from the CLI. **Docker Compose v2:** This installer exclusively uses Docker Compose v2 from the official Docker repositories. The docker-compose-plugin package is automatically installed, providing the `docker compose` command (note the space). A compatibility wrapper is also created to support the legacy `docker-compose` command (with hyphen) for backward compatibility with existing scripts. @@ -42,7 +42,7 @@ Make sure your system is up-to-date and pull Git from the apt repo. apt-get install -y git ``` ### Installation -1. Preferably a clean Debian 11, 12, or 13 (Trixie) system. **Debian 10 is no longer supported.** Make sure your system is up to date with the latest apt repository database. You must be super user "root" to run this installer successfully. +1. Preferably a clean Debian 11, 12, 13 or Ubuntu 22.04, 24.04 LTS system. **Debian 10 and Ubuntu 20.04 are no longer supported.** Make sure your system is up to date with the latest apt repository database. You must be super user "root" to run this installer successfully. ```sh apt update sudo su @@ -146,13 +146,13 @@ Within this installation includes the new HBMonv2 by Weldek SP2ONG ### Technical Details - Python Package Management -The installer uses modern Python package management following PEP 668 standards for all supported Debian versions: +The installer uses modern Python package management following PEP 668 standards for all supported OS versions: - HBMonv2 runs in an isolated Python virtual environment at `/opt/HBMonv2/venv` - All Python dependencies are installed within this virtual environment, avoiding system-wide package conflicts - The systemd service automatically uses the virtual environment's Python interpreter - This approach eliminates "externally-managed-environment" errors and conflicts with system packages -This ensures clean, maintainable installations that follow modern Python best practices across all Debian versions. +This ensures clean, maintainable installations that follow modern Python best practices across all supported Debian and Ubuntu versions. ## Easy Installation And Upgrade The installation can be upgraded either by the use of a future scripts or by manually backing up your configuration and re-running the install script. Also the ability and really cool feature of docker-compose is that its easy to update the container with fresh images! Run by a simple command. Make sure you are in the /etc/hblink3 dir. diff --git a/hblink3-docker-install.sh b/hblink3-docker-install.sh index 4b0eabb..1df4718 100755 --- a/hblink3-docker-install.sh +++ b/hblink3-docker-install.sh @@ -22,9 +22,9 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ################################################################################## # -# A tool to install HBlink3 Docker with Debian 11, 12, and 13 support. +# A tool to install HBlink3 Docker with Debian 11, 12, 13 and Ubuntu 22.04, 24.04 LTS support. # This essentially is a HBlink3 server fully installed with dashboard ready to go. -# Step 1: Install Debian 11, 12, or 13 (Trixie) and make sure it has internet and is up to date. +# Step 1: Install Debian 11, 12, 13 or Ubuntu 22.04, 24.04 LTS and make sure it has internet and is up to date. # Step 2: Run this script on the computer. # Step 3: Reboot after installation. # This is a docker version and you can use the following commands to control / maintain your server @@ -42,17 +42,52 @@ then echo "You Must be root to run this script!!" exit 1 fi -if [ ! -e "/etc/debian_version" ] -then - echo "" - echo "This script is only tested in Debian 11, 12 & 13 (Trixie)." - exit 0 + +# Detect OS type and version +if [ -f /etc/os-release ]; then + . /etc/os-release + OS=$ID + OS_VERSION=$VERSION_ID +else + echo "ERROR: Cannot detect operating system" + exit 1 fi + +# Check for supported OS +if [ "$OS" != "debian" ] && [ "$OS" != "ubuntu" ]; then + echo "" + echo "ERROR: This script only supports Debian and Ubuntu distributions" + echo "Detected OS: $OS" + exit 1 +fi + +# Validate Ubuntu versions +if [ "$OS" = "ubuntu" ]; then + if [ "$OS_VERSION" != "22.04" ] && [ "$OS_VERSION" != "24.04" ]; then + echo "" + echo "ERROR: Only Ubuntu 22.04 LTS and 24.04 LTS are supported" + echo "Detected Ubuntu version: $OS_VERSION" + exit 1 + fi + echo "Detected: Ubuntu $OS_VERSION LTS" +fi + +# Validate Debian versions +if [ "$OS" = "debian" ]; then + VERSION=$(sed 's/\..*//' /etc/debian_version) + if [ "$VERSION" != "11" ] && [ "$VERSION" != "12" ] && [ "$VERSION" != "13" ]; then + echo "" + echo "ERROR: Only Debian 11, 12, and 13 are supported" + echo "Detected Debian version: $VERSION" + exit 1 + fi + echo "Detected: Debian $VERSION" +fi + DIRDIR=$(pwd) LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') EXTERNAL_IP=$(curl -s --connect-timeout 5 https://ipecho.net/plain 2>/dev/null || echo "Unable to detect") ARC=$(lscpu | grep Arch | awk '{print $2}') -VERSION=$(sed 's/\..*//' /etc/debian_version) INSDIR=/opt/tmp/ HBLINKTMP=/opt/tmp/hblink3 HBMONDIR=/opt/HBMonv2/ @@ -66,8 +101,7 @@ echo "Downloading and installing required software & dependencies....." echo "------------------------------------------------------------------------------" install_docker_and_dependencies() { - local version=$1 - echo "Detected Debian version: $version" + echo "Installing Docker and dependencies..." # Install base dependencies (python3-venv is included for all versions for consistency) echo "Installing dependencies..." @@ -79,9 +113,18 @@ install_docker_and_dependencies() { echo "Removing old Docker versions if present..." apt-get remove docker docker-engine docker.io containerd runc docker-compose 2>/dev/null || true + # Determine Docker repository URL based on OS + if [ "$OS" = "ubuntu" ]; then + DOCKER_REPO_URL="https://download.docker.com/linux/ubuntu" + echo "Configuring Docker repository for Ubuntu..." + else + DOCKER_REPO_URL="https://download.docker.com/linux/debian" + echo "Configuring Docker repository for Debian..." + fi + # Add Docker GPG key echo "Adding Docker GPG key..." - curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + curl -fsSL ${DOCKER_REPO_URL}/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg if [ ! -f /usr/share/keyrings/docker-archive-keyring.gpg ]; then echo "ERROR: Failed to download Docker GPG key" @@ -91,7 +134,7 @@ install_docker_and_dependencies() { # Add Docker repository echo "Adding Docker repository..." echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian \ + "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] ${DOCKER_REPO_URL} \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Install Docker Engine from official Docker repositories @@ -168,10 +211,12 @@ EOF sleep 2 } - if [ $VERSION = 11 ] || [ $VERSION = 12 ] || [ $VERSION = 13 ]; then +# Run Docker installation for supported OS versions +if [ "$OS" = "debian" ]; then + if [ "$VERSION" = "11" ] || [ "$VERSION" = "12" ] || [ "$VERSION" = "13" ]; then echo "Installing for Debian $VERSION with Docker Compose v2..." - install_docker_and_dependencies $VERSION - elif [ $VERSION = 10 ]; then + install_docker_and_dependencies + elif [ "$VERSION" = "10" ]; then echo "ERROR: Debian 10 is no longer supported by this installer" echo "This installer now requires Debian 11, 12, or 13 for Docker Compose v2 support" echo "Please upgrade your system to Debian 11 or later" @@ -182,6 +227,22 @@ EOF echo "-------------------------------------------------------------------------------------------" exit 0 fi +elif [ "$OS" = "ubuntu" ]; then + if [ "$OS_VERSION" = "22.04" ] || [ "$OS_VERSION" = "24.04" ]; then + echo "Installing for Ubuntu $OS_VERSION LTS with Docker Compose v2..." + install_docker_and_dependencies + else + echo "-------------------------------------------------------------------------------------------" + echo "Operating system not supported! Please check you are running Ubuntu 22.04 or 24.04 LTS. Exiting....." + echo "-------------------------------------------------------------------------------------------" + exit 0 + fi +else + echo "-------------------------------------------------------------------------------------------" + echo "Operating system not supported! Exiting....." + echo "-------------------------------------------------------------------------------------------" + exit 0 +fi echo "Done." echo "------------------------------------------------------------------------------" echo "Installing control scripts /usr/local/sbin....." @@ -920,7 +981,11 @@ echo " https://github.com/ShaYmez/hblink3-docker-install " echo "" echo " Your IP address is $LOCAL_IP " echo "" -echo " You're running on $ARC with Debian $VERSION " +if [ "$OS" = "ubuntu" ]; then + echo " You're running on $ARC with Ubuntu $OS_VERSION LTS " +else + echo " You're running on $ARC with Debian $VERSION " +fi echo "" echo "------------------------------------------------------------------------------" echo " Installed Versions "