mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-03 00:32:58 +02:00
Compare commits
2 Commits
feat/apt-p
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
373e4c0c9a | ||
|
|
54f043d160 |
@@ -50,7 +50,7 @@ function update_script() {
|
||||
rm -rf /opt/zigbee2mqtt/data
|
||||
mv /opt/z2m_backup/data /opt/zigbee2mqtt
|
||||
cd /opt/zigbee2mqtt
|
||||
grep -q "^packageImportMethod" ./pnpm-workspace.yaml || echo "packageImportMethod: hardlink" >>./pnpm-workspace.yaml
|
||||
grep -q "^packageImportMethod" ./pnpm-workspace.yaml 2>/dev/null || echo "packageImportMethod: hardlink" >>./pnpm-workspace.yaml
|
||||
$STD pnpm install --frozen-lockfile
|
||||
$STD pnpm build
|
||||
rm -rf /opt/z2m_backup
|
||||
|
||||
@@ -986,23 +986,13 @@ base_settings() {
|
||||
|
||||
# Runtime check: Verify APT cacher is reachable if configured
|
||||
if [[ -n "$APT_CACHER_IP" && "$APT_CACHER" == "yes" ]]; then
|
||||
local _check_host _check_port _check_url
|
||||
_check_host=$(echo "$APT_CACHER_IP" | sed -e 's|https\?://||' -e 's|/.*||' | cut -d: -f1)
|
||||
_check_port=$(echo "$APT_CACHER_IP" | sed -e 's|https\?://||' -e 's|/.*||' | cut -s -d: -f2)
|
||||
if [[ "$APT_CACHER_IP" =~ ^https?:// ]]; then
|
||||
_check_url="$APT_CACHER_IP"
|
||||
_check_port="${_check_port:-80}"
|
||||
else
|
||||
_check_port="${_check_port:-3142}"
|
||||
_check_url="http://${APT_CACHER_IP}:${_check_port}"
|
||||
fi
|
||||
if ! curl -s --connect-timeout 2 "${_check_url}" >/dev/null 2>&1; then
|
||||
msg_warn "APT Cacher configured but not reachable at ${_check_url}"
|
||||
if ! curl -s --connect-timeout 2 "http://${APT_CACHER_IP}:3142" >/dev/null 2>&1; then
|
||||
msg_warn "APT Cacher configured but not reachable at ${APT_CACHER_IP}:3142"
|
||||
msg_custom "⚠️" "${YW}" "Disabling APT Cacher for this installation"
|
||||
APT_CACHER=""
|
||||
APT_CACHER_IP=""
|
||||
else
|
||||
msg_ok "APT Cacher verified at ${_check_url}"
|
||||
msg_ok "APT Cacher verified at ${APT_CACHER_IP}:3142"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1209,13 +1199,6 @@ load_vars_file() {
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
var_apt_cacher_ip)
|
||||
# Allow: plain IP/hostname, http://host, https://host:port
|
||||
if [[ -n "$var_val" ]] && ! [[ "$var_val" =~ ^(https?://)?[a-zA-Z0-9._-]+(:[0-9]+)?(/.*)?$ ]]; then
|
||||
msg_warn "Invalid APT Cacher address '$var_val' in $file, ignoring"
|
||||
continue
|
||||
fi
|
||||
;;
|
||||
var_container_storage | var_template_storage)
|
||||
# Validate that the storage exists and is active on the current node
|
||||
local _storage_status
|
||||
@@ -1328,11 +1311,9 @@ var_ipv6_method=none
|
||||
var_ssh=no
|
||||
# var_ssh_authorized_key=
|
||||
|
||||
# APT cacher (optional - IP or URL)
|
||||
# APT cacher (optional - with example)
|
||||
# var_apt_cacher=yes
|
||||
# var_apt_cacher_ip=192.168.1.10
|
||||
# var_apt_cacher_ip=http://proxy.local
|
||||
# var_apt_cacher_ip=https://proxy.local:443
|
||||
|
||||
# Features/Tags/verbosity
|
||||
var_fuse=no
|
||||
@@ -2545,7 +2526,7 @@ advanced_settings() {
|
||||
# Ask for IP if enabled
|
||||
if result=$(whiptail --backtitle "Proxmox VE Helper Scripts [Step $STEP/$MAX_STEP]" \
|
||||
--title "APT CACHER IP" \
|
||||
--inputbox "\nEnter APT Cacher-NG IP or URL:\n(e.g. 192.168.1.10, http://host, https://host:443)" 12 62 "$_apt_cacher_ip" \
|
||||
--inputbox "\nEnter APT Cacher-NG server IP address:" 10 58 "$_apt_cacher_ip" \
|
||||
3>&1 1>&2 2>&3); then
|
||||
_apt_cacher_ip="$result"
|
||||
fi
|
||||
|
||||
@@ -390,24 +390,10 @@ update_os() {
|
||||
msg_info "Updating Container OS"
|
||||
if [[ "$CACHER" == "yes" ]]; then
|
||||
echo 'Acquire::http::Proxy-Auto-Detect "/usr/local/bin/apt-proxy-detect.sh";' >/etc/apt/apt.conf.d/00aptproxy
|
||||
local _proxy_raw="${CACHER_IP}"
|
||||
local _proxy_host _proxy_port _proxy_url
|
||||
# Parse host and port from URL or plain IP/hostname
|
||||
_proxy_host=$(echo "$_proxy_raw" | sed -e 's|https\?://||' -e 's|/.*||' | cut -d: -f1)
|
||||
_proxy_port=$(echo "$_proxy_raw" | sed -e 's|https\?://||' -e 's|/.*||' | cut -s -d: -f2)
|
||||
if [[ "$_proxy_raw" =~ ^https?:// ]]; then
|
||||
# Full URL provided — use as-is for proxy output, extract port for nc check
|
||||
_proxy_url="$_proxy_raw"
|
||||
_proxy_port="${_proxy_port:-80}"
|
||||
else
|
||||
# Legacy: plain IP or hostname — default to http + port 3142
|
||||
_proxy_port="${_proxy_port:-3142}"
|
||||
_proxy_url="http://${_proxy_raw}:${_proxy_port}"
|
||||
fi
|
||||
cat <<EOF >/usr/local/bin/apt-proxy-detect.sh
|
||||
#!/bin/bash
|
||||
if nc -w1 -z "${_proxy_host}" ${_proxy_port}; then
|
||||
echo -n "${_proxy_url}"
|
||||
if nc -w1 -z "${CACHER_IP}" 3142; then
|
||||
echo -n "http://${CACHER_IP}:3142"
|
||||
else
|
||||
echo -n "DIRECT"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user