Skip to content

Commit dcf9235

Browse files
Merge pull request #388 from community-scripts/feat/use_new_core_features
feat: Add default and advanced install method selection
2 parents 580b623 + 69a5ac3 commit dcf9235

15 files changed

Lines changed: 2704 additions & 93 deletions

scripts/core/alpine-tools.func

Lines changed: 507 additions & 0 deletions
Large diffs are not rendered by default.

scripts/core/build.func

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,10 +2441,15 @@ build_container() {
24412441
if echo "$pci_vga_info" | grep -q "\[10de:"; then
24422442
msg_custom "🎮" "${GN}" "Detected NVIDIA GPU"
24432443

2444-
# Simple passthrough - just bind /dev/nvidia* devices if they exist
2445-
for d in /dev/nvidia* /dev/nvidiactl /dev/nvidia-modeset /dev/nvidia-uvm /dev/nvidia-uvm-tools; do
2446-
[[ -e "$d" ]] && NVIDIA_DEVICES+=("$d")
2444+
for d in /dev/nvidia*; do
2445+
[[ -c "$d" ]] && NVIDIA_DEVICES+=("$d")
24472446
done
2447+
# Also check for devices inside /dev/nvidia-caps/ directory
2448+
if [[ -d /dev/nvidia-caps ]]; then
2449+
for d in /dev/nvidia-caps/*; do
2450+
[[ -c "$d" ]] && NVIDIA_DEVICES+=("$d")
2451+
done
2452+
fi
24482453

24492454
if [[ ${#NVIDIA_DEVICES[@]} -gt 0 ]]; then
24502455
msg_custom "🎮" "${GN}" "Found ${#NVIDIA_DEVICES[@]} NVIDIA device(s) for passthrough"
@@ -2954,15 +2959,14 @@ fix_gpu_gids() {
29542959

29552960
# For privileged containers: also fix permissions inside container
29562961
if [[ "$CT_TYPE" == "0" ]]; then
2957-
pct exec "$CTID" -- bash -c "
2962+
pct exec "$CTID" -- sh -c "
29582963
if [ -d /dev/dri ]; then
29592964
for dev in /dev/dri/*; do
29602965
if [ -e \"\$dev\" ]; then
2961-
if [[ \"\$dev\" =~ renderD ]]; then
2962-
chgrp ${render_gid} \"\$dev\" 2>/dev/null || true
2963-
else
2964-
chgrp ${video_gid} \"\$dev\" 2>/dev/null || true
2965-
fi
2966+
case \"\$dev\" in
2967+
*renderD*) chgrp ${render_gid} \"\$dev\" 2>/dev/null || true ;;
2968+
*) chgrp ${video_gid} \"\$dev\" 2>/dev/null || true ;;
2969+
esac
29662970
chmod 660 \"\$dev\" 2>/dev/null || true
29672971
fi
29682972
done
@@ -3211,42 +3215,26 @@ create_lxc_container() {
32113215
fi
32123216
fi
32133217

3214-
# Validate content types
3215-
msg_info "Validating content types of storage '$CONTAINER_STORAGE'"
3216-
STORAGE_CONTENT=$(grep -A4 -E "^(zfspool|dir|lvmthin|lvm|linstor): $CONTAINER_STORAGE" /etc/pve/storage.cfg | grep content | awk '{$1=""; print $0}' | xargs)
3217-
msg_debug "Storage '$CONTAINER_STORAGE' has content types: $STORAGE_CONTENT"
3218-
3219-
# Check storage type for special handling
3220-
STORAGE_TYPE=$(grep -E "^[^:]+: $CONTAINER_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1)
3221-
if [[ "$STORAGE_TYPE" == "linstor" ]]; then
3222-
msg_info "Detected LINSTOR storage - verifying cluster connectivity"
3223-
if ! pvesm status -storage "$CONTAINER_STORAGE" &>/dev/null; then
3224-
msg_error "LINSTOR storage '$CONTAINER_STORAGE' not accessible. Check LINSTOR cluster health."
3225-
exit 217
3226-
fi
3227-
fi
3228-
3229-
grep -qw "rootdir" <<<"$STORAGE_CONTENT" || {
3230-
msg_error "Storage '$CONTAINER_STORAGE' does not support 'rootdir'. Cannot create LXC."
3231-
exit 217
3232-
}
3233-
$STD msg_ok "Storage '$CONTAINER_STORAGE' supports 'rootdir'"
3218+
msg_info "Validating storage '$CONTAINER_STORAGE'"
3219+
STORAGE_TYPE=$(grep -E "^[^:]+: $CONTAINER_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1 | head -1)
32343220

3235-
msg_info "Validating content types of template storage '$TEMPLATE_STORAGE'"
3236-
TEMPLATE_CONTENT=$(grep -A4 -E "^[^:]+: $TEMPLATE_STORAGE" /etc/pve/storage.cfg | grep content | awk '{$1=""; print $0}' | xargs)
3237-
msg_debug "Template storage '$TEMPLATE_STORAGE' has content types: $TEMPLATE_CONTENT"
3221+
case "$STORAGE_TYPE" in
3222+
iscsidirect) exit 212 ;;
3223+
iscsi | zfs) exit 213 ;;
3224+
cephfs) exit 219 ;;
3225+
pbs) exit 224 ;;
3226+
linstor | rbd | nfs | cifs)
3227+
pvesm status -storage "$CONTAINER_STORAGE" &>/dev/null || exit 217
3228+
;;
3229+
esac
32383230

3239-
# Check if template storage is LINSTOR (may need special handling)
3240-
TEMPLATE_TYPE=$(grep -E "^[^:]+: $TEMPLATE_STORAGE$" /etc/pve/storage.cfg | cut -d: -f1)
3241-
if [[ "$TEMPLATE_TYPE" == "linstor" ]]; then
3242-
msg_info "Template storage uses LINSTOR - ensuring resource availability"
3243-
fi
3231+
pvesm status -content rootdir 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$CONTAINER_STORAGE" || exit 213Add a comment on line R3227Add diff commentMarkdown input: edit mode selected.WritePreviewAdd a suggestionHeadingBoldItalicQuoteCodeLinkUnordered listNumbered listTask listMentionReferenceSaved repliesAdd FilesPaste, drop, or click to add filesCancelCommentStart a reviewReturn to code
3232+
msg_ok "Storage '$CONTAINER_STORAGE' ($STORAGE_TYPE) validated"
32443233

3245-
if ! grep -qw "vztmpl" <<<"$TEMPLATE_CONTENT"; then
3246-
msg_warn "Template storage '$TEMPLATE_STORAGE' does not declare 'vztmpl'. This may cause pct create to fail."
3247-
else
3248-
$STD msg_ok "Template storage '$TEMPLATE_STORAGE' supports 'vztmpl'"
3234+
if ! pvesm status -content vztmpl 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$TEMPLATE_STORAGE"; then
3235+
msg_warn "Template storage '$TEMPLATE_STORAGE' may not support 'vztmpl'"
32493236
fi
3237+
msg_ok "Template storage '$TEMPLATE_STORAGE' validated"
32503238

32513239
# Free space check
32523240
STORAGE_FREE=$(pvesm status | awk -v s="$CONTAINER_STORAGE" '$1 == s { print $6 }')
@@ -3261,7 +3249,7 @@ create_lxc_container() {
32613249
msg_info "Checking cluster quorum"
32623250
if ! pvecm status | awk -F':' '/^Quorate/ { exit ($2 ~ /Yes/) ? 0 : 1 }'; then
32633251
msg_error "Cluster is not quorate. Start all nodes or configure quorum device (QDevice)."
3264-
exit 201
3252+
exit 210
32653253
fi
32663254
msg_ok "Cluster is quorate"
32673255
fi
@@ -3417,6 +3405,15 @@ create_lxc_container() {
34173405
ONLINE_TEMPLATE=""
34183406
[[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]] && ONLINE_TEMPLATE="${ONLINE_TEMPLATES[-1]}"
34193407

3408+
if [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]]; then
3409+
count=0
3410+
for idx in "${!ONLINE_TEMPLATES[@]}"; do
3411+
((count++))
3412+
[[ $count -ge 3 ]] && break
3413+
done
3414+
ONLINE_TEMPLATE="${ONLINE_TEMPLATES[$idx]}"
3415+
fi
3416+
34203417
if [[ ${#LOCAL_TEMPLATES[@]} -gt 0 ]]; then
34213418
TEMPLATE="${LOCAL_TEMPLATES[-1]}"
34223419
TEMPLATE_SOURCE="local"
@@ -3554,7 +3551,7 @@ create_lxc_container() {
35543551
}
35553552
flock -w 60 9 || {
35563553
msg_error "Timeout while waiting for template lock."
3557-
exit 202
3554+
exit 211
35583555
}
35593556

35603557
LOGFILE="/tmp/pct_create_${CTID}_$(date +%Y%m%d_%H%M%S)_${SESSION_ID}.log"
@@ -3604,11 +3601,11 @@ create_lxc_container() {
36043601
2)
36053602
echo "Upgrade was declined. Please update and re-run:
36063603
apt update && apt install --only-upgrade pve-container lxc-pve"
3607-
exit 213
3604+
exit 231
36083605
;;
36093606
3)
36103607
echo "Upgrade and/or retry failed. Please inspect: $LOGFILE"
3611-
exit 213
3608+
exit 231
36123609
;;
36133610
esac
36143611
else

0 commit comments

Comments
 (0)