2026-01-06 13:28:12 +01:00
|
|
|
# Copyright (c) 2021-2026 community-scripts ORG
|
2024-12-16 12:41:51 +01:00
|
|
|
# Author: tteck (tteckster)
|
|
|
|
|
# Co-Author: MickLesk
|
2025-06-20 13:28:06 +02:00
|
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
2023-03-22 20:48:20 -04:00
|
|
|
|
2025-06-20 13:28:06 +02:00
|
|
|
if ! command -v curl >/dev/null 2>&1; then
|
|
|
|
|
apk update && apk add curl >/dev/null 2>&1
|
|
|
|
|
fi
|
|
|
|
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/core.func)
|
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture (#9540)
* Refactor Core
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
* Delete config-file.func
* Update install.func
* Refactor stop_all_services function and variable names
Refactor service stopping logic and improve variable handling
* Refactor installation script and update copyright
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
* Update install.func
* Update license comment format in install.func
* Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
* big core refactor
* Enhance IPv6 configuration menu options
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
* Update default Node.js version to 24 LTS
* Update misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
* indention
* remove debugf and duplicate codes
* Update whiptail backtitles and error codes
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
* comments
* Refactor error handling and clean up debug comments
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
* Update build.func
* feat: Improve LXC network checks and LINSTOR storage handling
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
---------
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2025-12-04 07:52:18 +01:00
|
|
|
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/error_handler.func)
|
2025-06-20 13:28:06 +02:00
|
|
|
load_functions
|
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture (#9540)
* Refactor Core
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
* Delete config-file.func
* Update install.func
* Refactor stop_all_services function and variable names
Refactor service stopping logic and improve variable handling
* Refactor installation script and update copyright
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
* Update install.func
* Update license comment format in install.func
* Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
* big core refactor
* Enhance IPv6 configuration menu options
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
* Update default Node.js version to 24 LTS
* Update misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
* indention
* remove debugf and duplicate codes
* Update whiptail backtitles and error codes
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
* comments
* Refactor error handling and clean up debug comments
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
* Update build.func
* feat: Improve LXC network checks and LINSTOR storage handling
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
---------
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2025-12-04 07:52:18 +01:00
|
|
|
catch_errors
|
2025-02-24 11:18:38 +01:00
|
|
|
|
core: Execution ID & Telemetry Improvements (#12041)
* fix: send telemetry BEFORE log collection in signal handlers
- Swap ensure_log_on_host/post_update_to_api order in on_interrupt, on_terminate, api_exit_script, and inline SIGHUP/SIGINT/SIGTERM traps
- For signal exits (>128): send telemetry immediately, then best-effort log collection
- Add 2>/dev/null || true to all I/O in signal handlers to prevent SIGPIPE
- Fix on_exit: exit_code=0 now reports 'done' instead of 'failed 1'
- Root cause: pct pull hangs on dying containers blocked telemetry updates, leaving 595+ records stuck in 'installing' daily
* feat: add execution_id to all telemetry payloads
- Generate EXECUTION_ID from RANDOM_UUID in variables()
- Export EXECUTION_ID to container environment
- Add execution_id field to all 8 API payloads in api.func
- Add execution_id to post_progress_to_api in install.func and alpine-install.func
- Fallback to RANDOM_UUID when EXECUTION_ID not set (backward compat)
* fix: correct telemetry type values for PVE and addon scripts
- PVE scripts (tools/pve/*): change type 'tool' -> 'pve'
- Addon scripts (tools/addon/*): fix 4 scripts that wrongly used 'tool' -> 'addon'
(netdata, add-tailscale-lxc, add-netbird-lxc, all-templates)
- api.func: post_tool_to_api sends type='pve', default fallback 'pve'
- Aligns with PocketBase categories: lxc, vm, pve, addon
* fix: persist diagnostics opt-in inside containers for addon telemetry
- install.func + alpine-install.func: create /usr/local/community-scripts/diagnostics
inside the container when DIAGNOSTICS=yes (from build.func export)
- Enables addon scripts running later inside containers to find the opt-in
- Update init_tool_telemetry default type from 'tool' to 'pve'
* refactor: clean up diagnostics/telemetry opt-in system
- diagnostics_check(): deduplicate heredoc (was 2x 22 lines), improve whiptail
text with clear what/what-not collected, add telemetry + privacy links
- diagnostics_menu(): better UX with current status, clear enable/disable
buttons, note about existing containers
- variables(): change DIAGNOSTICS default from 'yes' to 'no' (safe: no
telemetry before user consents via diagnostics_check)
- install.func + alpine-install.func: persist BOTH yes AND no in container
so opt-out is explicit (not just missing file = no)
- Fix typo 'menue' -> 'menu' in config file comments
* fix: no pre-selection in telemetry dialog, link to telemetry-service README
- Add --defaultno so 'No, opt out' is focused by default (user must Tab to Yes)
- Change privacy link from discussions/1836 to telemetry-service#privacy--compliance
* fix: use radiolist for telemetry dialog (no pre-selection)
- Replace --yesno with --radiolist: user must actively SPACE-select an option
- Both options start as OFF (no pre-selection)
- Cancel/Exit defaults to 'no' (opt-out)
* simplify: inline telemetry dialog text like other whiptail dialogs
* improve: telemetry dialog with more detail, link to PRIVACY.md
- Add what we collect / don't collect sections back to dialog
- Link to telemetry-service/docs/PRIVACY.md instead of README anchor
- Update config file comment with same link
2026-02-18 10:24:06 +01:00
|
|
|
# Persist diagnostics setting inside container (exported from build.func)
|
|
|
|
|
# so addon scripts running later can find the user's choice
|
|
|
|
|
if [[ ! -f /usr/local/community-scripts/diagnostics ]]; then
|
|
|
|
|
mkdir -p /usr/local/community-scripts
|
|
|
|
|
echo "DIAGNOSTICS=${DIAGNOSTICS:-no}" >/usr/local/community-scripts/diagnostics
|
|
|
|
|
fi
|
|
|
|
|
|
2026-01-19 17:40:25 +01:00
|
|
|
# Get LXC IP address (must be called INSIDE container, after network is up)
|
|
|
|
|
get_lxc_ip
|
|
|
|
|
|
2026-02-17 13:25:17 +01:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
# post_progress_to_api()
|
|
|
|
|
#
|
|
|
|
|
# - Lightweight progress ping from inside the container
|
2026-02-23 17:01:18 +01:00
|
|
|
# - Updates the existing telemetry record status
|
|
|
|
|
# - Arguments:
|
|
|
|
|
# * $1: status (optional, default: "configuring")
|
2026-02-17 13:25:17 +01:00
|
|
|
# - Signals that the installation is actively progressing (not stuck)
|
|
|
|
|
# - Fire-and-forget: never blocks or fails the script
|
|
|
|
|
# - Only executes if DIAGNOSTICS=yes and RANDOM_UUID is set
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
post_progress_to_api() {
|
|
|
|
|
command -v curl &>/dev/null || return 0
|
|
|
|
|
[[ "${DIAGNOSTICS:-no}" == "no" ]] && return 0
|
|
|
|
|
[[ -z "${RANDOM_UUID:-}" ]] && return 0
|
|
|
|
|
|
2026-02-23 17:01:18 +01:00
|
|
|
local progress_status="${1:-configuring}"
|
|
|
|
|
|
2026-02-17 13:25:17 +01:00
|
|
|
curl -fsS -m 5 -X POST "https://telemetry.community-scripts.org/telemetry" \
|
|
|
|
|
-H "Content-Type: application/json" \
|
2026-02-23 17:01:18 +01:00
|
|
|
-d "{\"random_id\":\"${RANDOM_UUID}\",\"execution_id\":\"${EXECUTION_ID:-${RANDOM_UUID}}\",\"type\":\"lxc\",\"nsapp\":\"${app:-unknown}\",\"status\":\"${progress_status}\"}" &>/dev/null || true
|
2026-02-17 13:25:17 +01:00
|
|
|
}
|
|
|
|
|
|
2025-02-24 11:18:38 +01:00
|
|
|
# This function enables IPv6 if it's not disabled and sets verbose mode
|
|
|
|
|
verb_ip6() {
|
|
|
|
|
set_std_mode # Set STD mode based on VERBOSE
|
|
|
|
|
|
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture (#9540)
* Refactor Core
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
* Delete config-file.func
* Update install.func
* Refactor stop_all_services function and variable names
Refactor service stopping logic and improve variable handling
* Refactor installation script and update copyright
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
* Update install.func
* Update license comment format in install.func
* Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
* big core refactor
* Enhance IPv6 configuration menu options
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
* Update default Node.js version to 24 LTS
* Update misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
* indention
* remove debugf and duplicate codes
* Update whiptail backtitles and error codes
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
* comments
* Refactor error handling and clean up debug comments
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
* Update build.func
* feat: Improve LXC network checks and LINSTOR storage handling
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
---------
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2025-12-04 07:52:18 +01:00
|
|
|
if [ "${IPV6_METHOD:-}" = "disable" ]; then
|
2025-11-21 08:53:46 +01:00
|
|
|
msg_info "Disabling IPv6 (this may affect some services)"
|
2023-08-14 21:23:58 -04:00
|
|
|
$STD sysctl -w net.ipv6.conf.all.disable_ipv6=1
|
2025-11-19 16:27:42 +01:00
|
|
|
$STD sysctl -w net.ipv6.conf.default.disable_ipv6=1
|
|
|
|
|
$STD sysctl -w net.ipv6.conf.lo.disable_ipv6=1
|
2025-11-21 08:53:46 +01:00
|
|
|
mkdir -p /etc/sysctl.d
|
|
|
|
|
$STD tee /etc/sysctl.d/99-disable-ipv6.conf >/dev/null <<EOF
|
|
|
|
|
net.ipv6.conf.all.disable_ipv6 = 1
|
|
|
|
|
net.ipv6.conf.default.disable_ipv6 = 1
|
|
|
|
|
net.ipv6.conf.lo.disable_ipv6 = 1
|
|
|
|
|
EOF
|
2023-08-14 21:23:58 -04:00
|
|
|
$STD rc-update add sysctl default
|
2025-11-19 16:27:42 +01:00
|
|
|
msg_ok "Disabled IPv6"
|
2023-03-22 20:48:20 -04:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-16 12:41:51 +01:00
|
|
|
# This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection
|
2023-03-22 20:48:20 -04:00
|
|
|
setting_up_container() {
|
|
|
|
|
msg_info "Setting up Container OS"
|
2025-06-20 13:28:06 +02:00
|
|
|
while [ $i -gt 0 ]; do
|
2023-03-22 20:48:20 -04:00
|
|
|
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" != "" ]; then
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
echo 1>&2 -en "${CROSS}${RD} No Network! "
|
2025-06-20 13:28:06 +02:00
|
|
|
sleep $RETRY_EVERY
|
2023-03-22 20:48:20 -04:00
|
|
|
i=$((i - 1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ "$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -d'/' -f1)" = "" ]; then
|
|
|
|
|
echo 1>&2 -e "\n${CROSS}${RD} No Network After $RETRY_NUM Tries${CL}"
|
2024-12-16 12:41:51 +01:00
|
|
|
echo -e "${NETWORK}Check Network Settings"
|
2023-03-22 20:48:20 -04:00
|
|
|
exit 1
|
|
|
|
|
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}"
|
2026-02-17 13:25:17 +01:00
|
|
|
post_progress_to_api
|
2023-03-22 20:48:20 -04:00
|
|
|
}
|
|
|
|
|
|
2024-12-16 12:41:51 +01:00
|
|
|
# This function checks the network connection by pinging a known IP address and prompts the user to continue if the internet is not connected
|
2023-03-22 20:48:20 -04:00
|
|
|
network_check() {
|
|
|
|
|
set +e
|
|
|
|
|
trap - ERR
|
2025-02-24 11:18:38 +01:00
|
|
|
if ping -c 1 -W 1 1.1.1.1 &>/dev/null || ping -c 1 -W 1 8.8.8.8 &>/dev/null || ping -c 1 -W 1 9.9.9.9 &>/dev/null; then
|
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture (#9540)
* Refactor Core
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
* Delete config-file.func
* Update install.func
* Refactor stop_all_services function and variable names
Refactor service stopping logic and improve variable handling
* Refactor installation script and update copyright
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
* Update install.func
* Update license comment format in install.func
* Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
* big core refactor
* Enhance IPv6 configuration menu options
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
* Update default Node.js version to 24 LTS
* Update misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
* indention
* remove debugf and duplicate codes
* Update whiptail backtitles and error codes
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
* comments
* Refactor error handling and clean up debug comments
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
* Update build.func
* feat: Improve LXC network checks and LINSTOR storage handling
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
---------
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2025-12-04 07:52:18 +01:00
|
|
|
ipv4_status="${GN}✔${CL} IPv4"
|
2024-12-16 12:41:51 +01:00
|
|
|
else
|
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture (#9540)
* Refactor Core
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
* Delete config-file.func
* Update install.func
* Refactor stop_all_services function and variable names
Refactor service stopping logic and improve variable handling
* Refactor installation script and update copyright
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
* Update install.func
* Update license comment format in install.func
* Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
* big core refactor
* Enhance IPv6 configuration menu options
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
* Update default Node.js version to 24 LTS
* Update misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
* indention
* remove debugf and duplicate codes
* Update whiptail backtitles and error codes
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
* comments
* Refactor error handling and clean up debug comments
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
* Update build.func
* feat: Improve LXC network checks and LINSTOR storage handling
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
---------
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2025-12-04 07:52:18 +01:00
|
|
|
ipv4_status="${RD}✖${CL} IPv4"
|
|
|
|
|
read -r -p "Internet NOT connected. Continue anyway? <y/N> " prompt
|
2023-06-10 00:38:17 +02:00
|
|
|
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
|
2024-12-16 12:41:51 +01:00
|
|
|
echo -e "${INFO}${RD}Expect Issues Without Internet${CL}"
|
2023-03-22 20:48:20 -04:00
|
|
|
else
|
2025-02-24 11:18:38 +01:00
|
|
|
echo -e "${NETWORK}Check Network Settings"
|
2023-03-22 20:48:20 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
RESOLVEDIP=$(getent hosts github.com | awk '{ print $1 }')
|
Three-tier defaults system | security improvements | error_handler | improved logging | improved container creation | improved architecture (#9540)
* Refactor Core
Refactored misc/alpine-install.func to improve error handling, network checks, and MOTD setup. Added misc/alpine-tools.func and misc/error_handler.func for modular tool installation and error management. Enhanced misc/api.func with detailed exit code explanations and telemetry functions. Updated misc/core.func for better initialization, validation, and execution helpers. Removed misc/create_lxc.sh as part of cleanup.
* Delete config-file.func
* Update install.func
* Refactor stop_all_services function and variable names
Refactor service stopping logic and improve variable handling
* Refactor installation script and update copyright
Updated copyright information and adjusted package installation commands. Enhanced IPv6 disabling logic and improved container customization process.
* Update install.func
* Update license comment format in install.func
* Refactor IPv6 handling and enhance MOTD and SSH
Refactor IPv6 handling and update OS function. Enhance MOTD with additional details and configure SSH settings.
* big core refactor
* Enhance IPv6 configuration menu options
Updated IPv6 Address Management menu options for clarity and added a new option for fully disabling IPv6.
* Update default Node.js version to 24 LTS
* Update misc/alpine-tools.func
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
* indention
* remove debugf and duplicate codes
* Update whiptail backtitles and error codes
Removed '[dev]' from whiptail --backtitle strings for consistency. Refactored custom exit codes in build.func and error_handler.func: updated Proxmox error codes, shifted MySQL/MariaDB codes to 260-263, and removed unused MongoDB code. Updated error descriptions to match new codes.
* comments
* Refactor error handling and clean up debug comments
Standardized bash variable checks, removed unnecessary debug and commented code, and clarified error handling logic in container build and setup scripts. These changes improve code readability and maintainability without altering functional behavior.
* Update build.func
* feat: Improve LXC network checks and LINSTOR storage handling
Enhanced LXC container network setup to check for both IPv4 and IPv6 addresses, added connectivity (ping) tests, and provided troubleshooting tips on failure. Updated storage validation to support LINSTOR, including cluster connectivity checks and special handling for LINSTOR template storage.
---------
Co-authored-by: Michel Roegl-Brunner <73236783+michelroegl-brunner@users.noreply.github.com>
2025-12-04 07:52:18 +01:00
|
|
|
if [[ -z "$RESOLVEDIP" ]]; then
|
|
|
|
|
msg_error "Internet: ${ipv4_status} DNS Failed"
|
|
|
|
|
else
|
|
|
|
|
msg_ok "Internet: ${ipv4_status} DNS: ${BL}${RESOLVEDIP}${CL}"
|
|
|
|
|
fi
|
2023-03-22 20:48:20 -04:00
|
|
|
set -e
|
|
|
|
|
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-16 12:41:51 +01:00
|
|
|
# This function updates the Container OS by running apt-get update and upgrade
|
2023-03-22 20:48:20 -04:00
|
|
|
update_os() {
|
|
|
|
|
msg_info "Updating Container OS"
|
2025-05-12 16:07:07 +02:00
|
|
|
$STD apk -U upgrade
|
2026-02-17 13:25:17 +01:00
|
|
|
local tools_content
|
|
|
|
|
tools_content=$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/tools.func) || {
|
|
|
|
|
msg_error "Failed to download tools.func"
|
|
|
|
|
exit 6
|
|
|
|
|
}
|
|
|
|
|
source /dev/stdin <<<"$tools_content"
|
|
|
|
|
if ! declare -f fetch_and_deploy_gh_release >/dev/null 2>&1; then
|
|
|
|
|
msg_error "tools.func loaded but incomplete — missing expected functions"
|
|
|
|
|
exit 6
|
|
|
|
|
fi
|
2023-03-22 20:48:20 -04:00
|
|
|
msg_ok "Updated Container OS"
|
2026-02-17 13:25:17 +01:00
|
|
|
post_progress_to_api
|
2023-03-22 20:48:20 -04:00
|
|
|
}
|
|
|
|
|
|
2024-12-16 12:41:51 +01:00
|
|
|
# This function modifies the message of the day (motd) and SSH settings
|
2023-03-22 20:48:20 -04:00
|
|
|
motd_ssh() {
|
|
|
|
|
echo "export TERM='xterm-256color'" >>/root/.bashrc
|
2025-01-21 11:02:11 +01:00
|
|
|
|
|
|
|
|
PROFILE_FILE="/etc/profile.d/00_lxc-details.sh"
|
2025-02-24 11:18:38 +01:00
|
|
|
echo "echo -e \"\"" >"$PROFILE_FILE"
|
|
|
|
|
echo -e "echo -e \"${BOLD}${APPLICATION} LXC Container${CL}"\" >>"$PROFILE_FILE"
|
|
|
|
|
echo -e "echo -e \"${TAB}${GATEWAY}${YW} Provided by: ${GN}community-scripts ORG ${YW}| GitHub: ${GN}https://github.com/community-scripts/ProxmoxVE${CL}\"" >>"$PROFILE_FILE"
|
|
|
|
|
echo "echo \"\"" >>"$PROFILE_FILE"
|
2025-12-07 21:29:09 +01:00
|
|
|
echo -e "echo -e \"${TAB}${OS}${YW} OS: ${GN}\$(grep ^NAME /etc/os-release | cut -d= -f2 | tr -d '\"') - Version: \$(grep ^VERSION_ID /etc/os-release | cut -d= -f2 | tr -d '\"')${CL}\"" >>"$PROFILE_FILE"
|
2025-02-24 11:18:38 +01:00
|
|
|
echo -e "echo -e \"${TAB}${HOSTNAME}${YW} Hostname: ${GN}\$(hostname)${CL}\"" >>"$PROFILE_FILE"
|
|
|
|
|
echo -e "echo -e \"${TAB}${INFO}${YW} IP Address: ${GN}\$(ip -4 addr show eth0 | awk '/inet / {print \$2}' | cut -d/ -f1 | head -n 1)${CL}\"" >>"$PROFILE_FILE"
|
2025-01-21 11:02:11 +01:00
|
|
|
|
2024-12-16 12:41:51 +01:00
|
|
|
# Configure SSH if enabled
|
2023-03-22 20:48:20 -04:00
|
|
|
if [[ "${SSH_ROOT}" == "yes" ]]; then
|
2024-12-16 12:41:51 +01:00
|
|
|
# Enable sshd service
|
2023-03-22 20:48:20 -04:00
|
|
|
$STD rc-update add sshd
|
2024-12-16 12:41:51 +01:00
|
|
|
# Allow root login via SSH
|
2023-03-25 20:21:12 -04:00
|
|
|
sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
|
2024-12-16 12:41:51 +01:00
|
|
|
# Start the sshd service
|
2023-03-22 20:48:20 -04:00
|
|
|
$STD /etc/init.d/sshd start
|
|
|
|
|
fi
|
2026-02-18 16:19:19 +01:00
|
|
|
post_progress_to_api
|
2023-03-22 20:48:20 -04:00
|
|
|
}
|
2023-03-25 06:12:45 -04:00
|
|
|
|
2025-03-13 15:54:50 +01:00
|
|
|
# Validate Timezone for some LXC's
|
|
|
|
|
validate_tz() {
|
2025-03-27 11:52:04 +01:00
|
|
|
[[ -f "/usr/share/zoneinfo/$1" ]]
|
2025-03-13 15:54:50 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-16 12:41:51 +01:00
|
|
|
# This function customizes the container and enables passwordless login for the root user
|
2023-03-25 06:12:45 -04:00
|
|
|
customize() {
|
2023-05-15 07:39:30 -04:00
|
|
|
if [[ "$PASSWORD" == "" ]]; then
|
2025-02-24 11:18:38 +01:00
|
|
|
msg_info "Customizing Container"
|
2025-05-09 15:28:12 +02:00
|
|
|
passwd -d root >/dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
# Ensure agetty is available
|
|
|
|
|
apk add --no-cache --force-broken-world util-linux >/dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
# Create persistent autologin boot script
|
|
|
|
|
mkdir -p /etc/local.d
|
|
|
|
|
cat <<'EOF' >/etc/local.d/autologin.start
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
sed -i 's|^tty1::respawn:.*|tty1::respawn:/sbin/agetty --autologin root --noclear tty1 38400 linux|' /etc/inittab
|
|
|
|
|
kill -HUP 1
|
|
|
|
|
EOF
|
|
|
|
|
touch /root/.hushlogin
|
|
|
|
|
|
|
|
|
|
chmod +x /etc/local.d/autologin.start
|
|
|
|
|
rc-update add local >/dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
# Apply autologin immediately for current session
|
|
|
|
|
/etc/local.d/autologin.start
|
|
|
|
|
|
2025-02-24 11:18:38 +01:00
|
|
|
msg_ok "Customized Container"
|
2023-03-25 06:12:45 -04:00
|
|
|
fi
|
2025-03-27 11:52:04 +01:00
|
|
|
|
2025-06-20 13:28:06 +02:00
|
|
|
echo "bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/ct/${app}.sh)\"" >/usr/bin/update
|
2025-03-27 11:52:04 +01:00
|
|
|
chmod +x /usr/bin/update
|
2026-02-18 16:19:19 +01:00
|
|
|
post_progress_to_api
|
2025-02-24 11:18:38 +01:00
|
|
|
}
|