From 57eac55d54e508cbc78729b3337f0ff6582a9eb1 Mon Sep 17 00:00:00 2001 From: Ing Date: Tue, 16 Dec 2025 13:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=95=9C=E5=83=8F=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C=E8=B0=83?= =?UTF-8?q?=E6=95=B4=20VMID=20=E7=94=9F=E6=88=90=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=9B=B4=E4=B8=BA=E7=81=B5=E6=B4=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/pve.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/scripts/pve.sh b/scripts/pve.sh index 8ef11a97..29d106b0 100755 --- a/scripts/pve.sh +++ b/scripts/pve.sh @@ -95,16 +95,15 @@ if ! command -v qm >/dev/null 2>&1; then exit 1 fi -if [ -z "$TAG" ]; then - TAG="$(curl -skL --connect-timeout 10 -w "%{url_effective}" -o /dev/null "${REPO}/releases/latest" | awk -F'/' '{print $NF}' | sed 's/^[v|V]//g')" -fi - if [ -n "${IMG}" ] && [ -f "${IMG}" ]; then IMG_PATH="${IMG}" else if ! command -v curl >/dev/null 2>&1; then apt-get update >/dev/null 2>&1 && apt-get install -y curl >/dev/null 2>&1 fi + if [ -z "$TAG" ]; then + TAG="$(curl -skL --connect-timeout 10 -w "%{url_effective}" -o /dev/null "${REPO}/releases/latest" | awk -F'/' '{print $NF}' | sed 's/^[v|V]//g')" + fi rm -f "/tmp/rr-${TAG}.img.zip" echo "Downloading rr-${TAG}.img.zip ... " STATUS=$(curl -skL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "/tmp/rr-${TAG}.img.zip") @@ -137,14 +136,9 @@ fi echo "Creating VM with RR ... " # 获取可用的 VMID -last_vmid=$(qm list | awk 'NR>1{print$1}' | sort -n | tail -1 2>/dev/null) -if [ -z "$last_vmid" ]; then - # 如果 last_vmid 是空字符串,说明没有VM,设置一个起始ID - VMID=100 -else - # 否则,在最后一个ID的基础上加1 - VMID=$((last_vmid + 1)) -fi +LAST_VMID=$(qm list | awk 'NR>1{print$1}' | sort -n | tail -1 2>/dev/null) +VMID=$((${LAST_VMID:-99} + 1)) + ARGS="" SATAIDX=0 @@ -232,7 +226,7 @@ qm set ${VMID} --net0 virtio,bridge=${BRIDGE} qm set ${VMID} --serial0 socket qm set ${VMID} --agent enabled=1 -qm set ${VMID} --smbios1 "uuid=$(cat /proc/sys/kernel/random/uuid),manufacturer=$(echo -n "RROrg" | base64),product=$(echo -n "RR" | base64),version=$(echo -n "$TAG" | base64),base64=1" +qm set ${VMID} --smbios1 "uuid=$(cat /proc/sys/kernel/random/uuid),manufacturer=$(echo -n "RROrg" | base64),product=$(echo -n "RR" | base64),version=$(echo -n "${TAG:-local}" | base64),base64=1" qm set ${VMID} --onboot "${ONBOOT}" echo "Created success, VMID=${VMID}"