Merge pull request #8 from ShaYmez/copilot/refactor-installation-process

Add Debian 13 support, uninstall functionality, and refactor installation logic
This commit is contained in:
M0VUB 2025-12-13 01:21:48 +00:00 committed by GitHub
commit 804be3c33e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 366 additions and 57 deletions

View File

@ -1,7 +1,9 @@
# HBlink3 Docker Installer
Debian 10 / 11 only!!
Debian 10 / 11 / 12 / 13 (Trixie) Support!!
=======
This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debian 10 / 11. The HBMonv2 dashboard is not currently supported on debian 12 at this time!!
This is a multi-arch docker installer for HBlink3 and HBmonV2 combined for Debian 10, 11, 12, and 13 (Trixie).
**Note:** Debian 12 (Bookworm) and 13 (Trixie) support has been added with proper handling of pip installation restrictions and docker-compose compatibility.
![HBlink](img/HBLINK_logoV1.png "HBlink")
@ -10,7 +12,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 or 11. Please note this installer will not work on Debian 12 Bookworm!!
This is a destructive installer and is recommended to be built on a freshly installed machine running Debian 10, 11, 12, or 13 (Trixie).
### Docker Multi-Arch build
Docker container pre-built for multi-arch!
@ -27,7 +29,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 10 or 11. Although this software may run on the latest debian platform, this installer has only been tested on debian 10 and 11. The installer may fail due to pip/python changes in debian 12. This script has been tested on most architectures but 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 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.
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.
@ -36,7 +38,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 or 11 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 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.
```sh
apt update
sudo su
@ -72,8 +74,32 @@ hblink-stop
hblink-restart
hblink-flush
hblink-update
hblink-uninstall
```
### Uninstallation
To completely remove HBlink3 and all its components from your system, you can use the uninstall script:
```sh
hblink-uninstall
```
or
```sh
hblink-menu
```
Then select option 11 "Uninstall HBlink3"
The uninstall script will:
- Stop all HBlink3 services (Docker containers and HBMonv2)
- Remove Docker containers and HBlink images
- Remove systemd service files
- Remove cron jobs
- Remove control scripts from /usr/local/sbin
- Backup configurations to /root/hblink3-backup-[timestamp]
- Remove installation directories (/etc/hblink3, /opt/HBMonv2, /var/log/hblink)
- Restore default Apache index page
**Note:** Docker, Apache2, PHP, and other system packages will NOT be removed during uninstallation.
9. To interact with HBlink3 manually using docker you need to enter the HBlink3 directory
```sh
cd /etc/hblink3

View File

@ -20,11 +20,11 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
##################################################################################
#
# A tool to install HBlink3 Docker with Debian 10-11 / Ubuntu 20.04 support.
# A tool to install HBlink3 Docker with Debian 10-13 / Ubuntu 20.04 support.
# This essentially is a HBlink3 server fully installed with dashboard ready to go.
# Step 1: Install Debian 10 or 11 or Ubuntu 20.04 and make sure it has internet and is up to date.
# 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 2: Run this script on the computer.
# Step 4: Reboot after installation.
# Step 3: Reboot after installation.
# This is a docker version and you can use the following comands to control / maintain your server
# cd /etc/hblink3
# docker-compose up -d (starts the hblink3 docker container)
@ -42,7 +42,7 @@ fi
if [ ! -e "/etc/debian_version" ]
then
echo ""
echo "This script is only tested in Debian 9,10 & 11 repo only."
echo "This script is only tested in Debian 10, 11, 12 & 13 (Trixie)."
exit 0
fi
DIRDIR=$(pwd)
@ -68,51 +68,67 @@ echo "--------------------------------------------------------------------------
echo "Downloading and installing required software & dependencies....."
echo "------------------------------------------------------------------------------"
if [ $VERSION = 10 ];
then
apt-get update
apt-get install -y $DEP
sleep 2
apt-get remove docker docker-engine docker.io containerd runc
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
install_docker_and_dependencies() {
local version=$1
echo "Detected Debian version: $version"
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 base dependencies
apt-get update
apt-get install -y $DEP
sleep 2
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
# Remove old Docker versions if present
apt-get remove docker docker-engine docker.io containerd runc 2>/dev/null || true
# Add Docker GPG key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Add 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
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
# 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
apt-get install -y docker-compose-plugin 2>/dev/null || {
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
chmod +x /usr/local/bin/docker-compose
ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose 2>/dev/null || true
}
else
# For Debian 10-11 use apt package
apt-get install -y docker-compose
systemctl enable docker
systemctl start docker
figlet "docker.io"
echo Set userland-proxy to false...
echo '{ "userland-proxy": false}' > /etc/docker/daemon.json
fi
elif [ $VERSION = 11 ];
then
apt-get update
apt-get install -y $DEP
sleep 2
apt-get remove docker docker-engine docker.io containerd runc
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Enable and start Docker
systemctl enable docker
systemctl start docker
figlet "docker.io"
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
echo "Set userland-proxy to false..."
echo '{ "userland-proxy": false}' > /etc/docker/daemon.json
}
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
apt-get install -y docker-compose
systemctl enable docker
systemctl start docker
figlet "docker.io"
echo Set userland-proxy to false...
echo '{ "userland-proxy": false}' > /etc/docker/daemon.json
if [ $VERSION = 10 ] || [ $VERSION = 11 ]; then
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
else
echo "-------------------------------------------------------------------------------------------"
echo "Operating system not supported! Please check your running debian 10 or 11. Exiting....."
echo "Operating system not supported! Please check you are running Debian 10-13. Exiting....."
echo "-------------------------------------------------------------------------------------------"
exit 0
fi
@ -129,6 +145,7 @@ echo "--------------------------------------------------------------------------
cp -p start /usr/local/sbin/hblink-start
cp -p restart /usr/local/sbin/hblink-restart
cp -p initial-setup /usr/local/sbin/hblink-initial-setup
cp -p uninstall /usr/local/sbin/hblink-uninstall
if [ -e /usr/local/sbin/hblink-menu ]
then
echo "----------------------------------------------------------------------------------------------"
@ -149,6 +166,7 @@ fi
chmod 755 /usr/local/sbin/hblink-start
chmod 755 /usr/local/sbin/hblink-restart
chmod 755 /usr/local/sbin/hblink-initial-setup
chmod 755 /usr/local/sbin/hblink-uninstall
echo "Done."
echo "------------------------------------------------------------------------------"
@ -179,9 +197,24 @@ echo "--------------------------------------------------------------------------
echo "Installing HBMonv2 configuration....."
echo "------------------------------------------------------------------------------"
sleep 2
pip3 install setuptools wheel
pip3 install -r requirements.txt
pip3 install attrs --force
# Helper function to install pip packages with Debian 12+ compatibility
pip_install() {
local args="$@"
if [ $VERSION -ge 12 ]; then
# For Debian 12+, try with --break-system-packages flag first
pip3 install --break-system-packages $args 2>/dev/null || pip3 install $args
else
# For Debian 10-11, use standard pip installation
pip3 install $args
fi
}
echo "Installing Python dependencies..."
pip_install setuptools wheel
pip_install -r requirements.txt
pip_install attrs --force
echo Install /opt/HBMonv2/config.py ...
cat << EOF > /opt/HBMonv2/config.py
CONFIG_INC = True # Include HBlink stats

View File

@ -19,7 +19,7 @@
# Main MENU system.....
while : ; do
menuopt=$(whiptail --title "HBlink3 Control Version 1.9PL" --menu "Select option by using the up and down arrows on your keyboard. Once selected please press enter:" 23 56 13 \
menuopt=$(whiptail --title "HBlink3 Control Version 1.9PL" --menu "Select option by using the up and down arrows on your keyboard. Once selected please press enter:" 24 56 14 \
1 " Stop HBlink " \
2 " Start HBlink " \
3 " Restart HBlink " \
@ -30,8 +30,9 @@ menuopt=$(whiptail --title "HBlink3 Control Version 1.9PL" --menu "Select option
8 " Edit Dashboard Config " \
9 " Full Upgrade OBPMaster " \
10 " System Update / apt update " \
11 " Reboot Entire Server " \
12 " Shutdown Entire Server " 3>&1 1>&2 2>&3)
11 " Uninstall HBlink3 " \
12 " Reboot Entire Server " \
13 " Shutdown Entire Server " 3>&1 1>&2 2>&3)
exitstatus=$?
# Back-end HBlink3 menu
if [ $exitstatus = 0 ]; then
@ -62,8 +63,10 @@ sudo /usr/local/sbin/hblink-upgrade ;;
10)
sudo apt-get update -y && sudo apt-get upgrade ;;
11)
sudo reboot ;;
sudo /usr/local/sbin/hblink-uninstall ;;
12)
sudo reboot ;;
13)
sudo shutdown now ;
esac
done

247
usr/local/sbin/uninstall Normal file
View File

@ -0,0 +1,247 @@
#!/bin/bash
# HBLINK3 DOCKER UNINSTALL SCRIPT V1.0
# This script written by Shane Daley M0VUB.
# This script gracefully removes HBlink3 installation and all related components.
# Copyright (C) 2024 Shane P. Daley M0VUB <support@gb7nr.co.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# Root check
if [ "$EUID" -ne 0 ];
then
echo ""
echo "You Must be root to run this script!!"
exit 1
fi
clear
echo "*************************************************************************"
echo ""
echo " HBlink3 Docker Installation Uninstaller "
echo ""
echo "*************************************************************************"
echo ""
echo "WARNING: This will remove ALL HBlink3 components including:"
echo " - HBlink3 Docker containers and images"
echo " - HBMonv2 Dashboard"
echo " - Configuration files (/etc/hblink3)"
echo " - Log files (/var/log/hblink)"
echo " - Control scripts (/usr/local/sbin/hblink-*)"
echo " - Systemd services"
echo " - Cron jobs"
echo ""
echo "NOTE: Docker, Apache2, PHP, and system packages will NOT be removed."
echo ""
read -p "Are you sure you want to continue? (yes/no): " confirm
if [ "$confirm" != "yes" ]; then
echo "Uninstall cancelled."
exit 0
fi
echo ""
echo "Starting uninstallation process..."
echo ""
# Stop services
echo "------------------------------------------------------------------------------"
echo "Stopping HBlink3 services..."
echo "------------------------------------------------------------------------------"
if [ -d "/etc/hblink3" ]; then
cd /etc/hblink3
if [ -f "docker-compose.yml" ]; then
echo "Stopping HBlink3 Docker container..."
docker-compose down 2>/dev/null || true
fi
fi
if systemctl is-active --quiet hbmon; then
echo "Stopping HBMonv2 service..."
systemctl stop hbmon
fi
if systemctl is-enabled --quiet hbmon 2>/dev/null; then
echo "Disabling HBMonv2 service..."
systemctl disable hbmon
fi
# Remove Docker containers and images
echo ""
echo "------------------------------------------------------------------------------"
echo "Removing HBlink3 Docker containers and images..."
echo "------------------------------------------------------------------------------"
if [ -x "$(command -v docker)" ]; then
# Remove hblink container if it exists
if docker ps -a | grep -q hblink; then
echo "Removing hblink container..."
docker rm -f hblink 2>/dev/null || true
fi
# Remove hblink images
hblink_images=$(docker images | grep -i hblink | awk '{print $3}')
if [ ! -z "$hblink_images" ]; then
echo "Removing HBlink Docker images..."
docker rmi -f $hblink_images 2>/dev/null || true
fi
fi
# Remove systemd service files
echo ""
echo "------------------------------------------------------------------------------"
echo "Removing systemd service files..."
echo "------------------------------------------------------------------------------"
if [ -f "/lib/systemd/system/hbmon.service" ]; then
echo "Removing hbmon.service..."
rm -f /lib/systemd/system/hbmon.service
systemctl daemon-reload
fi
# Remove cron jobs
echo ""
echo "------------------------------------------------------------------------------"
echo "Removing cron jobs..."
echo "------------------------------------------------------------------------------"
if [ -f "/etc/cron.daily/lastheard" ]; then
echo "Removing lastheard cron job..."
rm -f /etc/cron.daily/lastheard
fi
# Remove control scripts
echo ""
echo "------------------------------------------------------------------------------"
echo "Removing control scripts..."
echo "------------------------------------------------------------------------------"
echo "Removing HBlink control scripts from /usr/local/sbin..."
rm -f /usr/local/sbin/hblink-menu
rm -f /usr/local/sbin/hblink-flush
rm -f /usr/local/sbin/hblink-update
rm -f /usr/local/sbin/hblink-upgrade
rm -f /usr/local/sbin/hblink-stop
rm -f /usr/local/sbin/hblink-start
rm -f /usr/local/sbin/hblink-restart
rm -f /usr/local/sbin/hblink-initial-setup
rm -f /usr/local/sbin/hblink-uninstall
# Backup configurations before removal
echo ""
echo "------------------------------------------------------------------------------"
echo "Creating backup of configuration files..."
echo "------------------------------------------------------------------------------"
backup_dir="/root/hblink3-backup-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$backup_dir"
if [ -d "/etc/hblink3" ]; then
echo "Backing up /etc/hblink3 to $backup_dir..."
cp -r /etc/hblink3 "$backup_dir/" 2>/dev/null || true
fi
if [ -d "/opt/HBMonv2" ]; then
echo "Backing up /opt/HBMonv2/config.py to $backup_dir..."
mkdir -p "$backup_dir/HBMonv2"
cp /opt/HBMonv2/config.py "$backup_dir/HBMonv2/" 2>/dev/null || true
fi
# Remove directories
echo ""
echo "------------------------------------------------------------------------------"
echo "Removing installation directories..."
echo "------------------------------------------------------------------------------"
if [ -d "/etc/hblink3" ]; then
echo "Removing /etc/hblink3..."
rm -rf /etc/hblink3
fi
if [ -d "/opt/HBMonv2" ]; then
echo "Removing /opt/HBMonv2..."
rm -rf /opt/HBMonv2
fi
if [ -d "/var/log/hblink" ]; then
echo "Removing /var/log/hblink..."
rm -rf /var/log/hblink
fi
if [ -d "/opt/tmp" ]; then
echo "Removing /opt/tmp..."
rm -rf /opt/tmp
fi
# Restore default Apache index
echo ""
echo "------------------------------------------------------------------------------"
echo "Restoring default Apache index page..."
echo "------------------------------------------------------------------------------"
if [ -f "/var/www/html/index_APACHE.html" ]; then
echo "Restoring original index.html..."
cd /var/www/html
rm -f index.html
mv index_APACHE.html index.html 2>/dev/null || true
fi
# Remove HBMonv2 dashboard files
if [ -f "/var/www/html/info.php" ]; then
echo "Removing HBMonv2 dashboard files from /var/www/html..."
# Remove only HBMonv2 specific files, not entire www directory
cd /var/www/html
rm -f info.php lastheard.php talkgroups.php *.js 2>/dev/null || true
rm -rf css/ fonts/ img/ include/ scripts/ 2>/dev/null || true
fi
# Final cleanup
echo ""
echo "------------------------------------------------------------------------------"
echo "Final cleanup..."
echo "------------------------------------------------------------------------------"
# Restart Apache to apply changes
if systemctl is-active --quiet apache2; then
echo "Restarting Apache2..."
systemctl restart apache2
fi
echo ""
echo "*************************************************************************"
echo ""
echo " HBlink3 Uninstallation Complete! "
echo ""
echo " All HBlink3 components have been removed from your system. "
echo ""
echo " Configuration backups saved to: $backup_dir"
echo ""
echo " The following were NOT removed (if you want to remove them manually): "
echo " - Docker (docker-ce, docker-ce-cli, containerd.io) "
echo " - Docker Compose "
echo " - Apache2 "
echo " - PHP and PHP modules "
echo " - Python3 and pip3 "
echo " - System packages (git, curl, wget, etc.) "
echo ""
echo " To remove Docker completely, run: "
echo " apt-get remove docker-ce docker-ce-cli containerd.io docker-compose "
echo " rm -rf /var/lib/docker "
echo ""
echo "*************************************************************************"
echo ""
echo "Thank you for using HBlink3 Docker Installer!"
echo ""
exit 0