From e06856506209d57451243927ae9b0fe68c739a70 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Wed, 7 May 2025 11:46:57 +0200 Subject: [PATCH] Update create_lxc.sh --- ct/create_lxc.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ct/create_lxc.sh b/ct/create_lxc.sh index 9f445fb..d223038 100644 --- a/ct/create_lxc.sh +++ b/ct/create_lxc.sh @@ -280,14 +280,15 @@ if ! pct create "$CTID" "${TEMPLATE_STORAGE}:vztmpl/${TEMPLATE}" "${PCT_OPTIONS[ fi fi if [ "$UDHCPC_FIX" == "yes" ]; then - CT_ROOT="/var/lib/lxc/${CTID}/rootfs" - CONFIG_FILE="$CT_ROOT/etc/udhcpc/udhcpc.conf" + # Ensure container is mounted + if ! mount | grep -q "/var/lib/lxc/${CTID}/rootfs"; then + pct mount "$CTID" >/dev/null 2>&1 + fi + + CONFIG_FILE="/var/lib/lxc/${CTID}/rootfs/etc/udhcpc/udhcpc.conf" - # wait max. 5 seconds for rootfs for i in {1..10}; do - if [ -f "$CONFIG_FILE" ]; then - break - fi + [ -f "$CONFIG_FILE" ] && break sleep 0.5 done @@ -307,4 +308,5 @@ if [ "$UDHCPC_FIX" == "yes" ]; then msg_error "udhcpc.conf not found in $CONFIG_FILE after waiting" fi fi + msg_ok "LXC Container ${BL}$CTID${CL} ${GN}was successfully created."