Compare commits

..

1 Commits

+50 -33
View File
@@ -1062,7 +1062,6 @@ load_vars_file() {
var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu
var_net var_nesting var_ns var_os var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged var_net var_nesting var_ns var_os var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged
var_verbose var_version var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage var_searchdomain var_verbose var_version var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage var_searchdomain
var_post_install
) )
# Whitelist check helper # Whitelist check helper
@@ -1280,7 +1279,6 @@ default_var_settings() {
var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu
var_net var_nesting var_ns var_os var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged var_net var_nesting var_ns var_os var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged
var_verbose var_version var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage var_verbose var_version var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage
var_post_install
) )
# Snapshot: environment variables (highest precedence) # Snapshot: environment variables (highest precedence)
@@ -1376,11 +1374,6 @@ var_verbose=no
# GitHub Personal Access Token (optional avoids API rate limits during installs) # GitHub Personal Access Token (optional avoids API rate limits during installs)
# Create at https://github.com/settings/tokens read-only public access is sufficient # Create at https://github.com/settings/tokens read-only public access is sufficient
# var_github_token=ghp_your_token_here # var_github_token=ghp_your_token_here
# Optional post-install script (host-side path to a *.sh on the Proxmox host)
# Runs ON THE HOST after the container is fully provisioned.
# Available env vars: APP, NSAPP, CTID, IP, HN, STORAGE, BRG
# var_post_install=/opt/post-install/myhook.sh
EOF EOF
# Now choose storages (always prompt unless just one exists) # Now choose storages (always prompt unless just one exists)
@@ -1459,7 +1452,6 @@ if ! declare -p VAR_WHITELIST >/dev/null 2>&1; then
var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu var_gateway var_hostname var_ipv6_method var_mac var_mknod var_mount_fs var_mtu
var_net var_nesting var_ns var_os var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged var_net var_nesting var_ns var_os var_protection var_pw var_ram var_tags var_timezone var_tun var_unprivileged
var_verbose var_version var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage var_searchdomain var_verbose var_version var_vlan var_ssh var_ssh_authorized_key var_container_storage var_template_storage var_searchdomain
var_post_install
) )
fi fi
@@ -1672,7 +1664,6 @@ _build_current_app_vars_tmp() {
[ -n "$_tpl_storage" ] && echo "var_template_storage=$(_sanitize_value "$_tpl_storage")" [ -n "$_tpl_storage" ] && echo "var_template_storage=$(_sanitize_value "$_tpl_storage")"
[ -n "$_ct_storage" ] && echo "var_container_storage=$(_sanitize_value "$_ct_storage")" [ -n "$_ct_storage" ] && echo "var_container_storage=$(_sanitize_value "$_ct_storage")"
[ -n "${var_post_install:-}" ] && echo "var_post_install=$(_sanitize_value "${var_post_install}")"
} >"$tmpf" } >"$tmpf"
echo "$tmpf" echo "$tmpf"
@@ -1817,7 +1808,7 @@ advanced_settings() {
TAGS="community-script${var_tags:+;${var_tags}}" TAGS="community-script${var_tags:+;${var_tags}}"
fi fi
local STEP=1 local STEP=1
local MAX_STEP=29 local MAX_STEP=28
# Store values for back navigation - inherit from var_* app defaults # Store values for back navigation - inherit from var_* app defaults
local _ct_type="${var_unprivileged:-1}" local _ct_type="${var_unprivileged:-1}"
@@ -1851,7 +1842,6 @@ advanced_settings() {
local _enable_mknod="${var_mknod:-0}" local _enable_mknod="${var_mknod:-0}"
local _mount_fs="${var_mount_fs:-}" local _mount_fs="${var_mount_fs:-}"
local _protect_ct="${var_protection:-no}" local _protect_ct="${var_protection:-no}"
local _post_install="${var_post_install:-}"
# Detect host timezone for default (if not set via var_timezone) # Detect host timezone for default (if not set via var_timezone)
local _host_timezone="" local _host_timezone=""
@@ -2763,8 +2753,7 @@ Features:
Advanced: Advanced:
Timezone: $tz_display Timezone: $tz_display
APT Cacher: $apt_display APT Cacher: $apt_display
Verbose: $_verbose Verbose: $_verbose"
Post-Install Script: ${_post_install:-(none)}"
if whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \ if whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
--title "CONFIRM SETTINGS" \ --title "CONFIRM SETTINGS" \
@@ -2807,7 +2796,6 @@ Advanced:
APT_CACHER="$_apt_cacher" APT_CACHER="$_apt_cacher"
APT_CACHER_IP="$_apt_cacher_ip" APT_CACHER_IP="$_apt_cacher_ip"
VERBOSE="$_verbose" VERBOSE="$_verbose"
var_post_install="$_post_install"
# Update var_* based on user choice (for functions that check these) # Update var_* based on user choice (for functions that check these)
var_gpu="$_enable_gpu" var_gpu="$_enable_gpu"
@@ -3516,6 +3504,52 @@ msg_menu() {
return 0 return 0
} }
# ------------------------------------------------------------------------------
# run_addon_updates()
#
# - Scans /usr/local/bin/update_* for addon update scripts installed alongside
# the main application (e.g. by tools/addon/*.sh)
# - For each found addon, prompts the user (60s timeout, default no) whether
# it should be updated as well
# - Skipped entirely when PHS_SILENT=1 to keep unattended updates predictable
# ------------------------------------------------------------------------------
run_addon_updates() {
shopt -s nullglob
local addons=(/usr/local/bin/update_*)
shopt -u nullglob
((${#addons[@]} == 0)) && return 0
if [[ "${PHS_SILENT:-0}" == "1" ]]; then
msg_info "Detected ${#addons[@]} addon update script(s) - skipping (PHS_SILENT)"
return 0
fi
echo
echo -e "${INFO}${YW} Detected installed addon update script(s):${CL}"
local a name
for a in "${addons[@]}"; do
echo -e "${TAB}- ${a##*/update_}"
done
echo
local ans
for a in "${addons[@]}"; do
name="${a##*/update_}"
printf 'Do you also want to update addon "%s"? (y/N) [60s]: ' "$name"
ans=""
if read -r -t 60 ans; then :; else echo; fi
case "${ans,,}" in
y | yes)
bash "$a" || msg_warn "Addon update for $name failed (rc=$?)"
;;
*)
msg_info "Skipped addon: $name"
;;
esac
done
}
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# start() # start()
# #
@@ -3535,6 +3569,7 @@ start() {
ensure_profile_loaded ensure_profile_loaded
get_lxc_ip get_lxc_ip
update_script update_script
run_addon_updates
update_motd_ip update_motd_ip
cleanup_lxc cleanup_lxc
else else
@@ -3563,6 +3598,7 @@ start() {
ensure_profile_loaded ensure_profile_loaded
get_lxc_ip get_lxc_ip
update_script update_script
run_addon_updates
update_motd_ip update_motd_ip
cleanup_lxc cleanup_lxc
fi fi
@@ -6317,25 +6353,6 @@ EOF
systemctl start ping-instances.service systemctl start ping-instances.service
fi fi
# Optional host-side post-install hook
# Path comes from var_post_install (default.vars / app.vars / advanced settings).
# Runs ON THE PROXMOX HOST after the container is up and configured.
# Exposed env vars: APP, NSAPP, CTID, IP, HN, STORAGE, BRG.
if [[ -n "${var_post_install:-}" ]]; then
if [[ -f "${var_post_install}" ]]; then
msg_info "Running post-install script: ${var_post_install}"
if APP="$APP" NSAPP="${NSAPP:-}" CTID="$CTID" IP="$IP" HN="${HN:-}" \
STORAGE="${STORAGE:-}" BRG="${BRG:-}" \
bash "${var_post_install}"; then
msg_ok "Ran post-install script"
else
msg_error "Post-install script exited with non-zero status (rc=$?)"
fi
else
msg_error "Post-install script not found on host: ${var_post_install}"
fi
fi
INSTALL_COMPLETE=true INSTALL_COMPLETE=true
post_update_to_api "done" "none" post_update_to_api "done" "none"
} }