mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-04-20 00:25:12 +00:00
quickfix vm's for pve 8.4
This commit is contained in:
parent
2b8d10a4d9
commit
84478921e7
@ -77,19 +77,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Arch Linux VM" --yesno "This will create a New Arch Linux VM. Proceed?" 10 58; then
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Arch Linux VM" --yesno "This will create a New Arch Linux VM. Proceed?" 10 58; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@ -122,7 +122,7 @@ 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-3](\.[0-9]+)*"; then
|
||||||
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
msg_error "${CROSS}${RD}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..."
|
||||||
@ -195,7 +195,7 @@ function default_settings() {
|
|||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -215,7 +215,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -247,7 +247,7 @@ function advanced_settings() {
|
|||||||
"0" "None (Default)" ON \
|
"0" "None (Default)" ON \
|
||||||
"1" "Write Through" OFF \
|
"1" "Write Through" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE" = "1" ]; then
|
if [ $DISK_CACHE = "1" ]; then
|
||||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -259,11 +259,11 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 arch-linux --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 arch-linux --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="arch-linux"
|
HN="arch-linux"
|
||||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -274,7 +274,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64 (Default)" ON \
|
"0" "KVM64 (Default)" ON \
|
||||||
"1" "Host" OFF \
|
"1" "Host" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}"
|
echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -286,7 +286,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
else
|
else
|
||||||
@ -297,7 +297,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="2048"
|
RAM_SIZE="2048"
|
||||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
||||||
else
|
else
|
||||||
@ -308,7 +308,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
||||||
else
|
else
|
||||||
@ -318,8 +318,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
||||||
else
|
else
|
||||||
@ -331,7 +331,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}"
|
echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}"
|
||||||
@ -344,7 +344,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
@ -394,9 +394,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -429,7 +429,7 @@ 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}"
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir | cifs)
|
nfs | dir | cifs)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -447,19 +447,19 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating a Arch Linux VM"
|
msg_info "Creating a Arch Linux 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 -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-efidisk0 "${DISK0_REF}"${FORMAT} \
|
-efidisk0 ${DISK0_REF}${FORMAT} \
|
||||||
-scsi0 "${DISK1_REF}",${DISK_CACHE}${THIN}size="${DISK_SIZE}" \
|
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \
|
||||||
-ide2 "${STORAGE}":cloudinit \
|
-ide2 ${STORAGE}:cloudinit \
|
||||||
-boot order=scsi0 \
|
-boot order=scsi0 \
|
||||||
-serial0 socket >/dev/null
|
-serial0 socket >/dev/null
|
||||||
DESCRIPTION=$(
|
DESCRIPTION=$(
|
||||||
@ -495,16 +495,16 @@ EOF
|
|||||||
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
||||||
if [ -n "$DISK_SIZE" ]; then
|
if [ -n "$DISK_SIZE" ]; then
|
||||||
msg_info "Resizing disk to $DISK_SIZE GB"
|
msg_info "Resizing disk to $DISK_SIZE GB"
|
||||||
qm resize "$VMID" scsi0 "${DISK_SIZE}" >/dev/null
|
qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null
|
||||||
else
|
else
|
||||||
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
|
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
|
||||||
qm resize "$VMID" scsi0 "${DEFAULT_DISK_SIZE}" >/dev/null
|
qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_ok "Created a Arch Linux VM ${CL}${BL}(${HN})"
|
msg_ok "Created a Arch Linux VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Arch Linux VM"
|
msg_info "Starting Arch Linux VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started Arch Linux VM"
|
msg_ok "Started Arch Linux VM"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
@ -123,7 +122,7 @@ 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-3](\.[0-9]+)*"; then
|
||||||
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
msg_error "${CROSS}${RD}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..."
|
||||||
|
@ -57,19 +57,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Docker VM" --yesno "This will create a New Docker VM. Proceed?" 10 58; then
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Docker VM" --yesno "This will create a New Docker VM. Proceed?" 10 58; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@ -102,7 +102,7 @@ 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-3](\.[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..."
|
||||||
@ -174,7 +174,7 @@ function default_settings() {
|
|||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -194,7 +194,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -211,7 +211,7 @@ function advanced_settings() {
|
|||||||
"0" "None (Default)" ON \
|
"0" "None (Default)" ON \
|
||||||
"1" "Write Through" OFF \
|
"1" "Write Through" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE" = "1" ]; then
|
if [ $DISK_CACHE = "1" ]; then
|
||||||
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -223,11 +223,11 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 docker --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 docker --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="docker"
|
HN="docker"
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -238,7 +238,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64 (Default)" ON \
|
"0" "KVM64 (Default)" ON \
|
||||||
"1" "Host" OFF \
|
"1" "Host" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -250,7 +250,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
else
|
else
|
||||||
@ -261,7 +261,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="4096"
|
RAM_SIZE="4096"
|
||||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||||
else
|
else
|
||||||
@ -272,7 +272,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
||||||
else
|
else
|
||||||
@ -282,8 +282,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
|
||||||
else
|
else
|
||||||
@ -295,7 +295,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
||||||
@ -308,7 +308,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
@ -358,9 +358,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -390,10 +390,10 @@ sleep 2
|
|||||||
msg_ok "${CL}${BL}${URL}${CL}"
|
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=$(basename "$URL")
|
FILE=$(basename $URL)
|
||||||
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}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir)
|
nfs | dir)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -411,8 +411,8 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Installing Pre-Requisite libguestfs-tools onto Host"
|
msg_info "Installing Pre-Requisite libguestfs-tools onto Host"
|
||||||
@ -429,17 +429,17 @@ virt-customize -q -a "${FILE}" --install qemu-guest-agent,apt-transport-https,ca
|
|||||||
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
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
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 >/dev/null
|
-serial0 socket >/dev/null
|
||||||
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
|
||||||
@ -476,7 +476,7 @@ qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
|||||||
msg_ok "Created a Docker VM ${CL}${BL}(${HN})"
|
msg_ok "Created a Docker VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Docker VM"
|
msg_info "Starting Docker VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started Docker VM"
|
msg_ok "Started Docker VM"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
@ -66,19 +66,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOME ASSISTANT OS VM" --yesno "This will create a New Home Assistant OS VM. Proceed?" 10 58; then
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "HOME ASSISTANT OS VM" --yesno "This will create a New Home Assistant OS VM. Proceed?" 10 58; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@ -127,7 +127,7 @@ 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-3](\.[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..."
|
||||||
@ -211,7 +211,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -231,7 +231,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -248,7 +248,7 @@ function advanced_settings() {
|
|||||||
"0" "None" OFF \
|
"0" "None" OFF \
|
||||||
"1" "Write Through (Default)" ON \
|
"1" "Write Through (Default)" ON \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE1" = "1" ]; then
|
if [ $DISK_CACHE1 = "1" ]; then
|
||||||
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -259,12 +259,12 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 haos"${BRANCH}" --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 haos${BRANCH} --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="haos${BRANCH}"
|
HN="haos${BRANCH}"
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -275,7 +275,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64" OFF \
|
"0" "KVM64" OFF \
|
||||||
"1" "Host (Default)" ON \
|
"1" "Host (Default)" ON \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -287,7 +287,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
else
|
else
|
||||||
@ -298,7 +298,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 4096 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="4096"
|
RAM_SIZE="4096"
|
||||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||||
else
|
else
|
||||||
@ -309,7 +309,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
||||||
else
|
else
|
||||||
@ -319,8 +319,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
|
||||||
else
|
else
|
||||||
@ -332,7 +332,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
||||||
@ -345,7 +345,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
@ -396,9 +396,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -434,11 +434,11 @@ sleep 2
|
|||||||
msg_ok "${CL}${BL}${URL}${CL}"
|
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=$(basename "$URL")
|
FILE=$(basename $URL)
|
||||||
msg_ok "Downloaded ${CL}${BL}haos_ova-${BRANCH}.qcow2.xz${CL}"
|
msg_ok "Downloaded ${CL}${BL}haos_ova-${BRANCH}.qcow2.xz${CL}"
|
||||||
msg_info "Extracting KVM Disk Image"
|
msg_info "Extracting KVM Disk Image"
|
||||||
unxz "$FILE"
|
unxz $FILE
|
||||||
STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir)
|
nfs | dir)
|
||||||
DISK_EXT=".raw"
|
DISK_EXT=".raw"
|
||||||
@ -456,18 +456,18 @@ btrfs | local-zfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
msg_ok "Extracted KVM Disk Image"
|
msg_ok "Extracted KVM Disk Image"
|
||||||
msg_info "Creating HAOS VM"
|
msg_info "Creating HAOS 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 -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE%.*}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-efidisk0 "${DISK0_REF}"${FORMAT} \
|
-efidisk0 ${DISK0_REF}${FORMAT} \
|
||||||
-scsi0 "${DISK1_REF}",${DISK_CACHE}${THIN}size=32G \
|
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=32G \
|
||||||
-boot order=scsi0 \
|
-boot order=scsi0 \
|
||||||
-description "<div align='center'><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'/></a>
|
-description "<div align='center'><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'/></a>
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ qm set "$VMID" \
|
|||||||
msg_ok "Created HAOS VM ${CL}${BL}(${HN})"
|
msg_ok "Created HAOS VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Home Assistant OS VM"
|
msg_info "Starting Home Assistant OS VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started Home Assistant OS VM"
|
msg_ok "Started Home Assistant OS VM"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
@ -57,24 +57,24 @@ function error_exit() {
|
|||||||
local msg="${1:-$reason}"
|
local msg="${1:-$reason}"
|
||||||
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
|
||||||
echo -e "$flag $msg" 1>&2
|
echo -e "$flag $msg" 1>&2
|
||||||
[ ! -z "${VMID-}" ] && cleanup_vmid
|
[ ! -z ${VMID-} ] && cleanup_vmid
|
||||||
exit "$EXIT"
|
exit $EXIT
|
||||||
}
|
}
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if $(qm status "$VMID" &>/dev/null); then
|
if $(qm status $VMID &>/dev/null); then
|
||||||
if [ "$(qm status "$VMID" | awk '{print $2}')" == "running" ]; then
|
if [ "$(qm status $VMID | awk '{print $2}')" == "running" ]; then
|
||||||
qm stop "$VMID"
|
qm stop $VMID
|
||||||
fi
|
fi
|
||||||
qm destroy "$VMID"
|
qm destroy $VMID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if ! pveversion | grep -Eq "pve-manager/8\.[1-4](\.[0-9]+)*"; then
|
if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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..."
|
||||||
@ -121,7 +121,7 @@ function default_settings() {
|
|||||||
}
|
}
|
||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" 3>&1 1>&2 2>&3)
|
VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" 3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus = 0 ]; then
|
if [ $exitstatus = 0 ]; then
|
||||||
echo -e "${DGN}Using Virtual Machine ID: ${BGN}$VMID${CL}"
|
echo -e "${DGN}Using Virtual Machine ID: ${BGN}$VMID${CL}"
|
||||||
@ -131,7 +131,7 @@ function advanced_settings() {
|
|||||||
VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 mikrotik-routeros-chr --title "HOSTNAME" 3>&1 1>&2 2>&3)
|
VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 mikrotik-routeros-chr --title "HOSTNAME" 3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus = 0 ]; then
|
if [ $exitstatus = 0 ]; then
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
@ -157,7 +157,7 @@ function advanced_settings() {
|
|||||||
else
|
else
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" 3>&1 1>&2 2>&3)
|
MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" 3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus = 0 ]; then
|
if [ $exitstatus = 0 ]; then
|
||||||
MAC="$MAC1"
|
MAC="$MAC1"
|
||||||
@ -168,7 +168,7 @@ function advanced_settings() {
|
|||||||
VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3)
|
VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" 3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus = 0 ]; then
|
if [ $exitstatus = 0 ]; then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default" VLAN=""
|
VLAN1="Default" VLAN=""
|
||||||
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
||||||
else
|
else
|
||||||
@ -179,7 +179,7 @@ function advanced_settings() {
|
|||||||
MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3)
|
||||||
exitstatus=$?
|
exitstatus=$?
|
||||||
if [ $exitstatus = 0 ]; then
|
if [ $exitstatus = 0 ]; then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default" MTU=""
|
MTU1="Default" MTU=""
|
||||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
else
|
else
|
||||||
@ -221,9 +221,9 @@ start_script
|
|||||||
post_to_api_vm
|
post_to_api_vm
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -259,8 +259,8 @@ 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}"
|
||||||
msg_info "Extracting Mikrotik RouterOS CHR Disk Image"
|
msg_info "Extracting Mikrotik RouterOS CHR Disk Image"
|
||||||
gunzip -f -S .zip "$FILE"
|
gunzip -f -S .zip $FILE
|
||||||
STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir)
|
nfs | dir)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -284,11 +284,11 @@ DISK_REF="${STORAGE}:${DISK_REF:-}${DISK_VAR:-}"
|
|||||||
|
|
||||||
msg_ok "Extracted Mikrotik RouterOS CHR Disk Image"
|
msg_ok "Extracted Mikrotik RouterOS CHR Disk Image"
|
||||||
msg_info "Creating Mikrotik RouterOS CHR VM"
|
msg_info "Creating Mikrotik RouterOS CHR VM"
|
||||||
qm create "$VMID" -tablet 0 -localtime 1 -cores "$CORE_COUNT" -memory "$RAM_SIZE" -name "$HN" \
|
qm create $VMID -tablet 0 -localtime 1 -cores $CORE_COUNT -memory $RAM_SIZE -name $HN \
|
||||||
-tags community-script -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" \
|
-tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU \
|
||||||
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
qm importdisk "$VMID" "${FILE%.*}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-scsi0 "$DISK_REF" \
|
-scsi0 "$DISK_REF" \
|
||||||
-boot order=scsi0 \
|
-boot order=scsi0 \
|
||||||
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
|
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
|
||||||
@ -300,7 +300,7 @@ qm set "$VMID" \
|
|||||||
msg_ok "Mikrotik RouterOS CHR VM ${CL}${BL}(${HN})"
|
msg_ok "Mikrotik RouterOS CHR VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Mikrotik RouterOS CHR VM"
|
msg_info "Starting Mikrotik RouterOS CHR VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started Mikrotik RouterOS CHR VM"
|
msg_ok "Started Mikrotik RouterOS CHR VM"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
@ -59,19 +59,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "$NAME" --yesno "This will create a New $NAME. Proceed?" 10 58; then
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "$NAME" --yesno "This will create a New $NAME. Proceed?" 10 58; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@ -104,7 +104,7 @@ 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-3](\.[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..."
|
||||||
@ -174,7 +174,7 @@ function default_settings() {
|
|||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -194,7 +194,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -211,7 +211,7 @@ function advanced_settings() {
|
|||||||
"0" "None (Default)" ON \
|
"0" "None (Default)" ON \
|
||||||
"1" "Write Through" OFF \
|
"1" "Write Through" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE" = "1" ]; then
|
if [ $DISK_CACHE = "1" ]; then
|
||||||
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -223,11 +223,11 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 turnkey-nextcloud-vm --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 turnkey-nextcloud-vm --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="$HN"
|
HN="$HN"
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -238,7 +238,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64 (Default)" ON \
|
"0" "KVM64 (Default)" ON \
|
||||||
"1" "Host" OFF \
|
"1" "Host" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -250,7 +250,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
else
|
else
|
||||||
@ -261,7 +261,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="2048"
|
RAM_SIZE="2048"
|
||||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||||
else
|
else
|
||||||
@ -272,7 +272,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
echo -e "${DGN}Using Bridge: ${BGN}$BRG${CL}"
|
||||||
else
|
else
|
||||||
@ -282,8 +282,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${DGN}Using MAC Address: ${BGN}$MAC${CL}"
|
||||||
else
|
else
|
||||||
@ -295,7 +295,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
echo -e "${DGN}Using Vlan: ${BGN}$VLAN1${CL}"
|
||||||
@ -308,7 +308,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
@ -359,9 +359,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -394,7 +394,7 @@ 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}"
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir)
|
nfs | dir)
|
||||||
DISK_EXT=".raw"
|
DISK_EXT=".raw"
|
||||||
@ -412,20 +412,20 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1,2}; do
|
for i in {0,1,2}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating a $NAME"
|
msg_info "Creating a $NAME"
|
||||||
qm create "$VMID" -agent 1"${MACHINE}" -tablet 0 -localtime 1 -bios seabios"${CPU_TYPE}" -cores "$CORE_COUNT" -memory "$RAM_SIZE" \
|
qm create $VMID -agent 1${MACHINE} -tablet 0 -localtime 1 -bios seabios${CPU_TYPE} -cores $CORE_COUNT -memory $RAM_SIZE \
|
||||||
-name "$HN" -tags community-script -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK1" 12G 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK1 12G 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-efidisk0 "${DISK0_REF}"${FORMAT} \
|
-efidisk0 ${DISK0_REF}${FORMAT} \
|
||||||
-scsi0 "${DISK1_REF}",${DISK_CACHE}${THIN} \
|
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN} \
|
||||||
-scsi1 "${DISK2_REF}",${DISK_CACHE}${THIN} \
|
-scsi1 ${DISK2_REF},${DISK_CACHE}${THIN} \
|
||||||
-boot order='scsi1;scsi0' \
|
-boot order='scsi1;scsi0' \
|
||||||
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
|
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ qm set "$VMID" \
|
|||||||
msg_ok "Created a $NAME ${CL}${BL}(${HN})"
|
msg_ok "Created a $NAME ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting $NAME"
|
msg_info "Starting $NAME"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started $NAME"
|
msg_ok "Started $NAME"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
@ -62,19 +62,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
function send_line_to_vm() {
|
function send_line_to_vm() {
|
||||||
echo -e "${DGN}Sending line: ${YW}$1${CL}"
|
echo -e "${DGN}Sending line: ${YW}$1${CL}"
|
||||||
for ((i = 0; i < ${#1}; i++)); do
|
for ((i = 0; i < ${#1}; i++)); do
|
||||||
@ -140,13 +140,13 @@ function send_line_to_vm() {
|
|||||||
"(") character="shift-9" ;;
|
"(") character="shift-9" ;;
|
||||||
")") character="shift-0" ;;
|
")") character="shift-0" ;;
|
||||||
esac
|
esac
|
||||||
qm sendkey "$VMID" "$character"
|
qm sendkey $VMID "$character"
|
||||||
done
|
done
|
||||||
qm sendkey "$VMID" ret
|
qm sendkey $VMID ret
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "OpenWrt VM" --yesno "This will create a New OpenWrt VM. Proceed?" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "OpenWrt VM" --yesno "This will create a New OpenWrt VM. Proceed?" 10 58); then
|
||||||
:
|
:
|
||||||
@ -170,7 +170,7 @@ function msg_error() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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-3](\.[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..."
|
||||||
@ -243,7 +243,7 @@ function default_settings() {
|
|||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -260,10 +260,10 @@ function advanced_settings() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 openwrt --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 openwrt --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="openwrt"
|
HN="openwrt"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
@ -271,7 +271,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 1 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 1 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="1"
|
CORE_COUNT="1"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
@ -280,7 +280,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 256 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 256 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="256"
|
RAM_SIZE="256"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||||
@ -289,7 +289,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Bridge" 8 58 vmbr0 --title "WAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Bridge" 8 58 vmbr0 --title "WAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using WAN Bridge: ${BGN}$BRG${CL}"
|
echo -e "${DGN}Using WAN Bridge: ${BGN}$BRG${CL}"
|
||||||
@ -298,7 +298,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if LAN_BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Bridge" 8 58 vmbr0 --title "LAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if LAN_BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Bridge" 8 58 vmbr0 --title "LAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$LAN_BRG" ]; then
|
if [ -z $LAN_BRG ]; then
|
||||||
LAN_BRG="vmbr0"
|
LAN_BRG="vmbr0"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using LAN Bridge: ${BGN}$LAN_BRG${CL}"
|
echo -e "${DGN}Using LAN Bridge: ${BGN}$LAN_BRG${CL}"
|
||||||
@ -306,8 +306,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if LAN_IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a router IP" 8 58 "$LAN_IP_ADDR" --title "LAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if LAN_IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a router IP" 8 58 $LAN_IP_ADDR --title "LAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$LAN_IP_ADDR" ]; then
|
if [ -z $LAN_IP_ADDR ]; then
|
||||||
LAN_IP_ADDR="192.168.1.1"
|
LAN_IP_ADDR="192.168.1.1"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using LAN IP ADDRESS: ${BGN}$LAN_IP_ADDR${CL}"
|
echo -e "${DGN}Using LAN IP ADDRESS: ${BGN}$LAN_IP_ADDR${CL}"
|
||||||
@ -315,8 +315,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if LAN_NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a router netmask" 8 58 "$LAN_NETMASK" --title "LAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if LAN_NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a router netmask" 8 58 $LAN_NETMASK --title "LAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$LAN_NETMASK" ]; then
|
if [ -z $LAN_NETMASK ]; then
|
||||||
LAN_NETMASK="255.255.255.0"
|
LAN_NETMASK="255.255.255.0"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using LAN NETMASK: ${BGN}$LAN_NETMASK${CL}"
|
echo -e "${DGN}Using LAN NETMASK: ${BGN}$LAN_NETMASK${CL}"
|
||||||
@ -324,8 +324,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN MAC Address" 8 58 "$GEN_MAC" --title "WAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN MAC Address" 8 58 $GEN_MAC --title "WAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
else
|
else
|
||||||
MAC="$MAC1"
|
MAC="$MAC1"
|
||||||
@ -335,8 +335,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN MAC Address" 8 58 "$GEN_MAC_LAN" --title "LAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN MAC Address" 8 58 $GEN_MAC_LAN --title "LAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC2" ]; then
|
if [ -z $MAC2 ]; then
|
||||||
LAN_MAC="$GEN_MAC_LAN"
|
LAN_MAC="$GEN_MAC_LAN"
|
||||||
else
|
else
|
||||||
LAN_MAC="$MAC2"
|
LAN_MAC="$MAC2"
|
||||||
@ -347,7 +347,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Vlan (leave blank for default)" 8 58 --title "WAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Vlan (leave blank for default)" 8 58 --title "WAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
else
|
else
|
||||||
@ -359,7 +359,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Vlan" 8 58 999 --title "LAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Vlan" 8 58 999 --title "LAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN2" ]; then
|
if [ -z $VLAN2 ]; then
|
||||||
VLAN2="999"
|
VLAN2="999"
|
||||||
LAN_VLAN=",tag=$VLAN2"
|
LAN_VLAN=",tag=$VLAN2"
|
||||||
else
|
else
|
||||||
@ -371,7 +371,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
else
|
else
|
||||||
@ -418,9 +418,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -455,15 +455,15 @@ sleep 2
|
|||||||
msg_ok "${CL}${BL}${URL}${CL}"
|
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=$(basename "$URL")
|
FILE=$(basename $URL)
|
||||||
msg_ok "Downloaded ${CL}${BL}$FILE${CL}"
|
msg_ok "Downloaded ${CL}${BL}$FILE${CL}"
|
||||||
gunzip -f "$FILE" >/dev/null 2>/dev/null || true
|
gunzip -f $FILE >/dev/null 2>/dev/null || true
|
||||||
NEWFILE="${FILE%.*}"
|
NEWFILE="${FILE%.*}"
|
||||||
FILE="$NEWFILE"
|
FILE="$NEWFILE"
|
||||||
mv "$FILE" "${FILE%.*}"
|
mv $FILE ${FILE%.*}
|
||||||
qemu-img resize -f raw "${FILE%.*}" 512M >/dev/null 2>/dev/null
|
qemu-img resize -f raw ${FILE%.*} 512M >/dev/null 2>/dev/null
|
||||||
msg_ok "Extracted & Resized OpenWrt Disk Image ${CL}${BL}$FILE${CL}"
|
msg_ok "Extracted & Resized OpenWrt Disk Image ${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}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir)
|
nfs | dir)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -478,18 +478,18 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating OpenWrt VM"
|
msg_info "Creating OpenWrt VM"
|
||||||
qm create "$VMID" -cores "$CORE_COUNT" -memory "$RAM_SIZE" -name "$HN" \
|
qm create $VMID -cores $CORE_COUNT -memory $RAM_SIZE -name $HN \
|
||||||
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci --tablet 0
|
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci --tablet 0
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE%.*}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE%.*} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-efidisk0 "${DISK0_REF}",efitype=4m,size=4M \
|
-efidisk0 ${DISK0_REF},efitype=4m,size=4M \
|
||||||
-scsi0 "${DISK1_REF}",size=512M \
|
-scsi0 ${DISK1_REF},size=512M \
|
||||||
-boot order=scsi0 \
|
-boot order=scsi0 \
|
||||||
-tags community-script \
|
-tags community-script \
|
||||||
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
|
-description "<div align='center'><a href='https://Helper-Scripts.com'><img src='https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/images/logo-81x112.png'/></a>
|
||||||
@ -500,7 +500,7 @@ qm set "$VMID" \
|
|||||||
</div>" >/dev/null
|
</div>" >/dev/null
|
||||||
msg_ok "Created OpenWrt VM ${CL}${BL}(${HN})"
|
msg_ok "Created OpenWrt VM ${CL}${BL}(${HN})"
|
||||||
msg_info "OpenWrt is being started in order to configure the network interfaces."
|
msg_info "OpenWrt is being started in order to configure the network interfaces."
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
sleep 15
|
sleep 15
|
||||||
msg_ok "Network interfaces are being configured as OpenWrt initiates."
|
msg_ok "Network interfaces are being configured as OpenWrt initiates."
|
||||||
send_line_to_vm ""
|
send_line_to_vm ""
|
||||||
@ -517,17 +517,17 @@ send_line_to_vm "uci set network.lan.netmask=${LAN_NETMASK}"
|
|||||||
send_line_to_vm "uci commit"
|
send_line_to_vm "uci commit"
|
||||||
send_line_to_vm "halt"
|
send_line_to_vm "halt"
|
||||||
msg_ok "Network interfaces have been successfully configured."
|
msg_ok "Network interfaces have been successfully configured."
|
||||||
until qm status "$VMID" | grep -q "stopped"; do
|
until qm status $VMID | grep -q "stopped"; do
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
msg_info "Bridge interfaces are being added."
|
msg_info "Bridge interfaces are being added."
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-net0 virtio,bridge="${LAN_BRG}",macaddr="${LAN_MAC}""${LAN_VLAN}""${MTU}" \
|
-net0 virtio,bridge=${LAN_BRG},macaddr=${LAN_MAC}${LAN_VLAN}${MTU} \
|
||||||
-net1 virtio,bridge="${BRG}",macaddr="${MAC}""${VLAN}""${MTU}" >/dev/null 2>/dev/null
|
-net1 virtio,bridge=${BRG},macaddr=${MAC}${VLAN}${MTU} >/dev/null 2>/dev/null
|
||||||
msg_ok "Bridge interfaces have been successfully added."
|
msg_ok "Bridge interfaces have been successfully added."
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting OpenWrt VM"
|
msg_info "Starting OpenWrt VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started OpenWrt VM"
|
msg_ok "Started OpenWrt VM"
|
||||||
fi
|
fi
|
||||||
VLAN_FINISH=""
|
VLAN_FINISH=""
|
||||||
|
@ -55,20 +55,20 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
function send_line_to_vm() {
|
function send_line_to_vm() {
|
||||||
echo -e "${DGN}Sending line: ${YW}$1${CL}"
|
echo -e "${DGN}Sending line: ${YW}$1${CL}"
|
||||||
for ((i = 0; i < ${#1}; i++)); do
|
for ((i = 0; i < ${#1}; i++)); do
|
||||||
@ -134,13 +134,13 @@ function send_line_to_vm() {
|
|||||||
"(") character="shift-9" ;;
|
"(") character="shift-9" ;;
|
||||||
")") character="shift-0" ;;
|
")") character="shift-0" ;;
|
||||||
esac
|
esac
|
||||||
qm sendkey "$VMID" "$character"
|
qm sendkey $VMID "$character"
|
||||||
done
|
done
|
||||||
qm sendkey "$VMID" ret
|
qm sendkey $VMID ret
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "OPNsense VM" --yesno "This will create a New OPNsense VM. Proceed?" 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "OPNsense VM" --yesno "This will create a New OPNsense VM. Proceed?" 10 58); then
|
||||||
:
|
:
|
||||||
@ -164,7 +164,7 @@ function msg_error() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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-3]"; 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..."
|
||||||
@ -253,7 +253,7 @@ function advanced_settings() {
|
|||||||
local ip_regex='^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$'
|
local ip_regex='^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$'
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -273,7 +273,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${DGN}Using Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -290,7 +290,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64 (Default)" ON \
|
"0" "KVM64 (Default)" ON \
|
||||||
"1" "Host" OFF \
|
"1" "Host" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
echo -e "${DGN}Using CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -305,7 +305,7 @@ function advanced_settings() {
|
|||||||
"0" "None (Default)" ON \
|
"0" "None (Default)" ON \
|
||||||
"1" "Write Through" OFF \
|
"1" "Write Through" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE" = "1" ]; then
|
if [ $DISK_CACHE = "1" ]; then
|
||||||
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DGN}Using Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -317,10 +317,10 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 OPNsense --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 OPNsense --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="OPNsense"
|
HN="OPNsense"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
@ -328,7 +328,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 4 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 4 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
@ -337,7 +337,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 8192 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 8192 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="8192"
|
RAM_SIZE="8192"
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
|
||||||
@ -346,7 +346,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Bridge" 8 58 vmbr0 --title "LAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN Bridge" 8 58 vmbr0 --title "LAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
fi
|
fi
|
||||||
if ! grep -q "^iface ${BRG}" /etc/network/interfaces; then
|
if ! grep -q "^iface ${BRG}" /etc/network/interfaces; then
|
||||||
@ -358,8 +358,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN IP" 8 58 "$IP_ADDR" --title "LAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN IP" 8 58 $IP_ADDR --title "LAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$IP_ADDR" ]; then
|
if [ -z $IP_ADDR ]; then
|
||||||
echo -e "${DGN}Using DHCP AS LAN IP ADDRESS${CL}"
|
echo -e "${DGN}Using DHCP AS LAN IP ADDRESS${CL}"
|
||||||
else
|
else
|
||||||
if [[ -n "$IP_ADDR" && ! "$IP_ADDR" =~ $ip_regex ]]; then
|
if [[ -n "$IP_ADDR" && ! "$IP_ADDR" =~ $ip_regex ]]; then
|
||||||
@ -367,8 +367,8 @@ function advanced_settings() {
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using LAN IP ADDRESS: ${BGN}$IP_ADDR${CL}"
|
echo -e "${DGN}Using LAN IP ADDRESS: ${BGN}$IP_ADDR${CL}"
|
||||||
if LAN_GW=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN GATEWAY IP" 8 58 "$LAN_GW" --title "LAN GATEWAY IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if LAN_GW=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN GATEWAY IP" 8 58 $LAN_GW --title "LAN GATEWAY IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$LAN_GW" ]; then
|
if [ -z $LAN_GW ]; then
|
||||||
echo -e "${DGN}Gateway needs to be set if ip is not dhcp${CL}"
|
echo -e "${DGN}Gateway needs to be set if ip is not dhcp${CL}"
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
@ -378,8 +378,8 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using LAN GATEWAY ADDRESS: ${BGN}$LAN_GW${CL}"
|
echo -e "${DGN}Using LAN GATEWAY ADDRESS: ${BGN}$LAN_GW${CL}"
|
||||||
fi
|
fi
|
||||||
if NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN netmmask (24 for example)" 8 58 "$NETMASK" --title "LAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN netmmask (24 for example)" 8 58 $NETMASK --title "LAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$NETMASK" ]; then
|
if [ -z $NETMASK ]; then
|
||||||
echo -e "${DGN}Netmask needs to be set if ip is not dhcp${CL}"
|
echo -e "${DGN}Netmask needs to be set if ip is not dhcp${CL}"
|
||||||
fi
|
fi
|
||||||
if [[ -n "$NETMASK" && ! ("$NETMASK" =~ ^[0-9]+$ && "$NETMASK" -ge 1 && "$NETMASK" -le 32) ]]; then
|
if [[ -n "$NETMASK" && ! ("$NETMASK" =~ ^[0-9]+$ && "$NETMASK" -ge 1 && "$NETMASK" -le 32) ]]; then
|
||||||
@ -396,7 +396,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if WAN_BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Bridge" 8 58 vmbr1 --title "WAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if WAN_BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN Bridge" 8 58 vmbr1 --title "WAN BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$WAN_BRG" ]; then
|
if [ -z $WAN_BRG ]; then
|
||||||
WAN_BRG="vmbr1"
|
WAN_BRG="vmbr1"
|
||||||
fi
|
fi
|
||||||
if ! grep -q "^iface ${WAN_BRG}" /etc/network/interfaces; then
|
if ! grep -q "^iface ${WAN_BRG}" /etc/network/interfaces; then
|
||||||
@ -408,8 +408,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if WAN_IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN IP" 8 58 "$WAN_IP_ADDR" --title "WAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if WAN_IP_ADDR=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN IP" 8 58 $WAN_IP_ADDR --title "WAN IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$WAN_IP_ADDR" ]; then
|
if [ -z $WAN_IP_ADDR ]; then
|
||||||
echo -e "${DGN}Using DHCP AS WAN IP ADDRESS${CL}"
|
echo -e "${DGN}Using DHCP AS WAN IP ADDRESS${CL}"
|
||||||
else
|
else
|
||||||
if [[ -n "$WAN_IP_ADDR" && ! "$WAN_IP_ADDR" =~ $ip_regex ]]; then
|
if [[ -n "$WAN_IP_ADDR" && ! "$WAN_IP_ADDR" =~ $ip_regex ]]; then
|
||||||
@ -417,8 +417,8 @@ function advanced_settings() {
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using WAN IP ADDRESS: ${BGN}$WAN_IP_ADDR${CL}"
|
echo -e "${DGN}Using WAN IP ADDRESS: ${BGN}$WAN_IP_ADDR${CL}"
|
||||||
if WAN_GW=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN GATEWAY IP" 8 58 "$WAN_GW" --title "WAN GATEWAY IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if WAN_GW=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN GATEWAY IP" 8 58 $WAN_GW --title "WAN GATEWAY IP ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$WAN_GW" ]; then
|
if [ -z $WAN_GW ]; then
|
||||||
echo -e "${DGN}Gateway needs to be set if ip is not dhcp${CL}"
|
echo -e "${DGN}Gateway needs to be set if ip is not dhcp${CL}"
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
@ -430,8 +430,8 @@ function advanced_settings() {
|
|||||||
else
|
else
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
if WAN_NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN netmmask (24 for example)" 8 58 "$WAN_NETMASK" --title "WAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if WAN_NETMASK=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN netmmask (24 for example)" 8 58 $WAN_NETMASK --title "WAN NETMASK" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$WAN_NETMASK" ]; then
|
if [ -z $WAN_NETMASK ]; then
|
||||||
echo -e "${DGN}WAN Netmask needs to be set if ip is not dhcp${CL}"
|
echo -e "${DGN}WAN Netmask needs to be set if ip is not dhcp${CL}"
|
||||||
fi
|
fi
|
||||||
if [[ -n "$WAN_NETMASK" && ! ("$WAN_NETMASK" =~ ^[0-9]+$ && "$WAN_NETMASK" -ge 1 && "$WAN_NETMASK" -le 32) ]]; then
|
if [[ -n "$WAN_NETMASK" && ! ("$WAN_NETMASK" =~ ^[0-9]+$ && "$WAN_NETMASK" -ge 1 && "$WAN_NETMASK" -le 32) ]]; then
|
||||||
@ -446,8 +446,8 @@ function advanced_settings() {
|
|||||||
else
|
else
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN MAC Address" 8 58 "$GEN_MAC" --title "WAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a WAN MAC Address" 8 58 $GEN_MAC --title "WAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
else
|
else
|
||||||
MAC="$MAC1"
|
MAC="$MAC1"
|
||||||
@ -457,8 +457,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN MAC Address" 8 58 "$GEN_MAC_LAN" --title "LAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC2=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a LAN MAC Address" 8 58 $GEN_MAC_LAN --title "LAN MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC2" ]; then
|
if [ -z $MAC2 ]; then
|
||||||
WAN_MAC="$GEN_MAC_LAN"
|
WAN_MAC="$GEN_MAC_LAN"
|
||||||
else
|
else
|
||||||
WAN_MAC="$MAC2"
|
WAN_MAC="$MAC2"
|
||||||
@ -497,9 +497,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -533,7 +533,7 @@ 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}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir)
|
nfs | dir)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -551,22 +551,22 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating a OPNsense VM"
|
msg_info "Creating a OPNsense 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 proxmox-helper-scripts -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name $HN -tags proxmox-helper-scripts -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" ${FILE} "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
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 \
|
||||||
-tags community-script >/dev/null
|
-tags community-script >/dev/null
|
||||||
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'>
|
||||||
@ -600,18 +600,18 @@ 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 \
|
||||||
-net0 virtio,bridge="${BRG}",macaddr="${MAC}""${VLAN}""${MTU}" 2>/dev/null
|
-net0 virtio,bridge=${BRG},macaddr=${MAC}${VLAN}${MTU} 2>/dev/null
|
||||||
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."
|
||||||
|
@ -76,19 +76,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 22.04 VM" --yesno "This will create a New Ubuntu 22.04 VM. Proceed?" 10 58; then
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 22.04 VM" --yesno "This will create a New Ubuntu 22.04 VM. Proceed?" 10 58; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@ -121,7 +121,7 @@ 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-3](\.[0-9]+)*"; then
|
||||||
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
msg_error "${CROSS}${RD}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..."
|
||||||
@ -194,7 +194,7 @@ function default_settings() {
|
|||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -214,7 +214,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -246,7 +246,7 @@ function advanced_settings() {
|
|||||||
"0" "None (Default)" ON \
|
"0" "None (Default)" ON \
|
||||||
"1" "Write Through" OFF \
|
"1" "Write Through" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE" = "1" ]; then
|
if [ $DISK_CACHE = "1" ]; then
|
||||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -258,11 +258,11 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="ubuntu"
|
HN="ubuntu"
|
||||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -273,7 +273,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64 (Default)" ON \
|
"0" "KVM64 (Default)" ON \
|
||||||
"1" "Host" OFF \
|
"1" "Host" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}"
|
echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -285,7 +285,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
else
|
else
|
||||||
@ -296,7 +296,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="2048"
|
RAM_SIZE="2048"
|
||||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
||||||
else
|
else
|
||||||
@ -307,7 +307,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
||||||
else
|
else
|
||||||
@ -317,8 +317,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
||||||
else
|
else
|
||||||
@ -330,7 +330,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}"
|
echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}"
|
||||||
@ -343,7 +343,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
@ -393,9 +393,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -428,7 +428,7 @@ 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}"
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir | cifs)
|
nfs | dir | cifs)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -446,19 +446,19 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}"${DISK_EXT:-}
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}"${!disk}
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating a Ubuntu 22.04 VM"
|
msg_info "Creating a Ubuntu 22.04 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 -net0 virtio,bridge="$BRG",macaddr="$MAC"$VLAN"$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-efidisk0 "${DISK0_REF}"${FORMAT} \
|
-efidisk0 ${DISK0_REF}${FORMAT} \
|
||||||
-scsi0 "${DISK1_REF}",${DISK_CACHE}${THIN}size="${DISK_SIZE}" \
|
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \
|
||||||
-ide2 "${STORAGE}":cloudinit \
|
-ide2 ${STORAGE}:cloudinit \
|
||||||
-boot order=scsi0 \
|
-boot order=scsi0 \
|
||||||
-serial0 socket >/dev/null
|
-serial0 socket >/dev/null
|
||||||
DESCRIPTION=$(
|
DESCRIPTION=$(
|
||||||
@ -494,16 +494,16 @@ EOF
|
|||||||
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
||||||
if [ -n "$DISK_SIZE" ]; then
|
if [ -n "$DISK_SIZE" ]; then
|
||||||
msg_info "Resizing disk to $DISK_SIZE GB"
|
msg_info "Resizing disk to $DISK_SIZE GB"
|
||||||
qm resize "$VMID" scsi0 "${DISK_SIZE}" >/dev/null
|
qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null
|
||||||
else
|
else
|
||||||
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
|
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
|
||||||
qm resize "$VMID" scsi0 "${DEFAULT_DISK_SIZE}" >/dev/null
|
qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_ok "Created a Ubuntu 22.04 VM ${CL}${BL}(${HN})"
|
msg_ok "Created a Ubuntu 22.04 VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Ubuntu 22.04 VM"
|
msg_info "Starting Ubuntu 22.04 VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started Ubuntu 22.04 VM"
|
msg_ok "Started Ubuntu 22.04 VM"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
@ -446,13 +446,13 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}"${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}"${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating a Ubuntu 24.04 VM"
|
msg_info "Creating a Ubuntu 24.04 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 -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name "$HN" -tags community-script -net0 virtio,bridge="$BRG",macaddr="$MAC"$VLAN"$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set "$VMID" \
|
||||||
|
@ -76,19 +76,19 @@ function error_handler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cleanup_vmid() {
|
function cleanup_vmid() {
|
||||||
if qm status "$VMID" &>/dev/null; then
|
if qm status $VMID &>/dev/null; then
|
||||||
qm stop "$VMID" &>/dev/null
|
qm stop $VMID &>/dev/null
|
||||||
qm destroy "$VMID" &>/dev/null
|
qm destroy $VMID &>/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
rm -rf "$TEMP_DIR"
|
rm -rf $TEMP_DIR
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMP_DIR=$(mktemp -d)
|
TEMP_DIR=$(mktemp -d)
|
||||||
pushd "$TEMP_DIR" >/dev/null
|
pushd $TEMP_DIR >/dev/null
|
||||||
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 24.10 VM" --yesno "This will create a New Ubuntu 24.10 VM. Proceed?" 10 58; then
|
if whiptail --backtitle "Proxmox VE Helper Scripts" --title "Ubuntu 24.10 VM" --yesno "This will create a New Ubuntu 24.10 VM. Proceed?" 10 58; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
@ -121,7 +121,7 @@ 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-3](\.[0-9]+)*"; then
|
||||||
msg_error "${CROSS}${RD}This version of Proxmox Virtual Environment is not supported"
|
msg_error "${CROSS}${RD}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..."
|
||||||
@ -194,7 +194,7 @@ function default_settings() {
|
|||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
METHOD="advanced"
|
METHOD="advanced"
|
||||||
while true; do
|
while true; do
|
||||||
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 "$NEXTID" --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VMID=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Virtual Machine ID" 8 58 $NEXTID --title "VIRTUAL MACHINE ID" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VMID" ]; then
|
if [ -z "$VMID" ]; then
|
||||||
VMID="$NEXTID"
|
VMID="$NEXTID"
|
||||||
fi
|
fi
|
||||||
@ -214,7 +214,7 @@ function advanced_settings() {
|
|||||||
"i440fx" "Machine i440fx" ON \
|
"i440fx" "Machine i440fx" ON \
|
||||||
"q35" "Machine q35" OFF \
|
"q35" "Machine q35" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$MACH" = q35 ]; then
|
if [ $MACH = q35 ]; then
|
||||||
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}"
|
echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}$MACH${CL}"
|
||||||
FORMAT=""
|
FORMAT=""
|
||||||
MACHINE=" -machine q35"
|
MACHINE=" -machine q35"
|
||||||
@ -246,7 +246,7 @@ function advanced_settings() {
|
|||||||
"0" "None (Default)" ON \
|
"0" "None (Default)" ON \
|
||||||
"1" "Write Through" OFF \
|
"1" "Write Through" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$DISK_CACHE" = "1" ]; then
|
if [ $DISK_CACHE = "1" ]; then
|
||||||
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}"
|
echo -e "${DISKSIZE}${BOLD}${DGN}Disk Cache: ${BGN}Write Through${CL}"
|
||||||
DISK_CACHE="cache=writethrough,"
|
DISK_CACHE="cache=writethrough,"
|
||||||
else
|
else
|
||||||
@ -258,11 +258,11 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VM_NAME=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Hostname" 8 58 ubuntu --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VM_NAME" ]; then
|
if [ -z $VM_NAME ]; then
|
||||||
HN="ubuntu"
|
HN="ubuntu"
|
||||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||||
else
|
else
|
||||||
HN=$(echo "${VM_NAME,,}" | tr -d ' ')
|
HN=$(echo ${VM_NAME,,} | tr -d ' ')
|
||||||
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
echo -e "${HOSTNAME}${BOLD}${DGN}Hostname: ${BGN}$HN${CL}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -273,7 +273,7 @@ function advanced_settings() {
|
|||||||
"0" "KVM64 (Default)" ON \
|
"0" "KVM64 (Default)" ON \
|
||||||
"1" "Host" OFF \
|
"1" "Host" OFF \
|
||||||
3>&1 1>&2 2>&3); then
|
3>&1 1>&2 2>&3); then
|
||||||
if [ "$CPU_TYPE1" = "1" ]; then
|
if [ $CPU_TYPE1 = "1" ]; then
|
||||||
echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}"
|
echo -e "${OS}${BOLD}${DGN}CPU Model: ${BGN}Host${CL}"
|
||||||
CPU_TYPE=" -cpu host"
|
CPU_TYPE=" -cpu host"
|
||||||
else
|
else
|
||||||
@ -285,7 +285,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if CORE_COUNT=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate CPU Cores" 8 58 2 --title "CORE COUNT" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$CORE_COUNT" ]; then
|
if [ -z $CORE_COUNT ]; then
|
||||||
CORE_COUNT="2"
|
CORE_COUNT="2"
|
||||||
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
echo -e "${CPUCORE}${BOLD}${DGN}CPU Cores: ${BGN}$CORE_COUNT${CL}"
|
||||||
else
|
else
|
||||||
@ -296,7 +296,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if RAM_SIZE=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Allocate RAM in MiB" 8 58 2048 --title "RAM" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$RAM_SIZE" ]; then
|
if [ -z $RAM_SIZE ]; then
|
||||||
RAM_SIZE="2048"
|
RAM_SIZE="2048"
|
||||||
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
echo -e "${RAMSIZE}${BOLD}${DGN}RAM Size: ${BGN}$RAM_SIZE${CL}"
|
||||||
else
|
else
|
||||||
@ -307,7 +307,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if BRG=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Bridge" 8 58 vmbr0 --title "BRIDGE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$BRG" ]; then
|
if [ -z $BRG ]; then
|
||||||
BRG="vmbr0"
|
BRG="vmbr0"
|
||||||
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
echo -e "${BRIDGE}${BOLD}${DGN}Bridge: ${BGN}$BRG${CL}"
|
||||||
else
|
else
|
||||||
@ -317,8 +317,8 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 "$GEN_MAC" --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MAC1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a MAC Address" 8 58 $GEN_MAC --title "MAC ADDRESS" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MAC1" ]; then
|
if [ -z $MAC1 ]; then
|
||||||
MAC="$GEN_MAC"
|
MAC="$GEN_MAC"
|
||||||
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
echo -e "${MACADDRESS}${BOLD}${DGN}MAC Address: ${BGN}$MAC${CL}"
|
||||||
else
|
else
|
||||||
@ -330,7 +330,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if VLAN1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$VLAN1" ]; then
|
if [ -z $VLAN1 ]; then
|
||||||
VLAN1="Default"
|
VLAN1="Default"
|
||||||
VLAN=""
|
VLAN=""
|
||||||
echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}"
|
echo -e "${VLANTAG}${BOLD}${DGN}VLAN: ${BGN}$VLAN1${CL}"
|
||||||
@ -343,7 +343,7 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
if MTU1=$(whiptail --backtitle "Proxmox VE Helper Scripts" --inputbox "Set Interface MTU Size (leave blank for default)" 8 58 --title "MTU SIZE" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then
|
||||||
if [ -z "$MTU1" ]; then
|
if [ -z $MTU1 ]; then
|
||||||
MTU1="Default"
|
MTU1="Default"
|
||||||
MTU=""
|
MTU=""
|
||||||
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
echo -e "${DEFAULT}${BOLD}${DGN}Interface MTU Size: ${BGN}$MTU1${CL}"
|
||||||
@ -393,9 +393,9 @@ post_to_api_vm
|
|||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
TAG=$(echo "$line" | awk '{print $1}')
|
TAG=$(echo $line | awk '{print $1}')
|
||||||
TYPE=$(echo "$line" | awk '{printf "%-10s", $2}')
|
TYPE=$(echo $line | awk '{printf "%-10s", $2}')
|
||||||
FREE=$(echo "$line" | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}')
|
||||||
ITEM=" Type: $TYPE Free: $FREE "
|
ITEM=" Type: $TYPE Free: $FREE "
|
||||||
OFFSET=2
|
OFFSET=2
|
||||||
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
if [[ $((${#ITEM} + $OFFSET)) -gt ${MSG_MAX_LENGTH:-} ]]; then
|
||||||
@ -428,7 +428,7 @@ 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}"
|
||||||
|
|
||||||
STORAGE_TYPE=$(pvesm status -storage "$STORAGE" | awk 'NR>1 {print $2}')
|
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
|
||||||
case $STORAGE_TYPE in
|
case $STORAGE_TYPE in
|
||||||
nfs | dir | cifs)
|
nfs | dir | cifs)
|
||||||
DISK_EXT=".qcow2"
|
DISK_EXT=".qcow2"
|
||||||
@ -446,19 +446,19 @@ btrfs)
|
|||||||
esac
|
esac
|
||||||
for i in {0,1}; do
|
for i in {0,1}; do
|
||||||
disk="DISK$i"
|
disk="DISK$i"
|
||||||
eval DISK"${i}"=vm-"${VMID}"-disk-"${i}""${DISK_EXT:-}"
|
eval DISK${i}=vm-${VMID}-disk-${i}${DISK_EXT:-}
|
||||||
eval DISK"${i}"_REF="${STORAGE}":"${DISK_REF:-}""${!disk}"
|
eval DISK${i}_REF=${STORAGE}:${DISK_REF:-}${!disk}
|
||||||
done
|
done
|
||||||
|
|
||||||
msg_info "Creating a Ubuntu 24.10 VM"
|
msg_info "Creating a Ubuntu 24.10 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 -net0 virtio,bridge="$BRG",macaddr="$MAC""$VLAN""$MTU" -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
-name $HN -tags community-script -net0 virtio,bridge=$BRG,macaddr=$MAC$VLAN$MTU -onboot 1 -ostype l26 -scsihw virtio-scsi-pci
|
||||||
pvesm alloc "$STORAGE" "$VMID" "$DISK0" 4M 1>&/dev/null
|
pvesm alloc $STORAGE $VMID $DISK0 4M 1>&/dev/null
|
||||||
qm importdisk "$VMID" "${FILE}" "$STORAGE" "${DISK_IMPORT:-}" 1>&/dev/null
|
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
|
||||||
qm set "$VMID" \
|
qm set $VMID \
|
||||||
-efidisk0 "${DISK0_REF}"${FORMAT} \
|
-efidisk0 ${DISK0_REF}${FORMAT} \
|
||||||
-scsi0 "${DISK1_REF}",${DISK_CACHE}${THIN}size="${DISK_SIZE}" \
|
-scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=${DISK_SIZE} \
|
||||||
-ide2 "${STORAGE}":cloudinit \
|
-ide2 ${STORAGE}:cloudinit \
|
||||||
-boot order=scsi0 \
|
-boot order=scsi0 \
|
||||||
-serial0 socket >/dev/null
|
-serial0 socket >/dev/null
|
||||||
DESCRIPTION=$(
|
DESCRIPTION=$(
|
||||||
@ -494,16 +494,16 @@ EOF
|
|||||||
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
qm set "$VMID" -description "$DESCRIPTION" >/dev/null
|
||||||
if [ -n "$DISK_SIZE" ]; then
|
if [ -n "$DISK_SIZE" ]; then
|
||||||
msg_info "Resizing disk to $DISK_SIZE GB"
|
msg_info "Resizing disk to $DISK_SIZE GB"
|
||||||
qm resize "$VMID" scsi0 "${DISK_SIZE}" >/dev/null
|
qm resize $VMID scsi0 ${DISK_SIZE} >/dev/null
|
||||||
else
|
else
|
||||||
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
|
msg_info "Using default disk size of $DEFAULT_DISK_SIZE GB"
|
||||||
qm resize "$VMID" scsi0 "${DEFAULT_DISK_SIZE}" >/dev/null
|
qm resize $VMID scsi0 ${DEFAULT_DISK_SIZE} >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg_ok "Created a Ubuntu 24.10 VM ${CL}${BL}(${HN})"
|
msg_ok "Created a Ubuntu 24.10 VM ${CL}${BL}(${HN})"
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting Ubuntu 24.10 VM"
|
msg_info "Starting Ubuntu 24.10 VM"
|
||||||
qm start "$VMID"
|
qm start $VMID
|
||||||
msg_ok "Started Ubuntu 24.10 VM"
|
msg_ok "Started Ubuntu 24.10 VM"
|
||||||
fi
|
fi
|
||||||
post_update_to_api "done" "none"
|
post_update_to_api "done" "none"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user