Compare commits

...

7 Commits

Author SHA1 Message Date
MickLesk
6c05f7f858 perf(tools.func, alpine-tools.func): replace direct /etc/os-release reads with get_os_info(), echo|tr with bash builtins, consolidate pipelines
- get_os_info(): single while-read replaces 4 awk subprocesses on first call
- manage_tool_repository(): 7 awk|tr pipelines → get_os_info() cached lookups
- setup_hwaccel(): 3 grep|tr pipelines → get_os_info()
- setup_java/mysql/php/postgresql/clickhouse(): 2 awk|tr pipelines each → get_os_info()
- 6× echo|tr -d ' ' → bash parameter expansion (${var// /})
- 3× mod=$(echo|tr) → bash ${mod//[[:space:]]/}
- npm/apt-cache/cargo pipelines: grep|awk|tr → single awk with gsub
- COMBINED_MODULES: echo|tr|awk|paste (4 proc) → single awk with RS
- download_with_progress: awk|tr → awk gsub (both tools.func and alpine-tools.func)

Eliminates ~30 subprocess forks across typical tool setup paths.
2026-03-23 20:57:08 +01:00
MickLesk
be52f8e223 style: formatting cleanup in api.func and core.func 2026-03-23 20:46:34 +01:00
MickLesk
2008b1b458 perf(misc): optimize network checks, IP detection, and subprocess chains
Files: install.func, alpine-install.func, core.func, api.func

Changes:
- install.func: Cache hostname -I result in setting_up_container() —
  eliminates 3 redundant calls (retry loop + post-check + display).
  Single awk extracts first IP from cached call.

- alpine-install.func: Cache ip addr result in setting_up_container() —
  replaces 3 identical 4-process pipelines (ip|grep|grep|awk|cut) with
  one call using single awk (sub+print in one pass).

- core.func get_lxc_ip(): Merge awk+cut into single awk (sub+print)
  for eth0 IPv4/IPv6 lookups. Replace tr|grep pipeline for IPv6 hostname
  fallback with bash array iteration (read -ra + for loop).

- api.func detect_gpu(): Merge 2x sed + cut into single sed -E + bash
  substring. detect_cpu(): Merge 4x sed + cut into single sed -E + bash
  substring. get_error_text(): Merge 2x sed into single sed -E.
  post_addon_to_api(): Replace 2x grep|cut|tr on /etc/os-release with
  single while-read loop (1 file read instead of 6 subprocess forks).
2026-03-23 20:44:47 +01:00
MickLesk
a02bdf083d perf(build.func): eliminate subprocess forks in settings, hostname, and template discovery
Changes:
- Replace 6x echo|sed with bash parameter expansion in
  _build_current_app_vars_tmp() — eliminates 12 subprocess forks
  (6 echo + 6 sed) per advanced settings save cycle.

- Replace 4x echo|tr with bash builtins for lowercase + space
  removal in variables(), base_settings(), advanced_settings()
  hostname and tags handling — eliminates 8 subprocess forks.

- Consolidate 4 grep|awk|grep pipelines in template discovery to
  single awk passes — each template search now uses 1 awk process
  instead of 3 (grep + awk + grep). Applied to all online template
  and version discovery paths in create_lxc_container().

- Consolidate 2 grep|cut reads in ensure_storage_selection_for_vars_file()
  to single while-read loop — 1 file read instead of 2.
2026-03-23 20:39:40 +01:00
MickLesk
21e215dc1b perf(build.func): cache pveam calls, consolidate hostname/sed, pre-warm pvesm
Changes:
- Add pveam_cached() function with associative array cache for
  pveam available/list calls. Eliminates 5 redundant 'pveam available
  -section system' calls (each involves network I/O + catalog parsing)
  and 2 redundant 'pveam list' calls during template discovery.
  Cache is invalidated after pveam download for fresh post-check.

- Consolidate get_current_ip(): single 'hostname -I' call with bash
  array parsing instead of 2 calls piped through tr/grep/head.
  Pure bash regex matching replaces external grep for IPv4 detection.

- Batch update_motd_ip(): single sed pass with 3 expressions replaces
  3 separate grep + sed pairs (6 file reads → 1 read + 1 write).
  Read /etc/os-release once with sed instead of 2 grep|cut|tr pipes.

- Pre-warm pvesm cache at create_lxc_container() start: fetches
  pvesm status (unfiltered, rootdir, vztmpl) in 3 calls upfront so
  all subsequent pvesm_status_cached calls are instant cache hits.
2026-03-23 20:33:41 +01:00
MickLesk
6b9930c8df refactor(build.func): extract nested functions, recursion guard, GPU timeout, pvesm cache
Changes:
- Extract 7 functions from build_container() to module level:
  is_gpu_app(), detect_gpu_devices(), configure_usb_passthrough(),
  configure_gpu_passthrough(), configure_additional_devices(),
  get_container_gid(), pvesm_status_cached()
  Prevents function re-declaration on recursive retry attempts.

- Add recursion guard (_BUILD_DEPTH max 3) to build_container()
  to prevent infinite OOM→retry→OOM→retry loops (exit code 250).

- Add 30s timeout to multi-GPU selection prompt with auto-select
  fallback for the first available GPU type.

- Add pvesm_status_cached() with associative array cache keyed by
  arguments. Eliminates ~10 redundant pvesm subprocess calls during
  a single container creation flow. Applied to: check_storage_support(),
  select_storage(), resolve_storage_preselect(), create_lxc_container()
  rootdir/vztmpl validation, validate_storage_space(),
  choose_and_set_storage_for_file(), and settings validation.

- Simplify check_storage_support() from while-read loop to single
  pipeline with grep.
2026-03-23 20:26:36 +01:00
MickLesk
c3cb983085 perf(build.func): parallel IP scanning, sysfs bridge detection, GPU GID pre-start, VAR_WHITELIST consolidation, IPv6 description
Performance:
- resolve_ip_from_range(): parallel ping in batches of 10 (up to 10x faster)
  + Added bounds validation (start > end check)
  + Added range cap at 254 IPs to prevent excessive scanning
- _detect_bridges(): replaced 30-line config file parser with sysfs lookup
  (instant /sys/class/net/*/bridge detection + OVS bridge support)
  + Bridge descriptions now searched across interfaces.d/ too
- fix_gpu_gids(): read GIDs from mounted rootfs before first container start
  → eliminates 3+ second stop/edit/restart cycle for GPU passthrough

Bugfix:
- VAR_WHITELIST: consolidated 3 separate declarations into single global
  + Global copy was missing var_keyctl, var_mknod, var_mount_fs, var_nesting,
    var_protection, var_timezone, var_searchdomain — these were silently
    dropped from app defaults when default_var_settings() wasn't in scope

Edge case:
- description(): added IPv6 fallback for IPv6-only containers
2026-03-23 20:15:45 +01:00
7 changed files with 575 additions and 459 deletions

View File

@@ -67,22 +67,22 @@ EOF
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
setting_up_container() {
msg_info "Setting up Container OS"
local _ip=""
while [ $i -gt 0 ]; do
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then
break
fi
_ip=$(ip -4 addr show 2>/dev/null | awk '/inet [0-9]/ && !/127\.0\.0\.1/ {sub(/\/.*/, "", $2); print $2; exit}')
[[ -n "$_ip" ]] && break
echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY
i=$((i - 1))
done
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then
if [[ -z "$_ip" ]]; then
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
echo -e "${NETWORK}Check Network Settings"
exit 121
fi
msg_ok "Set up Container OS"
msg_ok "Network Connected: ${BL}$(ip addr show | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1 | tail -n1)${CL}"
msg_ok "Network Connected: ${BL}${_ip}${CL}"
post_progress_to_api
}

View File

@@ -53,7 +53,7 @@ download_with_progress() {
# $1 url, $2 dest
local url="$1" out="$2" cl
need_tool curl pv || return 1
cl=$(curl -fsSLI "$url" 2>/dev/null | awk 'tolower($0) ~ /^content-length:/ {print $2}' | tr -d '\r')
cl=$(curl -fsSLI "$url" 2>/dev/null | awk 'tolower($0) ~ /^content-length:/ {gsub(/\r/,""); print $2}')
if [ -n "$cl" ]; then
curl -fsSL "$url" | pv -s "$cl" >"$out" || {
msg_error "Download failed: $url"

View File

@@ -348,10 +348,10 @@ explain_exit_code() {
json_escape() {
# Escape a string for safe JSON embedding using awk (handles any input size).
# Pipeline: strip ANSI → remove control chars → escape \ " TAB → join lines with \n
printf '%s' "$1" \
| sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' \
| tr -d '\000-\010\013\014\016-\037\177\r' \
| awk '
printf '%s' "$1" |
sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' |
tr -d '\000-\010\013\014\016-\037\177\r' |
awk '
BEGIN { ORS = "" }
{
gsub(/\\/, "\\\\") # backslash → \\
@@ -401,7 +401,7 @@ get_error_text() {
fi
if [[ -n "$logfile" && -s "$logfile" ]]; then
tail -n 20 "$logfile" 2>/dev/null | sed 's/\r$//' | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g'
tail -n 20 "$logfile" 2>/dev/null | sed -E 's/\r$//; s/\x1b\[[0-9;]*[a-zA-Z]//g'
fi
}
@@ -508,7 +508,8 @@ detect_gpu() {
if [[ -n "$gpu_line" ]]; then
# Extract model: everything after the colon, clean up
GPU_MODEL=$(echo "$gpu_line" | sed 's/.*: //' | sed 's/ (rev .*)$//' | cut -c1-64)
GPU_MODEL=$(echo "$gpu_line" | sed -E 's/.*: //; s/ \(rev .*\)$//')
GPU_MODEL="${GPU_MODEL:0:64}"
# Detect vendor and passthrough type
if echo "$gpu_line" | grep -qi "Intel"; then
@@ -557,7 +558,8 @@ detect_cpu() {
esac
# Extract model name and clean it up
CPU_MODEL=$(grep -m1 "model name" /proc/cpuinfo 2>/dev/null | cut -d: -f2 | sed 's/^ *//' | sed 's/(R)//g' | sed 's/(TM)//g' | sed 's/ */ /g' | cut -c1-64)
CPU_MODEL=$(grep -m1 "model name" /proc/cpuinfo 2>/dev/null | cut -d: -f2 | sed -E 's/^ *//; s/\(R\)//g; s/\(TM\)//g; s/ +/ /g')
CPU_MODEL="${CPU_MODEL:0:64}"
fi
export CPU_VENDOR CPU_MODEL
@@ -1325,11 +1327,16 @@ post_addon_to_api() {
error_category=$(categorize_error "$exit_code")
fi
# Detect OS info
# Detect OS info (single read)
local os_type="" os_version=""
if [[ -f /etc/os-release ]]; then
os_type=$(grep "^ID=" /etc/os-release | cut -d= -f2 | tr -d '"')
os_version=$(grep "^VERSION_ID=" /etc/os-release | cut -d= -f2 | tr -d '"')
while IFS='=' read -r _k _v; do
_v="${_v//\"/}"
case "$_k" in
ID) os_type="$_v" ;;
VERSION_ID) os_version="$_v" ;;
esac
done </etc/os-release
fi
local JSON_PAYLOAD

File diff suppressed because it is too large Load Diff

View File

@@ -1644,7 +1644,7 @@ function get_lxc_ip() {
local ip
# Try direct interface lookup for eth0 FIRST (most reliable for LXC) - IPv4
ip=$(ip -4 addr show eth0 2>/dev/null | awk '/inet / {print $2}' | cut -d/ -f1 | head -n1)
ip=$(ip -4 addr show eth0 2>/dev/null | awk '/inet / {sub(/\/.*/, "", $2); print $2; exit}')
if [[ -n "$ip" && "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$ip"
return 0
@@ -1652,11 +1652,14 @@ function get_lxc_ip() {
# Fallback: Try hostname -I (returns IPv4 first if available)
if command -v hostname >/dev/null 2>&1; then
ip=$(hostname -I 2>/dev/null | awk '{print $1}')
if [[ -n "$ip" && "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$ip"
return 0
fi
local -a _ips
read -ra _ips <<<"$(hostname -I 2>/dev/null)"
for ip in "${_ips[@]}"; do
if [[ "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "$ip"
return 0
fi
done
fi
# Try routing table with IPv4 targets
@@ -1674,7 +1677,7 @@ function get_lxc_ip() {
done
# IPv6 fallback: Try direct interface lookup for eth0
ip=$(ip -6 addr show eth0 scope global 2>/dev/null | awk '/inet6 / {print $2}' | cut -d/ -f1 | head -n1)
ip=$(ip -6 addr show eth0 scope global 2>/dev/null | awk '/inet6 / {sub(/\/.*/, "", $2); print $2; exit}')
if [[ -n "$ip" && "$ip" =~ : ]]; then
echo "$ip"
return 0
@@ -1682,11 +1685,14 @@ function get_lxc_ip() {
# IPv6 fallback: Try hostname -I for IPv6
if command -v hostname >/dev/null 2>&1; then
ip=$(hostname -I 2>/dev/null | tr ' ' '\n' | grep -E ':' | head -n1)
if [[ -n "$ip" && "$ip" =~ : ]]; then
echo "$ip"
return 0
fi
local -a _ips6
read -ra _ips6 <<<"$(hostname -I 2>/dev/null)"
for ip in "${_ips6[@]}"; do
[[ "$ip" == *:* ]] && {
echo "$ip"
return 0
}
done
fi
# IPv6 fallback: Use routing table with IPv6 targets

View File

@@ -116,14 +116,14 @@ setting_up_container() {
(chown root:root / 2>/dev/null) || true
fi
local _host_ip=""
for ((i = RETRY_NUM; i > 0; i--)); do
if [ "$(hostname -I)" != "" ]; then
break
fi
_host_ip=$(hostname -I 2>/dev/null | awk '{print $1}')
[[ -n "$_host_ip" ]] && break
echo 1>&2 -en "${CROSS}${RD} No Network! "
sleep $RETRY_EVERY
done
if [ "$(hostname -I)" = "" ]; then
if [[ -z "$_host_ip" ]]; then
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
echo -e "${NETWORK}Check Network Settings"
exit 121
@@ -131,8 +131,7 @@ setting_up_container() {
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
systemctl disable -q --now systemd-networkd-wait-online.service
msg_ok "Set up Container OS"
#msg_custom "${CM}" "${GN}" "Network Connected: ${BL}$(hostname -I)"
msg_ok "Network Connected: ${BL}$(hostname -I)"
msg_ok "Network Connected: ${BL}${_host_ip}"
post_progress_to_api
}

View File

@@ -700,7 +700,7 @@ manage_tool_repository() {
local gpg_key_url="${4:-}"
local distro_id repo_component suite
distro_id=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
distro_id=$(get_os_info id)
case "$tool_name" in
mariadb)
@@ -714,7 +714,7 @@ manage_tool_repository() {
# Get suite for fallback handling
local distro_codename
distro_codename=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
distro_codename=$(get_os_info codename)
suite=$(get_fallback_suite "$distro_id" "$distro_codename" "$repo_url/$distro_id")
# Setup new repository using deb822 format
@@ -745,7 +745,7 @@ manage_tool_repository() {
# Setup repository
local distro_codename
distro_codename=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
distro_codename=$(get_os_info codename)
# Suite mapping with fallback for newer releases not yet supported by upstream
if [[ "$distro_id" == "debian" ]]; then
@@ -816,7 +816,7 @@ EOF
# NodeSource uses deb822 format with GPG from repo
local distro_codename
distro_codename=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
distro_codename=$(get_os_info codename)
# Download GPG key from NodeSource with retry logic
if ! download_gpg_key "$gpg_key_url" "/etc/apt/keyrings/nodesource.gpg" "dearmor"; then
@@ -858,7 +858,7 @@ EOF
# Setup repository
local distro_codename
distro_codename=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
distro_codename=$(get_os_info codename)
cat <<EOF >/etc/apt/sources.list.d/php.sources
Types: deb
URIs: https://packages.sury.org/php
@@ -886,7 +886,7 @@ EOF
# Setup repository
local distro_codename
distro_codename=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
distro_codename=$(get_os_info codename)
cat <<EOF >/etc/apt/sources.list.d/postgresql.sources
Types: deb
URIs: http://apt.postgresql.org/pub/repos/apt
@@ -1323,10 +1323,16 @@ get_os_info() {
# Cache OS info to avoid repeated file reads
if [[ -z "${_OS_ID:-}" ]]; then
export _OS_ID=$(awk -F= '/^ID=/{gsub(/"/,"",$2); print $2}' /etc/os-release)
export _OS_CODENAME=$(awk -F= '/^VERSION_CODENAME=/{gsub(/"/,"",$2); print $2}' /etc/os-release)
export _OS_VERSION=$(awk -F= '/^VERSION_ID=/{gsub(/"/,"",$2); print $2}' /etc/os-release)
export _OS_VERSION_FULL=$(awk -F= '/^VERSION=/{gsub(/"/,"",$2); print $2}' /etc/os-release)
local _line
while IFS='=' read -r _key _val; do
_val="${_val//\"/}"
case "$_key" in
ID) export _OS_ID="$_val" ;;
VERSION_CODENAME) export _OS_CODENAME="$_val" ;;
VERSION_ID) export _OS_VERSION="$_val" ;;
VERSION) export _OS_VERSION_FULL="$_val" ;;
esac
done </etc/os-release
fi
case "$field" in
@@ -2144,8 +2150,8 @@ fetch_and_deploy_gh_tag() {
local repo="$2"
local version="${3:-latest}"
local target="${4:-/opt/$app}"
local app_lc=""
app_lc="$(echo "${app,,}" | tr -d ' ')"
local app_lc="${app,,}"
app_lc="${app_lc// /}"
local version_file="$HOME/.${app_lc}"
if [[ "$version" == "latest" ]]; then
@@ -2221,8 +2227,8 @@ check_for_gh_tag() {
local app="$1"
local repo="$2"
local prefix="${3:-}"
local app_lc=""
app_lc="$(echo "${app,,}" | tr -d ' ')"
local app_lc="${app,,}"
app_lc="${app_lc// /}"
local current_file="$HOME/.${app_lc}"
msg_info "Checking for update: ${app}"
@@ -2272,8 +2278,8 @@ check_for_gh_release() {
local source="$2"
local pinned_version_in="${3:-}" # optional
local pin_reason="${4:-}" # optional reason shown to user
local app_lc=""
app_lc="$(echo "${app,,}" | tr -d ' ')"
local app_lc="${app,,}"
app_lc="${app_lc// /}"
local current_file="$HOME/.${app_lc}"
msg_info "Checking for update: ${app}"
@@ -2600,7 +2606,8 @@ create_self_signed_cert() {
local APP_NAME="${1:-${APPLICATION}}"
local HOSTNAME="$(hostname -f)"
local IP="$(hostname -I | awk '{print $1}')"
local APP_NAME_LC=$(echo "${APP_NAME,,}" | tr -d ' ')
local APP_NAME_LC="${APP_NAME,,}"
APP_NAME_LC="${APP_NAME_LC// /}"
local CERT_DIR="/etc/ssl/${APP_NAME_LC}"
local CERT_KEY="${CERT_DIR}/${APP_NAME_LC}.key"
local CERT_CRT="${CERT_DIR}/${APP_NAME_LC}.crt"
@@ -2647,7 +2654,7 @@ function download_with_progress() {
# Content-Length aus HTTP-Header holen
local content_length
content_length=$(curl -fsSLI "$url" | awk '/Content-Length/ {print $2}' | tr -d '\r' || true)
content_length=$(curl -fsSLI "$url" | awk '/Content-Length/ {gsub(/\r/,""); print $2}' || true)
if [[ -z "$content_length" ]]; then
if ! curl -fL# -o "$output" "$url"; then
@@ -2766,7 +2773,8 @@ function fetch_and_deploy_codeberg_release() {
local target="${5:-/opt/$app}"
local asset_pattern="${6:-}"
local app_lc=$(echo "${app,,}" | tr -d ' ')
local app_lc="${app,,}"
app_lc="${app_lc// /}"
local version_file="$HOME/.${app_lc}"
local api_timeouts=(60 120 240)
@@ -3318,7 +3326,8 @@ function fetch_and_deploy_gh_release() {
fi
fi
local app_lc=$(echo "${app,,}" | tr -d ' ')
local app_lc="${app,,}"
app_lc="${app_lc// /}"
local version_file="$HOME/.${app_lc}"
local api_timeouts=(60 120 240)
@@ -4409,7 +4418,7 @@ function setup_hwaccel() {
# Parse comma-separated numbers
IFS=',' read -ra nums <<<"$selection"
for num in "${nums[@]}"; do
num=$(echo "$num" | tr -d ' ')
num="${num// /}"
if [[ "$num" =~ ^[0-9]+$ ]] && ((num >= 1 && num <= gpu_count)); then
SELECTED_INDICES+=("$((num - 1))")
fi
@@ -4451,9 +4460,9 @@ function setup_hwaccel() {
# OS Detection
# ═══════════════════════════════════════════════════════════════════════════
local os_id os_codename os_version
os_id=$(grep -oP '(?<=^ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "debian")
os_codename=$(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "unknown")
os_version=$(grep -oP '(?<=^VERSION_ID=).+' /etc/os-release 2>/dev/null | tr -d '"' || echo "")
os_id=$(get_os_info id)
os_codename=$(get_os_info codename)
os_version=$(get_os_info version)
[[ -z "$os_id" ]] && os_id="debian"
local in_ct="${CTTYPE:-0}"
@@ -5339,8 +5348,8 @@ function setup_imagemagick() {
function setup_java() {
local JAVA_VERSION="${JAVA_VERSION:-21}"
local DISTRO_ID DISTRO_CODENAME
DISTRO_ID=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
DISTRO_CODENAME=$(awk -F= '/VERSION_CODENAME/ { print $2 }' /etc/os-release)
DISTRO_ID=$(get_os_info id)
DISTRO_CODENAME=$(get_os_info codename)
local DESIRED_PACKAGE="temurin-${JAVA_VERSION}-jdk"
# Prepare repository (cleanup + validation)
@@ -5595,7 +5604,7 @@ EOF
if [[ -n "$CURRENT_VERSION" ]]; then
# Get available distro version
local DISTRO_VERSION=""
DISTRO_VERSION=$(apt-cache policy mariadb-server 2>/dev/null | grep -E "Candidate:" | awk '{print $2}' | grep -oP '^\d+:\K\d+\.\d+\.\d+' || echo "")
DISTRO_VERSION=$(apt-cache policy mariadb-server 2>/dev/null | awk '/Candidate:/ {sub(/^[0-9]+:/, "", $2); print $2}' || echo "")
if [[ -n "$DISTRO_VERSION" ]]; then
# Compare versions - if current is higher, keep it
@@ -5996,8 +6005,8 @@ function setup_mysql() {
local MYSQL_VERSION="${MYSQL_VERSION:-8.0}"
local USE_MYSQL_REPO="${USE_MYSQL_REPO:-true}"
local DISTRO_ID DISTRO_CODENAME
DISTRO_ID=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
DISTRO_CODENAME=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
DISTRO_ID=$(get_os_info id)
DISTRO_CODENAME=$(get_os_info codename)
# Ensure non-interactive mode for all apt operations
export DEBIAN_FRONTEND=noninteractive
@@ -6343,7 +6352,7 @@ function setup_nodejs() {
# Check if the module is already installed
if $STD npm list -g --depth=0 "$MODULE_NAME" 2>&1 | grep -q "$MODULE_NAME@"; then
MODULE_INSTALLED_VERSION="$(npm list -g --depth=0 "$MODULE_NAME" 2>&1 | grep "$MODULE_NAME@" | awk -F@ '{print $2}' 2>/dev/null | tr -d '[:space:]' || echo '')"
MODULE_INSTALLED_VERSION="$(npm list -g --depth=0 "$MODULE_NAME" 2>&1 | awk -F@ -v mod="$MODULE_NAME" '$0 ~ mod"@" {gsub(/[[:space:]]/, "", $2); print $2}' || echo '')"
if [[ "$MODULE_REQ_VERSION" != "latest" && "$MODULE_REQ_VERSION" != "$MODULE_INSTALLED_VERSION" ]]; then
msg_info "Updating $MODULE_NAME from v$MODULE_INSTALLED_VERSION to v$MODULE_REQ_VERSION"
if ! $STD npm install -g "${MODULE_NAME}@${MODULE_REQ_VERSION}" 2>/dev/null; then
@@ -6414,8 +6423,8 @@ function setup_php() {
local PHP_APACHE="${PHP_APACHE:-NO}"
local PHP_FPM="${PHP_FPM:-NO}"
local DISTRO_ID DISTRO_CODENAME
DISTRO_ID=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
DISTRO_CODENAME=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
DISTRO_ID=$(get_os_info id)
DISTRO_CODENAME=$(get_os_info codename)
# Parse version for compatibility checks
local PHP_MAJOR="${PHP_VERSION%%.*}"
@@ -6462,7 +6471,7 @@ function setup_php() {
local FILTERED_MODULES=""
IFS=',' read -ra ALL_MODULES <<<"$COMBINED_MODULES"
for mod in "${ALL_MODULES[@]}"; do
mod=$(echo "$mod" | tr -d '[:space:]')
mod="${mod//[[:space:]]/}"
[[ -z "$mod" ]] && continue
# Skip if it's a known built-in module
@@ -6479,7 +6488,7 @@ function setup_php() {
done
# Deduplicate
COMBINED_MODULES=$(echo "$FILTERED_MODULES" | tr ',' '\n' | awk '!seen[$0]++' | paste -sd, -)
COMBINED_MODULES=$(awk -v RS=',' '!seen[$0]++{printf "%s%s", sep, $0; sep=","}' <<<"$FILTERED_MODULES")
# Get current PHP-CLI version
local CURRENT_PHP=""
@@ -6548,7 +6557,7 @@ EOF
IFS=',' read -ra MODULES <<<"$COMBINED_MODULES"
for mod in "${MODULES[@]}"; do
mod=$(echo "$mod" | tr -d '[:space:]')
mod="${mod//[[:space:]]/}"
[[ -z "$mod" ]] && continue
local pkg_name="php${PHP_VERSION}-${mod}"
@@ -6727,8 +6736,8 @@ setup_postgresql() {
local PG_MODULES="${PG_MODULES:-}"
local USE_PGDG_REPO="${USE_PGDG_REPO:-true}"
local DISTRO_ID DISTRO_CODENAME
DISTRO_ID=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
DISTRO_CODENAME=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
DISTRO_ID=$(get_os_info id)
DISTRO_CODENAME=$(get_os_info codename)
# Ensure non-interactive mode for all apt operations
export DEBIAN_FRONTEND=noninteractive
@@ -7571,8 +7580,8 @@ EOF
function setup_clickhouse() {
local CLICKHOUSE_VERSION="${CLICKHOUSE_VERSION:-latest}"
local DISTRO_ID DISTRO_CODENAME
DISTRO_ID=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d '"')
DISTRO_CODENAME=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
DISTRO_ID=$(get_os_info id)
DISTRO_CODENAME=$(get_os_info codename)
# Ensure non-interactive mode for all apt operations
export DEBIAN_FRONTEND=noninteractive
@@ -7786,7 +7795,7 @@ function setup_rust() {
# Check if already installed
if echo "$CRATE_LIST" | grep -q "^${NAME} "; then
INSTALLED_VER=$(echo "$CRATE_LIST" | grep "^${NAME} " | head -1 | awk '{print $2}' 2>/dev/null | tr -d 'v:' || echo '')
INSTALLED_VER=$(echo "$CRATE_LIST" | grep "^${NAME} " | head -1 | awk '{gsub(/[v:]/, "", $2); print $2}' || echo '')
if [[ -n "$VER" && "$VER" != "$INSTALLED_VER" ]]; then
msg_info "Upgrading $NAME from v$INSTALLED_VER to v$VER"