mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-02-18 19:15:55 +01:00
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
This commit is contained in:
@@ -11,11 +11,11 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
|
||||
load_functions
|
||||
catch_errors
|
||||
|
||||
# Persist diagnostics opt-in inside container (exported from build.func)
|
||||
# so addon scripts running later can find it
|
||||
if [[ "${DIAGNOSTICS:-no}" == "yes" ]] && [[ ! -f /usr/local/community-scripts/diagnostics ]]; then
|
||||
# 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=yes" >/usr/local/community-scripts/diagnostics
|
||||
echo "DIAGNOSTICS=${DIAGNOSTICS:-no}" >/usr/local/community-scripts/diagnostics
|
||||
fi
|
||||
|
||||
# Get LXC IP address (must be called INSIDE container, after network is up)
|
||||
|
||||
141
misc/build.func
141
misc/build.func
@@ -42,7 +42,7 @@ variables() {
|
||||
var_install="${NSAPP}-install" # sets the var_install variable by appending "-install" to the value of NSAPP.
|
||||
INTEGER='^[0-9]+([.][0-9]+)?$' # it defines the INTEGER regular expression pattern.
|
||||
PVEHOST_NAME=$(hostname) # gets the Proxmox Hostname and sets it to Uppercase
|
||||
DIAGNOSTICS="yes" # sets the DIAGNOSTICS variable to "yes", used for the API call.
|
||||
DIAGNOSTICS="no" # Safe default: no telemetry until user consents via diagnostics_check()
|
||||
METHOD="default" # sets the METHOD variable to "default", used for the API call.
|
||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)" # generates a random UUID and sets it to the RANDOM_UUID variable.
|
||||
EXECUTION_ID="${RANDOM_UUID}" # Unique execution ID for telemetry record identification (unique-indexed in PocketBase)
|
||||
@@ -2788,93 +2788,98 @@ Advanced:
|
||||
# diagnostics_check()
|
||||
#
|
||||
# - Ensures diagnostics config file exists at /usr/local/community-scripts/diagnostics
|
||||
# - Asks user whether to send anonymous diagnostic data
|
||||
# - Asks user whether to send anonymous diagnostic data (first run only)
|
||||
# - Saves DIAGNOSTICS=yes/no in the config file
|
||||
# - Creates file if missing with default DIAGNOSTICS=yes
|
||||
# - Reads current diagnostics setting from file
|
||||
# - Reads current diagnostics setting from existing file
|
||||
# - Sets global DIAGNOSTICS variable for API telemetry opt-in/out
|
||||
# ------------------------------------------------------------------------------
|
||||
diagnostics_check() {
|
||||
if ! [ -d "/usr/local/community-scripts" ]; then
|
||||
mkdir -p /usr/local/community-scripts
|
||||
local config_dir="/usr/local/community-scripts"
|
||||
local config_file="${config_dir}/diagnostics"
|
||||
|
||||
mkdir -p "$config_dir"
|
||||
|
||||
if [[ -f "$config_file" ]]; then
|
||||
DIAGNOSTICS=$(awk -F '=' '/^DIAGNOSTICS/ {print $2}' "$config_file") || true
|
||||
DIAGNOSTICS="${DIAGNOSTICS:-no}"
|
||||
return
|
||||
fi
|
||||
|
||||
if ! [ -f "/usr/local/community-scripts/diagnostics" ]; then
|
||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "DIAGNOSTICS" --yesno "Send Diagnostics of LXC Installation?\n\n(This only transmits data without user data, just RAM, CPU, LXC name, ...)" 10 58); then
|
||||
cat <<EOF >/usr/local/community-scripts/diagnostics
|
||||
DIAGNOSTICS=yes
|
||||
local dialog_text=(
|
||||
"Help improve Community-Scripts by sharing anonymous installation data.\n\n"
|
||||
"What we collect:\n"
|
||||
" - Container type, disk size, CPU cores, RAM size\n"
|
||||
" - OS type/version, Proxmox VE version\n"
|
||||
" - Application name, install method and status\n\n"
|
||||
"What we DON'T collect:\n"
|
||||
" - No IP addresses, hostnames, or personal data\n"
|
||||
" - No passwords, tokens, or configuration values\n\n"
|
||||
"You can change this at any time in the Settings menu\n"
|
||||
"or by editing: ${config_file}\n\n"
|
||||
"More info: https://telemetry.community-scripts.org\n"
|
||||
"Privacy: https://github.com/community-scripts/ProxmoxVE/discussions/1836"
|
||||
)
|
||||
|
||||
#This file is used to store the diagnostics settings for the Community-Scripts API.
|
||||
#https://github.com/community-scripts/ProxmoxVE/discussions/1836
|
||||
#Your diagnostics will be sent to the Community-Scripts API for troubleshooting/statistical purposes.
|
||||
#You can review the data at https://community-scripts.github.io/ProxmoxVE/data
|
||||
#If you do not wish to send diagnostics, please set the variable 'DIAGNOSTICS' to "no" in /usr/local/community-scripts/diagnostics, or use the menue.
|
||||
#This will disable the diagnostics feature.
|
||||
#To send diagnostics, set the variable 'DIAGNOSTICS' to "yes" in /usr/local/community-scripts/diagnostics, or use the menue.
|
||||
#This will enable the diagnostics feature.
|
||||
#The following information will be sent:
|
||||
#"disk_size"
|
||||
#"core_count"
|
||||
#"ram_size"
|
||||
#"os_type"
|
||||
#"os_version"
|
||||
#"nsapp"
|
||||
#"method"
|
||||
#"pve_version"
|
||||
#"status"
|
||||
#If you have any concerns, please review the source code at /misc/build.func
|
||||
EOF
|
||||
DIAGNOSTICS="yes"
|
||||
else
|
||||
cat <<EOF >/usr/local/community-scripts/diagnostics
|
||||
DIAGNOSTICS=no
|
||||
|
||||
#This file is used to store the diagnostics settings for the Community-Scripts API.
|
||||
#https://github.com/community-scripts/ProxmoxVE/discussions/1836
|
||||
#Your diagnostics will be sent to the Community-Scripts API for troubleshooting/statistical purposes.
|
||||
#You can review the data at https://community-scripts.github.io/ProxmoxVE/data
|
||||
#If you do not wish to send diagnostics, please set the variable 'DIAGNOSTICS' to "no" in /usr/local/community-scripts/diagnostics, or use the menue.
|
||||
#This will disable the diagnostics feature.
|
||||
#To send diagnostics, set the variable 'DIAGNOSTICS' to "yes" in /usr/local/community-scripts/diagnostics, or use the menue.
|
||||
#This will enable the diagnostics feature.
|
||||
#The following information will be sent:
|
||||
#"disk_size"
|
||||
#"core_count"
|
||||
#"ram_size"
|
||||
#"os_type"
|
||||
#"os_version"
|
||||
#"nsapp"
|
||||
#"method"
|
||||
#"pve_version"
|
||||
#"status"
|
||||
#If you have any concerns, please review the source code at /misc/build.func
|
||||
EOF
|
||||
DIAGNOSTICS="no"
|
||||
fi
|
||||
if whiptail --backtitle "Proxmox VE Helper Scripts" \
|
||||
--title "TELEMETRY & DIAGNOSTICS" \
|
||||
--yesno "${dialog_text[*]}" 22 68 \
|
||||
--yes-button "Yes, share data" --no-button "No, opt out"; then
|
||||
DIAGNOSTICS="yes"
|
||||
else
|
||||
DIAGNOSTICS=$(awk -F '=' '/^DIAGNOSTICS/ {print $2}' /usr/local/community-scripts/diagnostics)
|
||||
|
||||
DIAGNOSTICS="no"
|
||||
fi
|
||||
|
||||
cat <<EOF >"$config_file"
|
||||
DIAGNOSTICS=${DIAGNOSTICS}
|
||||
|
||||
# Community-Scripts Telemetry Configuration
|
||||
# https://telemetry.community-scripts.org
|
||||
#
|
||||
# This file stores your telemetry preference.
|
||||
# Set DIAGNOSTICS=yes to share anonymous installation data.
|
||||
# Set DIAGNOSTICS=no to disable telemetry.
|
||||
#
|
||||
# You can also change this via the Settings menu during installation.
|
||||
#
|
||||
# Data collected (when enabled):
|
||||
# disk_size, core_count, ram_size, os_type, os_version,
|
||||
# nsapp, method, pve_version, status, exit_code
|
||||
#
|
||||
# No personal data (IPs, hostnames, passwords) is ever collected.
|
||||
# Privacy: https://github.com/community-scripts/ProxmoxVE/discussions/1836
|
||||
EOF
|
||||
}
|
||||
|
||||
diagnostics_menu() {
|
||||
if [ "${DIAGNOSTICS:-no}" = "yes" ]; then
|
||||
local current="${DIAGNOSTICS:-no}"
|
||||
local status_text="DISABLED"
|
||||
[[ "$current" == "yes" ]] && status_text="ENABLED"
|
||||
|
||||
local dialog_text=(
|
||||
"Telemetry is currently: ${status_text}\n\n"
|
||||
"Anonymous data helps us improve scripts and track issues.\n"
|
||||
"No personal data is ever collected.\n\n"
|
||||
"More info: https://telemetry.community-scripts.org\n\n"
|
||||
"Do you want to ${current:+change this setting}?"
|
||||
)
|
||||
|
||||
if [[ "$current" == "yes" ]]; then
|
||||
if whiptail --backtitle "Proxmox VE Helper Scripts" \
|
||||
--title "DIAGNOSTIC SETTINGS" \
|
||||
--yesno "Send Diagnostics?\n\nCurrent: ${DIAGNOSTICS}" 10 58 \
|
||||
--yes-button "No" --no-button "Back"; then
|
||||
--title "TELEMETRY SETTINGS" \
|
||||
--yesno "${dialog_text[*]}" 14 64 \
|
||||
--yes-button "Disable" --no-button "Keep enabled"; then
|
||||
DIAGNOSTICS="no"
|
||||
sed -i 's/^DIAGNOSTICS=.*/DIAGNOSTICS=no/' /usr/local/community-scripts/diagnostics
|
||||
whiptail --msgbox "Diagnostics set to ${DIAGNOSTICS}." 8 58
|
||||
whiptail --msgbox "Telemetry disabled.\n\nNote: Existing containers keep their current setting.\nNew containers will inherit this choice." 10 58
|
||||
fi
|
||||
else
|
||||
if whiptail --backtitle "Proxmox VE Helper Scripts" \
|
||||
--title "DIAGNOSTIC SETTINGS" \
|
||||
--yesno "Send Diagnostics?\n\nCurrent: ${DIAGNOSTICS}" 10 58 \
|
||||
--yes-button "Yes" --no-button "Back"; then
|
||||
--title "TELEMETRY SETTINGS" \
|
||||
--yesno "${dialog_text[*]}" 14 64 \
|
||||
--yes-button "Enable" --no-button "Keep disabled"; then
|
||||
DIAGNOSTICS="yes"
|
||||
sed -i 's/^DIAGNOSTICS=.*/DIAGNOSTICS=yes/' /usr/local/community-scripts/diagnostics
|
||||
whiptail --msgbox "Diagnostics set to ${DIAGNOSTICS}." 8 58
|
||||
whiptail --msgbox "Telemetry enabled.\n\nNote: Existing containers keep their current setting.\nNew containers will inherit this choice." 10 58
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
|
||||
load_functions
|
||||
catch_errors
|
||||
|
||||
# Persist diagnostics opt-in inside container (exported from build.func)
|
||||
# so addon scripts running later can find it
|
||||
if [[ "${DIAGNOSTICS:-no}" == "yes" ]] && [[ ! -f /usr/local/community-scripts/diagnostics ]]; then
|
||||
# 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=yes" >/usr/local/community-scripts/diagnostics
|
||||
echo "DIAGNOSTICS=${DIAGNOSTICS:-no}" >/usr/local/community-scripts/diagnostics
|
||||
fi
|
||||
|
||||
# Get LXC IP address (must be called INSIDE container, after network is up)
|
||||
|
||||
Reference in New Issue
Block a user