1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-04-19 00:38:08 +00:00

quickfix broken vms

This commit is contained in:
CanbiZ 2025-04-09 19:29:12 +02:00
parent ef81b82d87
commit 30fbcb5ba8
13 changed files with 150 additions and 145 deletions

View File

@ -6,6 +6,7 @@
source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
function header_info { function header_info {
clear clear
cat <<"EOF" cat <<"EOF"

View File

@ -4,7 +4,7 @@
# Author: MickLesk (CanbiZ) # Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
function header_info { function header_info {
clear clear
@ -425,7 +425,7 @@ msg_info "Retrieving the URL for the Debian 12 Qcow2 Disk Image"
URL=https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2 URL=https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-amd64.qcow2
sleep 2 sleep 2
msg_ok "${CL}${BL}${URL}${CL}" msg_ok "${CL}${BL}${URL}${CL}"
wget -q --show-progress $URL curl -f#SL -o "$(basename "$URL")" "$URL"
echo -en "\e[1A\e[0K" echo -en "\e[1A\e[0K"
FILE=$(basename $URL) FILE=$(basename $URL)
msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" msg_ok "Downloaded ${CL}${BL}${FILE}${CL}"

View File

@ -108,7 +108,7 @@ function pve_check() {
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function arch_check() { function arch_check() {
@ -421,13 +421,14 @@ msg_ok "Installed libguestfs-tools successfully"
msg_info "Adding Docker and Docker Compose Plugin to Debian 12 Qcow2 Disk Image" msg_info "Adding Docker and Docker Compose Plugin to Debian 12 Qcow2 Disk Image"
virt-customize -q -a "${FILE}" --install qemu-guest-agent,apt-transport-https,ca-certificates,curl,gnupg,software-properties-common,lsb-release >/dev/null && virt-customize -q -a "${FILE}" --install qemu-guest-agent,apt-transport-https,ca-certificates,curl,gnupg,software-properties-common,lsb-release >/dev/null &&
virt-customize -q -a "${FILE}" --run-command "mkdir -p /etc/apt/keyrings && curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg" >/dev/null && virt-customize -q -a "${FILE}" --run-command "mkdir -p /etc/apt/keyrings && curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg" >/dev/null &&
virt-customize -q -a "${FILE}" --run-command "echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable' > /etc/apt/sources.list.d/docker.list" >/dev/null && virt-customize -q -a "${FILE}" --run-command "echo 'deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable' > /etc/apt/sources.list.d/docker.list" >/dev/null &&
virt-customize -q -a "${FILE}" --run-command "apt-get update -qq && apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin" >/dev/null && virt-customize -q -a "${FILE}" --run-command "apt-get update -qq && apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin" >/dev/null &&
virt-customize -q -a "${FILE}" --run-command "systemctl enable docker" >/dev/null && virt-customize -q -a "${FILE}" --run-command "systemctl enable docker" >/dev/null &&
virt-customize -q -a "${FILE}" --run-command "echo -n > /etc/machine-id" >/dev/null virt-customize -q -a "${FILE}" --run-command "echo -n > /etc/machine-id" >/dev/null
msg_ok "Added Docker and Docker Compose Plugin to Debian 12 Qcow2 Disk Image successfully" msg_ok "Added Docker and Docker Compose Plugin to Debian 12 Qcow2 Disk Image successfully"
msg_info "Creating a Docker VM" msg_info "Creating a Docker VM"
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \ qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios ovmf${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
-name $HN -tags community-script,debian12,docker -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci -name $HN -tags community-script,debian12,docker -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
@ -441,8 +442,7 @@ qm set $VMID \
qm resize $VMID scsi0 8G >/dev/null qm resize $VMID scsi0 8G >/dev/null
qm set $VMID --agent enabled=1 >/dev/null qm set $VMID --agent enabled=1 >/dev/null
DESCRIPTION=$( DESCRIPTION=$(cat <<EOF
cat <<EOF
<div align='center'> <div align='center'>
<a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'> <a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'>
<img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/> <img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/>

View File

@ -7,6 +7,7 @@
source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
function header_info { function header_info {
clear clear
cat <<"EOF" cat <<"EOF"
@ -54,7 +55,7 @@ trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
function error_handler() { function error_handler() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
printf "\e[?25h" printf "\e[?25h"
local exit_code="$?" local exit_code="$?"
local line_number="$1" local line_number="$1"
@ -103,14 +104,14 @@ function msg_info() {
} }
function msg_ok() { function msg_ok() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
printf "\e[?25h" printf "\e[?25h"
local msg="$1" local msg="$1"
echo -e "${BFR} ${CM} ${GN}${msg}${CL}" echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
} }
function msg_error() { function msg_error() {
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
printf "\e[?25h" printf "\e[?25h"
local msg="$1" local msg="$1"
echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}" echo -e "${BFR} ${CROSS} ${RD}${msg}${CL}"
@ -133,7 +134,7 @@ function pve_check() {
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function arch_check() { function arch_check() {
@ -392,6 +393,7 @@ pve_check
ssh_check ssh_check
start_script start_script
post_to_api_vm post_to_api_vm
msg_info "Validating Storage" msg_info "Validating Storage"
@ -414,7 +416,7 @@ elif [ $((${#STORAGE_MENU[@]} / 3)) -eq 1 ]; then
STORAGE=${STORAGE_MENU[0]} STORAGE=${STORAGE_MENU[0]}
else else
while [ -z "${STORAGE:+x}" ]; do while [ -z "${STORAGE:+x}" ]; do
if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID >/dev/null; then kill $SPINNER_PID >/dev/null; fi if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
printf "\e[?25h" printf "\e[?25h"
STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \ STORAGE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "Storage Pools" --radiolist \
"Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\n" \ "Which storage pool you would like to use for ${HN}?\nTo make a selection, use the Spacebar.\n" \
@ -483,3 +485,5 @@ if [ "$START_VM" == "yes" ]; then
fi fi
post_update_to_api "done" "none" post_update_to_api "done" "none"
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"

View File

@ -7,6 +7,7 @@
source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func) source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
function header_info { function header_info {
cat <<"EOF" cat <<"EOF"
__ ____ __ __ _ __ ____ __ ____ _____ ________ ______ __ ____ __ __ _ __ ____ __ ____ _____ ________ ______

View File

@ -110,7 +110,7 @@ function pve_check() {
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function arch_check() { function arch_check() {

View File

@ -176,7 +176,7 @@ function pve_check() {
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function arch_check() { function arch_check() {

View File

@ -530,7 +530,7 @@ msg_ok "${CL}${BL}${URL}${CL}"
curl -f#SL -o "$(basename "$URL")" "$URL" curl -f#SL -o "$(basename "$URL")" "$URL"
echo -en "\e[1A\e[0K" echo -en "\e[1A\e[0K"
FILE=Fressbsd.qcow2 FILE=Fressbsd.qcow2
unxz -cv $(basename $URL) >${FILE} unxz -cv $(basename $URL) > ${FILE}
msg_ok "Downloaded ${CL}${BL}${FILE}${CL}" msg_ok "Downloaded ${CL}${BL}${FILE}${CL}"
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}') STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
@ -564,11 +564,10 @@ qm set $VMID \
-efidisk0 ${DISK0_REF}${FORMAT} \ -efidisk0 ${DISK0_REF}${FORMAT} \
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \ -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \
-boot order=scsi0 \ -boot order=scsi0 \
-serial0 socket \ -serial0 socket >/dev/null \
-tags community-script >/dev/null -tags community-script
qm resize $VMID scsi0 10G >/dev/null qm resize $VMID scsi0 10G >/dev/null
DESCRIPTION=$( DESCRIPTION=$(cat <<EOF
cat <<EOF
<div align='center'> <div align='center'>
<a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'> <a href='https://Helper-Scripts.com' target='_blank' rel='noopener noreferrer'>
<img src='https://raw.githubusercontent.com/michelroegl-brunner/ProxmoxVE/refs/heads/develop/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/> <img src='https://raw.githubusercontent.com/michelroegl-brunner/ProxmoxVE/refs/heads/develop/misc/images/logo-81x112.png' alt='Logo' style='width:81px;height:112px;'/>
@ -597,7 +596,7 @@ DESCRIPTION=$(
</div> </div>
EOF EOF
) )
qm set "$VMID" -description "$DESCRIPTION" >/dev/null qm set "$VMID" -description "$DESCRIPTION" >/dev/null
msg_info "Bridge interfaces are being added." msg_info "Bridge interfaces are being added."
qm set $VMID \ qm set $VMID \
@ -605,23 +604,23 @@ qm set $VMID \
msg_ok "Bridge interfaces have been successfully added." msg_ok "Bridge interfaces have been successfully added."
msg_ok "Created a OPNsense VM ${CL}${BL}(${HN})" msg_ok "Created a OPNsense VM ${CL}${BL}(${HN})"
msg_ok "Starting OPNsense VM (Patience this takes 20-30 minutes)" msg_ok "Starting OPNsense VM (Patience this takes 20-30 minutes)"
qm start $VMID qm start $VMID
sleep 90 sleep 90
send_line_to_vm "root" send_line_to_vm "root"
send_line_to_vm "fetch https://raw.githubusercontent.com/opnsense/update/master/src/bootstrap/opnsense-bootstrap.sh.in" send_line_to_vm "fetch https://raw.githubusercontent.com/opnsense/update/master/src/bootstrap/opnsense-bootstrap.sh.in"
qm set $VMID \ qm set $VMID \
-net1 virtio,bridge=${WAN_BRG},macaddr=${WAN_MAC} &>/dev/null -net1 virtio,bridge=${WAN_BRG},macaddr=${WAN_MAC} &>/dev/null
sleep 10 sleep 10
send_line_to_vm "sh ./opnsense-bootstrap.sh.in -y -f -r 25.1" send_line_to_vm "sh ./opnsense-bootstrap.sh.in -y -f -r 25.1"
msg_ok "OPNsense VM is being installed, do not close the terminal, or the installation will fail." msg_ok "OPNsense VM is being installed, do not close the terminal, or the installation will fail."
#We need to wait for the OPNsense build proccess to finish, this takes a few minutes #We need to wait for the OPNsense build proccess to finish, this takes a few minutes
sleep 1000 sleep 1000
send_line_to_vm "root" send_line_to_vm "root"
send_line_to_vm "opnsense" send_line_to_vm "opnsense"
send_line_to_vm "2" send_line_to_vm "2"
if [ "$IP_ADDR" != "" ]; then if [ "$IP_ADDR" != "" ]; then
send_line_to_vm "1" send_line_to_vm "1"
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "${IP_ADDR}" send_line_to_vm "${IP_ADDR}"
@ -637,7 +636,7 @@ if [ "$IP_ADDR" != "" ]; then
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "n" send_line_to_vm "n"
else else
send_line_to_vm "1" send_line_to_vm "1"
send_line_to_vm "y" send_line_to_vm "y"
send_line_to_vm "n" send_line_to_vm "n"
@ -646,10 +645,10 @@ else
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "n" send_line_to_vm "n"
fi fi
#we need to wait for the Config changes to be saved #we need to wait for the Config changes to be saved
sleep 20 sleep 20
if [ "$WAN_IP_ADDR" != "" ]; then if [ "$WAN_IP_ADDR" != "" ]; then
send_line_to_vm "2" send_line_to_vm "2"
send_line_to_vm "2" send_line_to_vm "2"
send_line_to_vm "n" send_line_to_vm "n"
@ -663,10 +662,10 @@ if [ "$WAN_IP_ADDR" != "" ]; then
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "n" send_line_to_vm "n"
send_line_to_vm "n" send_line_to_vm "n"
fi fi
sleep 10 sleep 10
send_line_to_vm "0" send_line_to_vm "0"
msg_ok "Started OPNsense VM" msg_ok "Started OPNsense VM"
msg_ok "Completed Successfully!\n" msg_ok "Completed Successfully!\n"
if [ "$IP_ADDR" != "" ]; then if [ "$IP_ADDR" != "" ]; then

View File

@ -104,13 +104,13 @@ function check_root() {
} }
function pve_check() { function pve_check() {
if ! pveversion | grep -Eq "pve-manager/8\.[1-4](\.[0-9]+)*"; then if ! pveversion | grep -Eq "pve-manager/8\.[1-4](\.[0-9]+)*"; then
msg_error "This version of Proxmox Virtual Environment is not supported" msg_error "This version of Proxmox Virtual Environment is not supported"
echo -e "Requires Proxmox Virtual Environment Version 8.1 or later." echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
echo -e "Exiting..." echo -e "Exiting..."
sleep 2 sleep 2
exit exit
fi fi
} }
function arch_check() { function arch_check() {

View File

@ -84,7 +84,7 @@ function cleanup() {
} }
TEMP_DIR=$(mktemp -d) TEMP_DIR=$(mktemp -d)
pushd $TEMP_DIR >/dev/null pushd $TEMP_DIR >/dev/null
if ! command -v whiptail &>/dev/null; then if ! command -v whiptail &> /dev/null; then
echo "Installing whiptail..." echo "Installing whiptail..."
apt-get update &>/dev/null apt-get update &>/dev/null
apt-get install -y whiptail &>/dev/null apt-get install -y whiptail &>/dev/null