mirror of
https://github.com/ShaYmez/hblink3-docker-install.git
synced 2025-12-22 21:49:50 +13:00
Simplify installer for modern approach - remove version-specific duplications
Co-authored-by: ShaYmez <76499782+ShaYmez@users.noreply.github.com>
This commit is contained in:
parent
0246fe7c27
commit
73cceaf444
@ -146,15 +146,13 @@ Within this installation includes the new HBMonv2 by Weldek SP2ONG
|
|||||||
|
|
||||||
### Technical Details - Python Package Management
|
### 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`
|
- 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
|
- 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
|
- The systemd service automatically uses the virtual environment's Python interpreter
|
||||||
- This approach eliminates "externally-managed-environment" errors and conflicts with system packages
|
- 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 across all Debian versions.
|
||||||
|
|
||||||
This ensures clean, maintainable installations that follow modern Python best practices while maintaining compatibility with older Debian versions.
|
|
||||||
|
|
||||||
## Easy Installation And Upgrade
|
## 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.
|
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.
|
||||||
|
|||||||
@ -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")
|
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}')
|
ARC=$(lscpu | grep Arch | awk '{print $2}')
|
||||||
VERSION=$(sed 's/\..*//' /etc/debian_version)
|
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/
|
INSDIR=/opt/tmp/
|
||||||
HBLINKTMP=/opt/tmp/hblink3
|
HBLINKTMP=/opt/tmp/hblink3
|
||||||
HBMONDIR=/opt/HBMonv2/
|
HBMONDIR=/opt/HBMonv2/
|
||||||
HBDIR=/etc/hblink3/
|
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"
|
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"
|
||||||
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"
|
|
||||||
HBGITREPO=https://github.com/ShaYmez/hblink3.git
|
HBGITREPO=https://github.com/ShaYmez/hblink3.git
|
||||||
HBGITMONREPO=https://github.com/ShaYmez/HBMonv2.git
|
HBGITMONREPO=https://github.com/ShaYmez/HBMonv2.git
|
||||||
echo ""
|
echo ""
|
||||||
@ -75,14 +69,10 @@ install_docker_and_dependencies() {
|
|||||||
local version=$1
|
local version=$1
|
||||||
echo "Detected Debian version: $version"
|
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
|
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
|
apt-get install -y $DEP
|
||||||
fi
|
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Remove old Docker versions if present
|
# Remove old Docker versions if present
|
||||||
@ -262,12 +252,10 @@ echo "Installing HBMonv2 configuration....."
|
|||||||
echo "------------------------------------------------------------------------------"
|
echo "------------------------------------------------------------------------------"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Helper function to install pip packages with Debian 12+ compatibility
|
# Helper function to install pip packages in virtual environment
|
||||||
pip_install() {
|
pip_install() {
|
||||||
local args="$@"
|
local args="$@"
|
||||||
if [ $VERSION -ge 12 ]; then
|
echo "Installing Python packages: $args"
|
||||||
# For Debian 12+, use virtual environment (PEP 668 compliant)
|
|
||||||
echo "Installing Python packages for Debian $VERSION: $args"
|
|
||||||
if [ -z "$VIRTUAL_ENV" ]; then
|
if [ -z "$VIRTUAL_ENV" ]; then
|
||||||
echo "ERROR: Virtual environment not activated"
|
echo "ERROR: Virtual environment not activated"
|
||||||
return 1
|
return 1
|
||||||
@ -279,25 +267,13 @@ pip_install() {
|
|||||||
echo "ERROR: Failed to install: $args"
|
echo "ERROR: Failed to install: $args"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
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
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Installing Python dependencies..."
|
echo "Installing Python dependencies..."
|
||||||
cd $HBMONDIR
|
cd $HBMONDIR
|
||||||
|
|
||||||
# For Debian 12+, create and use a virtual environment (modern PEP 668 compliant approach)
|
# Create and use a virtual environment (modern approach for all Debian versions)
|
||||||
if [ $VERSION -ge 12 ]; then
|
echo "Creating Python virtual environment..."
|
||||||
echo "Creating Python virtual environment for Debian $VERSION..."
|
|
||||||
|
|
||||||
# Create virtual environment
|
# Create virtual environment
|
||||||
if [ ! -d "$HBMONDIR/venv" ]; then
|
if [ ! -d "$HBMONDIR/venv" ]; then
|
||||||
@ -320,7 +296,6 @@ if [ $VERSION -ge 12 ]; then
|
|||||||
if ! pip3 install --upgrade pip; then
|
if ! pip3 install --upgrade pip; then
|
||||||
echo "WARNING: Failed to upgrade pip in virtual environment, continuing with existing version..."
|
echo "WARNING: Failed to upgrade pip in virtual environment, continuing with existing version..."
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Install setuptools and wheel first
|
# Install setuptools and wheel first
|
||||||
if ! pip_install setuptools wheel; then
|
if ! pip_install setuptools wheel; then
|
||||||
@ -401,8 +376,7 @@ LOG_NAME = 'hbmon.log'
|
|||||||
EOF
|
EOF
|
||||||
cp utils/hbmon.service /lib/systemd/system/
|
cp utils/hbmon.service /lib/systemd/system/
|
||||||
|
|
||||||
# For Debian 12+, update the service file to use virtual environment
|
# Update the service file to use virtual environment (for all Debian versions)
|
||||||
if [ $VERSION -ge 12 ]; then
|
|
||||||
echo "Updating hbmon.service to use virtual environment..."
|
echo "Updating hbmon.service to use virtual environment..."
|
||||||
# Update ExecStart to use venv Python (only if not already using venv)
|
# 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
|
if ! grep -q "$HBMONDIR/venv/bin/python3" /lib/systemd/system/hbmon.service; then
|
||||||
@ -420,7 +394,6 @@ EOF
|
|||||||
else
|
else
|
||||||
echo "Service file already configured to use virtual environment"
|
echo "Service file already configured to use virtual environment"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
cp utils/lastheard /etc/cron.daily/
|
cp utils/lastheard /etc/cron.daily/
|
||||||
chmod +x /etc/cron.daily/lastheard
|
chmod +x /etc/cron.daily/lastheard
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user