2025-05-07 23:57:51 +02:00
#!/usr/bin/env bash
2025-03-23 17:50:33 +01:00
# ==========================================================
2025-05-07 23:57:51 +02:00
# ProxMenuX - Virtual Machine Creator Script
2025-03-23 17:50:33 +01:00
# ==========================================================
# Author : MacRimi
# Copyright : (c) 2024 MacRimi
# License : MIT (https://raw.githubusercontent.com/MacRimi/ProxMenux/main/LICENSE)
# Version : 1.0
2025-05-07 23:57:51 +02:00
# Last Updated: 07/05/2025
2025-03-23 17:50:33 +01:00
# ==========================================================
2025-05-07 23:57:51 +02:00
# Description:
# This script is part of the central ProxMenux VM creation module. It allows users
# to create virtual machines (VMs) in Proxmox VE using either default or advanced
# configurations, streamlining the deployment of Linux, Windows, and other systems.
#
# Key features:
# - Supports both virtual disk creation and physical disk passthrough.
# - Automates CPU, RAM, BIOS, network and storage configuration.
# - Provides a user-friendly menu to select OS type, ISO image and disk interface.
# - Automatically generates a detailed and styled HTML description for each VM.
#
# All operations are designed to simplify and accelerate VM creation in a
# consistent and maintainable way, using ProxMenux standards.
# ==========================================================
2025-03-23 17:50:33 +01:00
REPO_URL = "https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
2025-05-07 23:57:51 +02:00
VM_REPO = " $REPO_URL /scripts/vm "
ISO_REPO = " $REPO_URL /scripts/vm "
MENU_REPO = " $REPO_URL /scripts/menus "
2025-03-23 17:50:33 +01:00
BASE_DIR = "/usr/local/share/proxmenux"
UTILS_FILE = " $BASE_DIR /utils.sh "
VENV_PATH = "/opt/googletrans-env"
2025-05-07 23:57:51 +02:00
[ [ -f " $UTILS_FILE " ] ] && source " $UTILS_FILE "
source <( curl -s " $VM_REPO /vm_configurator.sh " )
source <( curl -s " $VM_REPO /disk_selector.sh " )
source <( curl -s " $VM_REPO /vm_creator.sh " )
2025-03-23 17:50:33 +01:00
if [ [ -f " $UTILS_FILE " ] ] ; then
source " $UTILS_FILE "
fi
2025-05-07 23:57:51 +02:00
2025-03-23 17:50:33 +01:00
load_language
initialize_cache
2025-05-07 23:57:51 +02:00
function header_info( ) {
clear
show_proxmenux_logo
echo -e " ${ BL } ╔═══════════════════════════════════════════════╗ ${ CL } "
echo -e " ${ BL } ║ ║ ${ CL } "
echo -e " ${ BL } ║ ${ YWB } ProxMenux VM Creator ${ BL } ║ ${ CL } "
echo -e " ${ BL } ║ ║ ${ CL } "
echo -e " ${ BL } ╚═══════════════════════════════════════════════╝ ${ CL } "
echo -e
}
# ==========================================================
# MAIN EXECUTION
2025-03-23 17:50:33 +01:00
# ==========================================================
2025-05-07 23:57:51 +02:00
header_info
echo -e "\n Loading..."
2025-05-08 00:06:36 +02:00
#sleep 1
2025-05-07 23:57:51 +02:00
function start_vm_configuration( ) {
if ( whiptail --title "ProxMenux" --yesno " $( translate "Use Default Settings?" ) " --no-button " $( translate "Advanced" ) " 10 60) ; then
header_info
load_default_vm_config " $OS_TYPE "
if [ [ -z " $HN " ] ] ; then
HN = $( whiptail --inputbox " $( translate "Enter a name for the new virtual machine:" ) " 10 60 --title "VM Hostname" 3>& 1 1>& 2 2>& 3)
[ [ -z " $HN " ] ] && HN = "custom-vm"
fi
apply_default_vm_config
else
header_info
echo -e " ${ CUS } $( translate "Using advanced configuration" ) ${ CL } "
configure_vm_advanced " $OS_TYPE "
fi
}
2025-03-23 17:50:33 +01:00
while true; do
2025-05-07 23:57:51 +02:00
OS_TYPE = $( dialog --backtitle "ProxMenux" \
--title " $( translate "Select System Type" ) " \
--menu " \n $( translate "Choose the type of virtual system to install:" ) " 18 70 10 \
1 " $( translate "Create" ) VM System NAS " \
2 " $( translate "Create" ) VM System Windows " \
3 " $( translate "Create" ) VM System Linux " \
2025-05-16 17:24:09 +02:00
4 " $( translate "Create" ) VM System macOS (OSX-PROXMOX) " \
5 " $( translate "Create" ) VM System Others (based Linux) " \
6 " $( translate "Return to Main Menu" ) " \
2025-05-07 23:57:51 +02:00
3>& 1 1>& 2 2>& 3)
2025-05-16 17:24:09 +02:00
[ [ $? -ne 0 || " $OS_TYPE " = = "6" ] ] && exec bash <( curl -s " $MENU_REPO /main_menu.sh " )
2025-05-07 23:57:51 +02:00
case " $OS_TYPE " in
1)
source <( curl -fsSL " $ISO_REPO /select_nas_iso.sh " ) && select_nas_iso || continue
; ;
2)
source <( curl -fsSL " $ISO_REPO /select_windows_iso.sh " ) && select_windows_iso || continue
; ;
3)
source <( curl -fsSL " $ISO_REPO /select_linux_iso.sh " ) && select_linux_iso || continue
; ;
4)
2025-05-16 17:30:13 +02:00
whiptail --title "OSX-PROXMOX" --yesno " $( translate "This is an external script that creates a macOS VM in Proxmox VE in just a few steps, whether you are using AMD or Intel hardware." ) \n\n $( translate "The script clones the osx-proxmox.com repository and once the setup is complete, the server will automatically reboot." ) \n\n $( translate "Make sure there are no critical services running as they will be interrupted. Ensure your server can be safely rebooted." ) \n\n $( translate "Visit https://osx-proxmox.com for more information." ) \n\n $( translate "Do you want to run the script now?" ) " 24 70
2025-05-16 17:24:09 +02:00
if [ [ $? -eq 0 ] ] ; then
bash -c " $( curl -fsSL https://install.osx-proxmox.com) "
fi
continue
; ;
5)
2025-05-07 23:57:51 +02:00
source <( curl -fsSL " $ISO_REPO /select_linux_iso.sh " ) && select_linux_other_scripts || continue
; ;
esac
if ! confirm_vm_creation; then
continue
fi
start_vm_configuration || continue
select_disk_type
if [ [ -z " $DISK_TYPE " ] ] ; then
msg_error " $( translate "Disk type selection failed or cancelled" ) "
continue
fi
create_vm
break
done
function start_vm_configuration( ) {
if ( whiptail --title "ProxMenux" --yesno " $( translate "Use Default Settings?" ) " --no-button " $( translate "Advanced" ) " 10 60) ; then
header_info
load_default_vm_config " $OS_TYPE "
if [ [ -z " $HN " ] ] ; then
HN = $( whiptail --inputbox " $( translate "Enter a name for the new virtual machine:" ) " 10 60 --title "VM Hostname" 3>& 1 1>& 2 2>& 3)
[ [ -z " $HN " ] ] && HN = "custom-vm"
fi
apply_default_vm_config
else
header_info
echo -e " ${ CUS } $( translate "Using advanced configuration" ) ${ CL } "
configure_vm_advanced " $OS_TYPE "
fi
}