mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	[API] Add API to vms (#2021)
* add API to debian-vm.sh * [API] Add API calls to VMs * [API] Add API calls to VMs * [API] Add API calls to VMs * [API] Add API calls to VMs * [API] Add API calls to VMs * debian-vm.sh Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> * updates --------- Co-authored-by: bvdberg01 <74251551+bvdberg01@users.noreply.github.com> Co-authored-by: Rögl-Brunner Michel <Michel.Roegl-brunner@htl-braunau.int>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							b9094e306e
						
					
				
				
					commit
					a481e89cad
				
			@@ -4,6 +4,9 @@
 | 
			
		||||
# Author: MickLesk (CanbiZ)
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -17,6 +20,12 @@ EOF
 | 
			
		||||
}
 | 
			
		||||
header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="arch-linux-vm"
 | 
			
		||||
var_os="arch-linux"
 | 
			
		||||
var_version=" "
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
 | 
			
		||||
@@ -56,10 +65,13 @@ THIN="discard=on,ssd=1,"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "${commad}"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -111,7 +123,7 @@ function check_root() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function pve_check() {
 | 
			
		||||
  if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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"
 | 
			
		||||
    echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
 | 
			
		||||
    echo -e "Exiting..."
 | 
			
		||||
@@ -164,6 +176,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}"
 | 
			
		||||
@@ -181,6 +194,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -377,6 +391,7 @@ arch_check
 | 
			
		||||
pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
@@ -493,5 +508,6 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Arch Linux VM"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@
 | 
			
		||||
# Author: MickLesk (CanbiZ)
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -19,6 +21,11 @@ header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="debian12vm"
 | 
			
		||||
var_os="debian"
 | 
			
		||||
var_version="12"
 | 
			
		||||
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")
 | 
			
		||||
@@ -56,11 +63,14 @@ THIN="discard=on,ssd=1,"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  post_update_to_api "failed" "${command}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
}
 | 
			
		||||
@@ -74,6 +84,7 @@ function cleanup_vmid() {
 | 
			
		||||
 | 
			
		||||
function cleanup() {
 | 
			
		||||
  popd >/dev/null
 | 
			
		||||
  post_update_to_api "done" "none"
 | 
			
		||||
  rm -rf $TEMP_DIR
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -111,7 +122,7 @@ function check_root() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function pve_check() {
 | 
			
		||||
  if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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"
 | 
			
		||||
    echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
 | 
			
		||||
    echo -e "Exiting..."
 | 
			
		||||
@@ -164,6 +175,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}"
 | 
			
		||||
@@ -181,6 +193,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -378,6 +391,8 @@ pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
  TAG=$(echo $line | awk '{print $1}')
 | 
			
		||||
@@ -439,7 +454,7 @@ done
 | 
			
		||||
 | 
			
		||||
msg_info "Creating a Debian 12 VM"
 | 
			
		||||
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 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
 | 
			
		||||
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
 | 
			
		||||
qm set $VMID \
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@
 | 
			
		||||
# Author: thost96 (thost96)
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -19,6 +21,12 @@ header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="debian12vm"
 | 
			
		||||
var_os="debian"
 | 
			
		||||
var_version="12"
 | 
			
		||||
DISK_SIZE="8G"
 | 
			
		||||
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")
 | 
			
		||||
@@ -36,10 +44,13 @@ THIN="discard=on,ssd=1,"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "${command}"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -91,7 +102,7 @@ function check_root() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function pve_check() {
 | 
			
		||||
  if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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"
 | 
			
		||||
    echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
 | 
			
		||||
    echo -e "Exiting..."
 | 
			
		||||
@@ -144,6 +155,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}"
 | 
			
		||||
@@ -160,6 +172,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -341,6 +354,7 @@ arch_check
 | 
			
		||||
pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
@@ -417,7 +431,7 @@ msg_ok "Added Docker and Docker Compose Plugin to Debian 12 Qcow2 Disk Image suc
 | 
			
		||||
 | 
			
		||||
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 \
 | 
			
		||||
  -name $HN -tags proxmox-helper-scripts,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
 | 
			
		||||
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
 | 
			
		||||
qm set $VMID \
 | 
			
		||||
@@ -465,4 +479,5 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Docker VM"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,9 @@
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -21,6 +24,13 @@ echo -e "\n Loading..."
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
VERSIONS=(stable beta dev)
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="homeassistant-os"
 | 
			
		||||
var_os="homeassistant"
 | 
			
		||||
DISK_SIZE="32G"
 | 
			
		||||
#
 | 
			
		||||
for version in "${VERSIONS[@]}"; do
 | 
			
		||||
  eval "$version=$(curl -s https://raw.githubusercontent.com/home-assistant/version/master/$version.json | grep "ova" | cut -d '"' -f 4)"
 | 
			
		||||
done
 | 
			
		||||
@@ -41,6 +51,8 @@ SPINNER_PID=""
 | 
			
		||||
set -Eeuo pipefail
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  if [ -n "$SPINNER_PID" ] && ps -p $SPINNER_PID > /dev/null; then kill $SPINNER_PID > /dev/null; fi
 | 
			
		||||
@@ -48,6 +60,7 @@ function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "${command}"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -167,6 +180,8 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  var_version="${stable}"
 | 
			
		||||
  echo -e "${DGN}Using HAOS Version: ${BGN}${BRANCH}${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
@@ -184,11 +199,13 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  if BRANCH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
 | 
			
		||||
    "$stable" "Stable  " ON \
 | 
			
		||||
    "$beta" "Beta  " OFF \
 | 
			
		||||
    "$dev" "Dev  " OFF \
 | 
			
		||||
    3>&1 1>&2 2>&3); then
 | 
			
		||||
    var_version="${BRANCH}"
 | 
			
		||||
    echo -e "${DGN}Using HAOS Version: ${BGN}$BRANCH${CL}"
 | 
			
		||||
  else
 | 
			
		||||
    exit-script
 | 
			
		||||
@@ -376,6 +393,9 @@ pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
  TAG=$(echo $line | awk '{print $1}')
 | 
			
		||||
@@ -463,4 +483,7 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Home Assistant OS VM"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,9 @@
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
    __  ____ __              __  _ __      ____              __            ____  _____    ________  ______
 | 
			
		||||
@@ -20,6 +23,14 @@ header_info
 | 
			
		||||
echo -e "Loading..."
 | 
			
		||||
GEN_MAC=$(echo '00 60 2f'$(od -An -N3 -t xC /dev/urandom) | sed -e 's/ /:/g' | tr '[:lower:]' '[:upper:]')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="mikrotik-router-os"
 | 
			
		||||
var_os="mikrotik"
 | 
			
		||||
var_version=" "
 | 
			
		||||
DISK_SIZE="1G"
 | 
			
		||||
#
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")
 | 
			
		||||
HA=$(echo "\033[1;34m")
 | 
			
		||||
@@ -39,6 +50,8 @@ shopt -s expand_aliases
 | 
			
		||||
alias die='EXIT=$? LINE=$LINENO error_exit'
 | 
			
		||||
trap die ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_exit() {
 | 
			
		||||
  trap - ERR
 | 
			
		||||
  local reason="Unknown failure occurred."
 | 
			
		||||
@@ -86,6 +99,7 @@ function msg_ok() {
 | 
			
		||||
  echo -e "${BFR} ${CM} ${GN}${msg}${CL}"
 | 
			
		||||
}
 | 
			
		||||
function default_settings() {
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
 | 
			
		||||
  VMID=$NEXTID
 | 
			
		||||
  echo -e "${DGN}Using Hostname: ${BGN}mikrotik-routeros-chr${CL}"
 | 
			
		||||
@@ -107,6 +121,7 @@ function default_settings() {
 | 
			
		||||
  echo -e "${BL}Creating a Mikrotik RouterOS CHR VM using the above default settings${CL}"
 | 
			
		||||
}
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  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)
 | 
			
		||||
  exitstatus=$?
 | 
			
		||||
  if [ $exitstatus = 0 ]; then
 | 
			
		||||
@@ -203,6 +218,8 @@ function start_script() {
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
start_script
 | 
			
		||||
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
  TAG=$(echo $line | awk '{print $1}')
 | 
			
		||||
@@ -287,4 +304,5 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Mikrotik RouterOS CHR VM"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -17,6 +19,14 @@ EOF
 | 
			
		||||
}
 | 
			
		||||
header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="turnkey-nextcloud"
 | 
			
		||||
var_os="turnkey-nextcloud"
 | 
			
		||||
var_version=" "
 | 
			
		||||
DISK_SIZE="12G"
 | 
			
		||||
#
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
NAME="TurnKey Nexcloud VM"
 | 
			
		||||
@@ -36,10 +46,13 @@ THIN="discard=on,ssd=1"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "${command}"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -142,6 +155,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="no"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}"
 | 
			
		||||
@@ -158,6 +172,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -340,6 +355,8 @@ pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
  TAG=$(echo $line | awk '{print $1}')
 | 
			
		||||
@@ -422,4 +439,5 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started $NAME"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,8 @@
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
# Based on work from https://i12bretro.github.io/tutorials/0405.html
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -21,6 +23,14 @@ EOF
 | 
			
		||||
}
 | 
			
		||||
header_info
 | 
			
		||||
echo -e "Loading..."
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="openwrt-vm"
 | 
			
		||||
var_os="openwrt"
 | 
			
		||||
var_version=" "
 | 
			
		||||
DISK_SIZE="0.5G"
 | 
			
		||||
#
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
GEN_MAC_LAN=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
@@ -39,10 +49,13 @@ CROSS="${RD}✗${CL}"
 | 
			
		||||
set -Eeo pipefail
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "$command"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -209,6 +222,7 @@ function default_settings() {
 | 
			
		||||
  LAN_VLAN=",tag=999"
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Hostname: ${BGN}${HN}${CL}"
 | 
			
		||||
  echo -e "${DGN}Allocated Cores: ${BGN}${CORE_COUNT}${CL}"
 | 
			
		||||
@@ -227,6 +241,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -399,6 +414,7 @@ arch_check
 | 
			
		||||
pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
@@ -518,4 +534,5 @@ VLAN_FINISH=""
 | 
			
		||||
if [ "$VLAN" == "" ] && [ "$VLAN2" != "999" ]; then
 | 
			
		||||
  VLAN_FINISH=" Please remember to adjust the VLAN tags to suit your network."
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n${VLAN_FINISH}"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -17,6 +19,14 @@ EOF
 | 
			
		||||
}
 | 
			
		||||
header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="turnkey-owncloud-vm"
 | 
			
		||||
var_os="owncloud"
 | 
			
		||||
var_version="12"
 | 
			
		||||
DISK_SIZE="12G"
 | 
			
		||||
#
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
NAME="TurnKey ownCloud VM"
 | 
			
		||||
@@ -36,10 +46,13 @@ THIN="discard=on,ssd=1"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "$command"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -142,6 +155,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="no"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DGN}Using Disk Cache: ${BGN}None${CL}"
 | 
			
		||||
@@ -158,6 +172,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -340,6 +355,8 @@ pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
  TAG=$(echo $line | awk '{print $1}')
 | 
			
		||||
@@ -422,4 +439,5 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started $NAME"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
                                      ____  _ __  ___                                        
 | 
			
		||||
@@ -22,6 +24,14 @@ EOF
 | 
			
		||||
clear
 | 
			
		||||
header_info
 | 
			
		||||
echo -e "Loading..."
 | 
			
		||||
#API VARIABLES
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="pimox-haos-vm"
 | 
			
		||||
var_os="pimox-haos"
 | 
			
		||||
var_version=" "
 | 
			
		||||
DISK_SIZE="32G"
 | 
			
		||||
#
 | 
			
		||||
GEN_MAC=$(echo '00 60 2f'$(od -An -N3 -t xC /dev/urandom) | sed -e 's/ /:/g' | tr '[:lower:]' '[:upper:]')
 | 
			
		||||
USEDID=$(pvesh get /cluster/resources --type vm --output-format yaml | egrep -i 'vmid' | awk '{print substr($2, 1, length($2)-0) }')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
@@ -48,11 +58,14 @@ shopt -s expand_aliases
 | 
			
		||||
alias die='EXIT=$? LINE=$LINENO error_exit'
 | 
			
		||||
trap die ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_exit() {
 | 
			
		||||
  trap - ERR
 | 
			
		||||
  local reason="Unknown failure occurred."
 | 
			
		||||
  local msg="${1:-$reason}"
 | 
			
		||||
  local flag="${RD}‼ ERROR ${CL}$EXIT@$LINE"
 | 
			
		||||
  post_update_to_api "failed" "unknown"
 | 
			
		||||
  echo -e "$flag $msg" 1>&2
 | 
			
		||||
  [ ! -z ${VMID-} ] && cleanup_vmid
 | 
			
		||||
  exit $EXIT
 | 
			
		||||
@@ -106,6 +119,7 @@ function msg_error() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function default_settings() {
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${DGN}Using HAOS Version: ${BGN}${STABLE}${CL}"
 | 
			
		||||
  BRANCH=${STABLE}
 | 
			
		||||
  echo -e "${DGN}Using Virtual Machine ID: ${BGN}$NEXTID${CL}"
 | 
			
		||||
@@ -129,6 +143,7 @@ function default_settings() {
 | 
			
		||||
  echo -e "${BL}Creating a HAOS VM using the above default settings${CL}"
 | 
			
		||||
}
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  BRANCH=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "HAOS VERSION" --radiolist "Choose Version" --cancel-button Exit-Script 10 58 3 \
 | 
			
		||||
    "$STABLE" "Stable" ON \
 | 
			
		||||
    "$BETA" "Beta" OFF \
 | 
			
		||||
@@ -250,6 +265,7 @@ function START_SCRIPT() {
 | 
			
		||||
}
 | 
			
		||||
ARCH_CHECK
 | 
			
		||||
START_SCRIPT
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
while read -r line; do
 | 
			
		||||
  TAG=$(echo $line | awk '{print $1}')
 | 
			
		||||
  TYPE=$(echo $line | awk '{printf "%-10s", $2}')
 | 
			
		||||
@@ -322,4 +338,5 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Home Assistant OS VM"
 | 
			
		||||
fi
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@
 | 
			
		||||
# Author: MickLesk (CanbiZ)
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -19,6 +21,11 @@ header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="ubuntu-2204-vm"
 | 
			
		||||
var_os="ubuntu"
 | 
			
		||||
var_version="2204"
 | 
			
		||||
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")
 | 
			
		||||
@@ -56,10 +63,13 @@ THIN="discard=on,ssd=1,"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "$command"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -111,7 +121,7 @@ function check_root() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function pve_check() {
 | 
			
		||||
  if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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"
 | 
			
		||||
    echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
 | 
			
		||||
    echo -e "Exiting..."
 | 
			
		||||
@@ -164,6 +174,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}"
 | 
			
		||||
@@ -181,6 +192,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -377,6 +389,7 @@ arch_check
 | 
			
		||||
pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
@@ -439,7 +452,7 @@ done
 | 
			
		||||
 | 
			
		||||
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 \
 | 
			
		||||
  -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 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
 | 
			
		||||
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
 | 
			
		||||
qm set $VMID \
 | 
			
		||||
@@ -493,7 +506,7 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Ubuntu 22.04 VM"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
echo -e "Setup Cloud-Init before starting \n
 | 
			
		||||
More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n"
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,8 @@
 | 
			
		||||
# License: MIT
 | 
			
		||||
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -20,6 +22,11 @@ header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="ubuntu-2404-vm"
 | 
			
		||||
var_os="ubuntu"
 | 
			
		||||
var_version="2404"
 | 
			
		||||
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")		   
 | 
			
		||||
@@ -57,10 +64,13 @@ THIN="discard=on,ssd=1,"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "$command"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -112,7 +122,7 @@ function check_root() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function pve_check() {
 | 
			
		||||
  if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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"
 | 
			
		||||
    echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
 | 
			
		||||
    echo -e "Exiting..."
 | 
			
		||||
@@ -165,6 +175,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}"
 | 
			
		||||
@@ -182,6 +193,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -377,6 +389,7 @@ arch_check
 | 
			
		||||
pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
@@ -439,7 +452,7 @@ done
 | 
			
		||||
 | 
			
		||||
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 \
 | 
			
		||||
  -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 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
 | 
			
		||||
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
 | 
			
		||||
qm set $VMID \
 | 
			
		||||
@@ -493,7 +506,7 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Ubuntu 24.04 VM"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
post_update_to_api "done" "none"
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
echo -e "Setup Cloud-Init before starting \n
 | 
			
		||||
More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n"
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@
 | 
			
		||||
# Author: MickLesk (CanbiZ)
 | 
			
		||||
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
			
		||||
 | 
			
		||||
source /dev/stdin <<< $(wget -qLO - https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/api.func)
 | 
			
		||||
 | 
			
		||||
function header_info {
 | 
			
		||||
  clear
 | 
			
		||||
  cat <<"EOF"
 | 
			
		||||
@@ -19,6 +21,11 @@ header_info
 | 
			
		||||
echo -e "\n Loading..."
 | 
			
		||||
GEN_MAC=02:$(openssl rand -hex 5 | awk '{print toupper($0)}' | sed 's/\(..\)/\1:/g; s/.$//')
 | 
			
		||||
NEXTID=$(pvesh get /cluster/nextid)
 | 
			
		||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
 | 
			
		||||
METHOD=""
 | 
			
		||||
NSAPP="ubuntu-2410-vm"
 | 
			
		||||
var_os="ubuntu"
 | 
			
		||||
var_version="2410"
 | 
			
		||||
 | 
			
		||||
YW=$(echo "\033[33m")
 | 
			
		||||
BL=$(echo "\033[36m")
 | 
			
		||||
@@ -56,10 +63,13 @@ THIN="discard=on,ssd=1,"
 | 
			
		||||
set -e
 | 
			
		||||
trap 'error_handler $LINENO "$BASH_COMMAND"' ERR
 | 
			
		||||
trap cleanup EXIT
 | 
			
		||||
trap 'post_update_to_api "failed" "INTERRUPTED"' SIGINT 
 | 
			
		||||
trap 'post_update_to_api "failed" "TERMINATED"' SIGTERM
 | 
			
		||||
function error_handler() {
 | 
			
		||||
  local exit_code="$?"
 | 
			
		||||
  local line_number="$1"
 | 
			
		||||
  local command="$2"
 | 
			
		||||
  post_update_to_api "failed" "$command"
 | 
			
		||||
  local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}"
 | 
			
		||||
  echo -e "\n$error_message\n"
 | 
			
		||||
  cleanup_vmid
 | 
			
		||||
@@ -111,7 +121,7 @@ function check_root() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function pve_check() {
 | 
			
		||||
  if ! pveversion | grep -Eq "pve-manager/8\.[1-3](\.[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"
 | 
			
		||||
    echo -e "Requires Proxmox Virtual Environment Version 8.1 or later."
 | 
			
		||||
    echo -e "Exiting..."
 | 
			
		||||
@@ -164,6 +174,7 @@ function default_settings() {
 | 
			
		||||
  VLAN=""
 | 
			
		||||
  MTU=""
 | 
			
		||||
  START_VM="yes"
 | 
			
		||||
  METHOD="default"
 | 
			
		||||
  echo -e "${CONTAINERID}${BOLD}${DGN}Virtual Machine ID: ${BGN}${VMID}${CL}"
 | 
			
		||||
  echo -e "${CONTAINERTYPE}${BOLD}${DGN}Machine Type: ${BGN}i440fx${CL}"
 | 
			
		||||
  echo -e "${DISKSIZE}${BOLD}${DGN}Disk Size: ${BGN}${DISK_SIZE}${CL}"
 | 
			
		||||
@@ -181,6 +192,7 @@ function default_settings() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function advanced_settings() {
 | 
			
		||||
  METHOD="advanced"
 | 
			
		||||
  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 [ -z "$VMID" ]; then
 | 
			
		||||
@@ -377,6 +389,7 @@ arch_check
 | 
			
		||||
pve_check
 | 
			
		||||
ssh_check
 | 
			
		||||
start_script
 | 
			
		||||
post_to_api_vm
 | 
			
		||||
 | 
			
		||||
msg_info "Validating Storage"
 | 
			
		||||
while read -r line; do
 | 
			
		||||
@@ -439,7 +452,7 @@ done
 | 
			
		||||
 | 
			
		||||
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 \
 | 
			
		||||
  -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 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
 | 
			
		||||
qm importdisk $VMID ${FILE} $STORAGE ${DISK_IMPORT:-} 1>&/dev/null
 | 
			
		||||
qm set $VMID \
 | 
			
		||||
@@ -493,7 +506,7 @@ if [ "$START_VM" == "yes" ]; then
 | 
			
		||||
  qm start $VMID
 | 
			
		||||
  msg_ok "Started Ubuntu 24.10 VM"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
post_update_to_api "done" "none"s
 | 
			
		||||
msg_ok "Completed Successfully!\n"
 | 
			
		||||
echo -e "Setup Cloud-Init before starting \n
 | 
			
		||||
More info at https://github.com/community-scripts/ProxmoxVE/discussions/272 \n"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user