Remove hardcoded Ubuntu template - downloading templates restored

Debian defaults to Ubuntu Jammy
This commit is contained in:
Sam Heinz
2024-04-08 20:14:04 +10:00
parent 522bba69af
commit 8dd5615c48
2 changed files with 26 additions and 11 deletions

View File

@@ -72,12 +72,10 @@ Any applications not in ported or unsupported need to be tested for whether they
<details>
<summary>Unsupported applications</summary>
<li>Proxmox Backup Server - Needs custom image</li>
<li>All alpine templates - hardcoded Ubuntu base image due to Debian issues</li>
<li>The Debian template - hardcoded Ubuntu base image due to Debian issues</li>
<li>The Debian template - due to issues - see Current issues</li>
</details>
<details>
<summary>Current issues</summary>
<li>Currently the image used is hardcoded to be an Ubuntu 22.04 image.</li>
<li>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</li>
</details>

View File

@@ -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."