Update build.func
This commit is contained in:
parent
73d6cabb52
commit
ee5dc898f9
@ -1555,7 +1555,7 @@ advanced_settings() {
|
|||||||
configure_ssh_settings
|
configure_ssh_settings
|
||||||
export SSH_KEYS_FILE
|
export SSH_KEYS_FILE
|
||||||
echo -e "${ROOTSSH}${BOLD}${DGN}Root SSH Access: ${BGN}$SSH${CL}"
|
echo -e "${ROOTSSH}${BOLD}${DGN}Root SSH Access: ${BGN}$SSH${CL}"
|
||||||
|
|
||||||
# Advanced Settings - Proxmox Features
|
# Advanced Settings - Proxmox Features
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS" --yesno "Configure Advanced Proxmox Features?" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS" --yesno "Configure Advanced Proxmox Features?" 10 58); then
|
||||||
# keyctl: for Docker support
|
# keyctl: for Docker support
|
||||||
@ -1565,7 +1565,7 @@ advanced_settings() {
|
|||||||
ENABLE_KEYCTL="0"
|
ENABLE_KEYCTL="0"
|
||||||
fi
|
fi
|
||||||
echo -e "${SEARCH}${BOLD}${DGN}Allow keyctl(): ${BGN}$ENABLE_KEYCTL${CL}"
|
echo -e "${SEARCH}${BOLD}${DGN}Allow keyctl(): ${BGN}$ENABLE_KEYCTL${CL}"
|
||||||
|
|
||||||
# mknod: device node creation
|
# mknod: device node creation
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "Enable mknod()" --yesno "Allow device node creation?\n\nNeeded for: Complex device management (experimental, kernel 5.3+)\nDefault: No (rarely needed)" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "Enable mknod()" --yesno "Allow device node creation?\n\nNeeded for: Complex device management (experimental, kernel 5.3+)\nDefault: No (rarely needed)" 10 58); then
|
||||||
ENABLE_MKNOD="1"
|
ENABLE_MKNOD="1"
|
||||||
@ -1573,7 +1573,7 @@ advanced_settings() {
|
|||||||
ENABLE_MKNOD="0"
|
ENABLE_MKNOD="0"
|
||||||
fi
|
fi
|
||||||
echo -e "${SEARCH}${BOLD}${DGN}Allow mknod(): ${BGN}$ENABLE_MKNOD${CL}"
|
echo -e "${SEARCH}${BOLD}${DGN}Allow mknod(): ${BGN}$ENABLE_MKNOD${CL}"
|
||||||
|
|
||||||
# mount: specific filesystems
|
# mount: specific filesystems
|
||||||
if MOUNT_FS=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allow specific filesystems (e.g., nfs,fuse,ext4)\nLeave blank for defaults" 8 58 "$ALLOW_MOUNT_FS" --title "Mount Filesystems" 3>&1 1>&2 2>&3); then
|
if MOUNT_FS=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allow specific filesystems (e.g., nfs,fuse,ext4)\nLeave blank for defaults" 8 58 "$ALLOW_MOUNT_FS" --title "Mount Filesystems" 3>&1 1>&2 2>&3); then
|
||||||
ALLOW_MOUNT_FS="$MOUNT_FS"
|
ALLOW_MOUNT_FS="$MOUNT_FS"
|
||||||
@ -1582,7 +1582,7 @@ advanced_settings() {
|
|||||||
exit_script
|
exit_script
|
||||||
fi
|
fi
|
||||||
echo -e "${SEARCH}${BOLD}${DGN}Mount Filesystems: ${BGN}$ALLOW_MOUNT_FS${CL}"
|
echo -e "${SEARCH}${BOLD}${DGN}Mount Filesystems: ${BGN}$ALLOW_MOUNT_FS${CL}"
|
||||||
|
|
||||||
# Container protection
|
# Container protection
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "Protection Flag" --yesno "Prevent accidental deletion?\n\nIf enabled, container cannot be deleted or its disk modified\nDefault: No" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "Protection Flag" --yesno "Prevent accidental deletion?\n\nIf enabled, container cannot be deleted or its disk modified\nDefault: No" 10 58); then
|
||||||
PROTECT_CT="yes"
|
PROTECT_CT="yes"
|
||||||
@ -1590,7 +1590,7 @@ advanced_settings() {
|
|||||||
PROTECT_CT="no"
|
PROTECT_CT="no"
|
||||||
fi
|
fi
|
||||||
echo -e "${SEARCH}${BOLD}${DGN}Container Protection: ${BGN}$PROTECT_CT${CL}"
|
echo -e "${SEARCH}${BOLD}${DGN}Container Protection: ${BGN}$PROTECT_CT${CL}"
|
||||||
|
|
||||||
# Container timezone
|
# Container timezone
|
||||||
if CT_TIMEZONE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set container timezone (e.g., Europe/Berlin)\nLeave blank to use host timezone" 8 58 "$CT_TIMEZONE" --title "Container Timezone" 3>&1 1>&2 2>&3); then
|
if CT_TIMEZONE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set container timezone (e.g., Europe/Berlin)\nLeave blank to use host timezone" 8 58 "$CT_TIMEZONE" --title "Container Timezone" 3>&1 1>&2 2>&3); then
|
||||||
[ -z "$CT_TIMEZONE" ] && CT_TIMEZONE="(host)"
|
[ -z "$CT_TIMEZONE" ] && CT_TIMEZONE="(host)"
|
||||||
@ -1599,7 +1599,7 @@ advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
echo -e "${SEARCH}${BOLD}${DGN}Container Timezone: ${BGN}$CT_TIMEZONE${CL}"
|
echo -e "${SEARCH}${BOLD}${DGN}Container Timezone: ${BGN}$CT_TIMEZONE${CL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "FUSE Support" --yesno "Enable FUSE support?\nRequired for tools like rclone, mergerfs, AppImage, etc." 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "FUSE Support" --yesno "Enable FUSE support?\nRequired for tools like rclone, mergerfs, AppImage, etc." 10 58); then
|
||||||
ENABLE_FUSE="yes"
|
ENABLE_FUSE="yes"
|
||||||
else
|
else
|
||||||
@ -2287,8 +2287,11 @@ build_container() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# mount: allow specific filesystems (e.g., nfs, ext4, etc.)
|
# mount: allow specific filesystems (e.g., nfs, ext4, etc.)
|
||||||
|
# Format: mount=fstype1;fstype2;fstype3 (semicolon-separated, not comma!)
|
||||||
if [ -n "$ALLOW_MOUNT_FS" ]; then
|
if [ -n "$ALLOW_MOUNT_FS" ]; then
|
||||||
FEATURES="$FEATURES,mount=$ALLOW_MOUNT_FS"
|
# Replace commas with semicolons for proper pct syntax
|
||||||
|
ALLOW_MOUNT_FS_FORMATTED="${ALLOW_MOUNT_FS//,/;}"
|
||||||
|
FEATURES="$FEATURES,mount=$ALLOW_MOUNT_FS_FORMATTED"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
@ -2346,7 +2349,7 @@ build_container() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export PCT_OPTIONS="
|
export PCT_OPTIONS="
|
||||||
-features $FEATURES
|
-features '$FEATURES'
|
||||||
-hostname $HN
|
-hostname $HN
|
||||||
-tags $TAGS
|
-tags $TAGS
|
||||||
$SD
|
$SD
|
||||||
@ -3585,7 +3588,7 @@ create_lxc_container() {
|
|||||||
|
|
||||||
# First attempt
|
# First attempt
|
||||||
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" >"$LOGFILE" 2>&1; then
|
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" >"$LOGFILE" 2>&1; then
|
||||||
msg_error "Container creation failed on ${TEMPLATE_STORAGE}. Checking template..."
|
msg_debug "Container creation failed on ${TEMPLATE_STORAGE}. Validating template..."
|
||||||
|
|
||||||
# Validate template file
|
# Validate template file
|
||||||
if [[ ! -s "$TEMPLATE_PATH" || "$(stat -c%s "$TEMPLATE_PATH")" -lt 1000000 ]]; then
|
if [[ ! -s "$TEMPLATE_PATH" || "$(stat -c%s "$TEMPLATE_PATH")" -lt 1000000 ]]; then
|
||||||
@ -3604,18 +3607,16 @@ create_lxc_container() {
|
|||||||
|
|
||||||
# Retry after repair
|
# Retry after repair
|
||||||
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" >>"$LOGFILE" 2>&1; then
|
if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" >>"$LOGFILE" 2>&1; then
|
||||||
# Fallback to local storage
|
# Fallback to local storage if not already on local
|
||||||
if [[ "$TEMPLATE_STORAGE" != "local" ]]; then
|
if [[ "$TEMPLATE_STORAGE" != "local" ]]; then
|
||||||
msg_warn "Retrying container creation with fallback to local storage..."
|
msg_info "Retrying container creation with fallback to local storage..."
|
||||||
LOCAL_TEMPLATE_PATH="/var/lib/vz/template/cache/$TEMPLATE"
|
LOCAL_TEMPLATE_PATH="/var/lib/vz/template/cache/$TEMPLATE"
|
||||||
if [[ ! -f "$LOCAL_TEMPLATE_PATH" ]]; then
|
if [[ ! -f "$LOCAL_TEMPLATE_PATH" ]]; then
|
||||||
msg_info "Downloading template to local..."
|
msg_info "Downloading template to local..."
|
||||||
pveam download local "$TEMPLATE" >/dev/null 2>&1
|
pveam download local "$TEMPLATE" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
if pct create "$CTID" "local:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" >>"$LOGFILE" 2>&1; then
|
if ! pct create "$CTID" "local:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[@]}" >>"$LOGFILE" 2>&1; then
|
||||||
msg_ok "Container successfully created using local fallback."
|
# Local fallback also failed - check for LXC stack version issue
|
||||||
else
|
|
||||||
# --- Dynamic stack upgrade + auto-retry on the well-known error pattern ---
|
|
||||||
if grep -qiE 'unsupported .* version' "$LOGFILE"; then
|
if grep -qiE 'unsupported .* version' "$LOGFILE"; then
|
||||||
echo
|
echo
|
||||||
echo "pct reported 'unsupported ... version' – your LXC stack might be too old for this template."
|
echo "pct reported 'unsupported ... version' – your LXC stack might be too old for this template."
|
||||||
@ -3635,7 +3636,7 @@ create_lxc_container() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
msg_error "Container creation failed even with local fallback. See $LOGFILE"
|
msg_error "Container creation failed. See $LOGFILE"
|
||||||
if whiptail --yesno "pct create failed.\nDo you want to enable verbose debug mode and view detailed logs?" 12 70; then
|
if whiptail --yesno "pct create failed.\nDo you want to enable verbose debug mode and view detailed logs?" 12 70; then
|
||||||
set -x
|
set -x
|
||||||
bash -x -c "pct create $CTID local:vztmpl/${TEMPLATE} ${PCT_OPTIONS[*]}" 2>&1 | tee -a "$LOGFILE"
|
bash -x -c "pct create $CTID local:vztmpl/${TEMPLATE} ${PCT_OPTIONS[*]}" 2>&1 | tee -a "$LOGFILE"
|
||||||
@ -3643,10 +3644,11 @@ create_lxc_container() {
|
|||||||
fi
|
fi
|
||||||
exit 209
|
exit 209
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
msg_ok "Container successfully created using local fallback."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
msg_error "Container creation failed on local storage. See $LOGFILE"
|
# Already on local storage and still failed - check LXC stack version
|
||||||
# --- Dynamic stack upgrade + auto-retry on the well-known error pattern ---
|
|
||||||
if grep -qiE 'unsupported .* version' "$LOGFILE"; then
|
if grep -qiE 'unsupported .* version' "$LOGFILE"; then
|
||||||
echo
|
echo
|
||||||
echo "pct reported 'unsupported ... version' – your LXC stack might be too old for this template."
|
echo "pct reported 'unsupported ... version' – your LXC stack might be too old for this template."
|
||||||
@ -3675,6 +3677,8 @@ create_lxc_container() {
|
|||||||
exit 209
|
exit 209
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
msg_ok "Container successfully created after template repair."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user