mirror of https://github.com/tteck/Proxmox.git
Update create_lxc.sh
This commit is contained in:
parent
c17e8d4fc4
commit
dfc583d531
|
@ -136,20 +136,36 @@ msg_info "Updating LXC Template List"
|
||||||
pveam update >/dev/null
|
pveam update >/dev/null
|
||||||
msg_ok "Updated LXC Template List"
|
msg_ok "Updated LXC Template List"
|
||||||
|
|
||||||
# Get LXC template string
|
if [ "$arm64ct" = "yes" ]; then
|
||||||
TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-}
|
msg_info "Arm64 Detected"
|
||||||
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]}"
|
|
||||||
|
|
||||||
# Download LXC template if needed
|
|
||||||
if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; then
|
|
||||||
msg_info "Downloading LXC Template"
|
msg_info "Downloading LXC Template"
|
||||||
pveam download $TEMPLATE_STORAGE $TEMPLATE >/dev/null ||
|
pvesm add dir ctgrabtmp -content vztmpl -path /tmp/ctgrabtmp
|
||||||
|
bash <(curl -s https://raw.githubusercontent.com/ArchemedIan/Proxmox-Arm64-Container-Fetcher/main/pimox_image_fetcher.sh) ubuntu 22.04 default /tmp/ctgrabtmp/template/cache 1 >/dev/null
|
||||||
|
TEMPLATE_SEARCH=${PCT_OSTYPE}-${PCT_OSVERSION:-}
|
||||||
|
mapfile -t TEMPLATES < <(ls -l /tmp/ctgrabtmp/template/cache | 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 ! pveam list ctgrabtmp | grep -q $TEMPLATE; then
|
||||||
exit "A problem occured while downloading the LXC template."
|
exit "A problem occured while downloading the LXC template."
|
||||||
msg_ok "Downloaded LXC Template"
|
fi
|
||||||
fi
|
|
||||||
|
else
|
||||||
|
|
||||||
|
# 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]}"
|
||||||
|
|
||||||
|
# Download LXC template if needed
|
||||||
|
if ! pveam list $TEMPLATE_STORAGE | grep -q $TEMPLATE; 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
|
||||||
|
fi
|
||||||
# Combine all options
|
# Combine all options
|
||||||
DEFAULT_PCT_OPTIONS=(
|
DEFAULT_PCT_OPTIONS=(
|
||||||
-arch $(dpkg --print-architecture))
|
-arch $(dpkg --print-architecture))
|
||||||
|
@ -159,6 +175,10 @@ PCT_OPTIONS=(${PCT_OPTIONS[@]:-${DEFAULT_PCT_OPTIONS[@]}})
|
||||||
|
|
||||||
# Create container
|
# Create container
|
||||||
msg_info "Creating LXC Container"
|
msg_info "Creating LXC Container"
|
||||||
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null ||
|
if [ "$arm64ct" = "yes" ]; then
|
||||||
exit "A problem occured while trying to create container."
|
pct create $CTID ctgrabtmp:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null || exit "A problem occured while trying to create container."
|
||||||
|
pvesm remove ctgrabtmp
|
||||||
|
else
|
||||||
|
pct create $CTID ${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE} ${PCT_OPTIONS[@]} >/dev/null || exit "A problem occured while trying to create container."
|
||||||
|
fi
|
||||||
msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created."
|
msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created."
|
||||||
|
|
Loading…
Reference in New Issue