From 8dd5615c48d4d26fd2ebf889734bc15e3ad3e8ee Mon Sep 17 00:00:00 2001 From: Sam Heinz <54530346+asylumexp@users.noreply.github.com> Date: Mon, 8 Apr 2024 20:14:04 +1000 Subject: [PATCH] Remove hardcoded Ubuntu template - downloading templates restored Debian defaults to Ubuntu Jammy --- README.md | 4 +--- ct/create_lxc.sh | 33 +++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9f6483312..5b6cbb837 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,10 @@ Any applications not in ported or unsupported need to be tested for whether they
Unsupported applications
  • Proxmox Backup Server - Needs custom image
  • -
  • All alpine templates - hardcoded Ubuntu base image due to Debian issues
  • -
  • The Debian template - hardcoded Ubuntu base image due to Debian issues
  • +
  • The Debian template - due to issues - see Current issues
  • Current issues -
  • Currently the image used is hardcoded to be an Ubuntu 22.04 image.
  • Available debian arm64 images aren't able to be used currently as they have moved from ifupdown networking to systemd-network, meaning that until I can figure out how to make a custom image using ifupdown Debian will not work, if you know how to do this please make an issue, as Im unsure of where to start with this
  • diff --git a/ct/create_lxc.sh b/ct/create_lxc.sh index 4452f907c..952ad7a5e 100644 --- a/ct/create_lxc.sh +++ b/ct/create_lxc.sh @@ -156,21 +156,38 @@ pveam update >/dev/null msg_ok "Updated LXC Template List" # Get LXC template string -TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-} -mapfile -t TEMPLATES < <(pveam available -section system | sed -n "s/.*\($TEMPLATE_SEARCH.*\)/\1/p" | sort -t - -k 2 -V) -[ ${#TEMPLATES[@]} -gt 0 ] || exit "Unable to find a template when searching for '$TEMPLATE_SEARCH'." -TEMPLATE="${TEMPLATES[-1]}" +if [ $PCT_OSTYPE = debian ]; then + if [ $PCT_OSVERSION = 11 ]; then + # TEMPLATE_SEARCH=debian-bullseye + # Debian broken - using ubuntu 22.04 + TEMPLATE_SEARCH=ubuntu-jammy + else + # TEMPLATE_SEARCH=debian-bookworm + # Debian broken - using ubuntu 22.04 + TEMPLATE_SEARCH=ubuntu-jammy + fi +elif [ $PCT_OSTYPE = alpine ]; then + TEMPLATE_SEARCH=alpine-3.18 +else + if [ $PCT_OSVERSION = 20.04 ]; then + TEMPLATE_SEARCH=ubuntu-focal + elif [ $PCT_OSVERSION = 23.10 ]; then + TEMPLATE_SEARCH=ubuntu-mantic + else + TEMPLATE_SEARCH=ubuntu-jammy + fi +fi + +TEMPLATE="$(pveam available | grep -E "arm64.*$TEMPLATE_SEARCH" | sed 's/arm64[[:space:]]*//')" # Download LXC template if needed -if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then +if ! pveam list $TEMPLATE_STORAGE | grep -F $TEMPLATE > /dev/null; then msg_info "Downloading LXC Template" pveam download $TEMPLATE_STORAGE $TEMPLATE >/dev/null || exit "A problem occured while downloading the LXC template." msg_ok "Downloaded LXC Template" fi -echo $TEMPLATE_SEARCH -echo $TEMPLATE # Combine all options DEFAULT_PCT_OPTIONS=( -arch $(dpkg --print-architecture)) @@ -180,6 +197,6 @@ PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}}) # Create container msg_info "Creating LXC Container" -pct create $CTID local:vztmpl/ubuntu-jammy-20231124_arm64.tar.xz ${PCT_OPTIONS[@]} >/dev/null || +pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null || exit "A problem occured while trying to create container." msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created."