librelad bdaec0c03b fix(install): resolve the 7-Zip package name per release
`apt install p7zip*` only still resolves on Debian 13 / Ubuntu 24.04+
because the renamed `7zip` package happens to declare `Provides: p7zip`.
That is an alias we don't control, so pick the real package name against
the freshly-updated lists instead: `7zip` where it exists, `p7zip-full`
otherwise. Match on a real package stanza rather than apt-cache's exit
status, which returns 0 with empty output for provided-only names.

Also in this path:
- apt -> apt-get for the scripted calls, so the "apt does not have a
  stable CLI interface" warning stops polluting the captured $result.
- drop a duplicated `pv` from the package list.
- move the package list below `apt-get update` so the 7-Zip probe reads
  current lists.

Debian 10 sysctl check now reads OS_TYPE/OS_VERSION from detectOS rather
than shelling out to lsb_release, which minimal images don't ship. This
also stops a non-Debian release numbered "10" from matching.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-01 10:55:30 +01:00

58 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
installDebianUbuntu()
{
if [[ "$OS_TYPE" == "Ubuntu" || "$OS_TYPE" == "Debian" ]]; then
# OS package management needs real root. A root install runs apt directly
# (and bootstraps sudo itself on a bare box); the hardened de-sudo manager
# is deliberately NOT granted `sudo apt` — the LP_SYSTEM sudoers allowlist
# scopes systemctl/ufw/sysctl/loginctl/service, never apt. So at manager
# runtime skip cleanly instead of logging apt permission failures (exit
# 100) on every preinstall pass; OS/security updates are a host /
# install-time concern there. `priv` is the privilege prefix: empty when
# we're already root, "sudo" only where sudo-apt is actually permitted.
local priv=""
if [[ $EUID -ne 0 ]]; then
if sudo -n apt-get --version >/dev/null 2>&1; then
priv="sudo"
else
isNotice "OS package updates need root and aren't permitted for the manager — skipping (handled at install time / by the host)."
return 0
fi
fi
if checkIfOSUpdateShouldRun; then
isNotice "Installing System Updates... this may take a while."
if [[ "$OS_TYPE" == "Debian" ]]; then
export DEBIAN_FRONTEND="noninteractive"
fi
local result; result=$(DEBIAN_FRONTEND=noninteractive APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 $priv apt-get update -qq 2>&1 && DEBIAN_FRONTEND=noninteractive APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 $priv apt-get install sudo -yqq 2>&1 && $priv apt-get autoclean 2>&1)
checkSuccess "Updating System Operating system."
local result; result=$(DEBIAN_FRONTEND=noninteractive APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 $priv apt-get update -qq 2>&1)
checkSuccess "Running application update"
# 7-Zip changed package name: Debian 13 and Ubuntu 24.04+ ship `7zip`, older
# releases ship `p7zip-full`. Resolve against the freshly-updated package
# lists rather than relying on a `p7zip*` glob — that only still matches on
# new releases because `7zip` happens to declare `Provides: p7zip`.
# Match on a real package stanza, not just apt-cache's exit status — it
# returns 0 with empty output for virtual/provided-only names.
local sevenzip="p7zip-full"
if apt-cache show 7zip 2>/dev/null | grep -q .; then
sevenzip="7zip"
fi
installed_apps="apt-get install curl dialog pv wget git zip htop sqlite3 sshpass rsync acl apache2-utils inotify-tools jq $sevenzip"
local result; result=$(DEBIAN_FRONTEND=noninteractive APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 $priv $installed_apps -yqq 2>&1)
checkSuccess "Installing system applications"
else
isNotice "System Updates already ran within the last ${CFG_UPDATER_CHECK} minutes, skipping..."
fi
$priv mkdir -p "$(dirname "$sysctl")"
$priv touch $sysctl
fi
}