mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-11 10:19:16 +00:00
update opensens-vm.sh
This commit is contained in:
parent
9b9a3fadb6
commit
669aa4fc84
@ -28,5 +28,10 @@
|
|||||||
"username": "root",
|
"username": "root",
|
||||||
"password": "opnsense"
|
"password": "opnsense"
|
||||||
},
|
},
|
||||||
"notes": []
|
"notes": [
|
||||||
|
{
|
||||||
|
"text": "It wail fail with default settings if there is no vmbr0 and vmbr1 on your node. Use advanced settings in this case.",
|
||||||
|
"type": "warning"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ EOF
|
|||||||
header_info
|
header_info
|
||||||
echo -e "Loading..."
|
echo -e "Loading..."
|
||||||
#API VARIABLES
|
#API VARIABLES
|
||||||
RELEASE=$(curl -sL https://api.github.com/repos/opnsense/core/tags | jq -r '[.[] | select(.name | test("^[0-9]+\\.[0-9]+$"))] | max_by(.name) | .name')
|
RELEASE=$(curl -sL https://api.github.com/repos/opnsense/core/tags | grep -oP '"name": "\K[0-9]+\.[0-9]+' | sort -V | tail -n 1)
|
||||||
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
|
RANDOM_UUID="$(cat /proc/sys/kernel/random/uuid)"
|
||||||
METHOD=""
|
METHOD=""
|
||||||
NSAPP="opnsense-vm"
|
NSAPP="opnsense-vm"
|
||||||
@ -251,6 +251,7 @@ function default_settings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function advanced_settings() {
|
function advanced_settings() {
|
||||||
|
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
|
||||||
@ -361,6 +362,10 @@ function advanced_settings() {
|
|||||||
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
|
||||||
|
if [[ -n "$IP_ADDR" && ! "$IP_ADDR" =~ $ip_regex ]]; then
|
||||||
|
msg_error "Invalid IP Address format for LAN IP. Needs to be 0.0.0.0, was $IP_ADDR"
|
||||||
|
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
|
||||||
@ -368,21 +373,28 @@ function advanced_settings() {
|
|||||||
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
|
||||||
|
if [[ -n "$LAN_GW" && ! "$LAN_GW" =~ $ip_regex ]]; then
|
||||||
|
msg_error "Invalid IP Address format for Gateway. Needs to be 0.0.0.0, was $LAN_GW"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
echo -e "${DGN}Using LAN GATEWAY ADDRESS: ${BGN}$LAN_GW${CL}"
|
echo -e "${DGN}Using LAN GATEWAY ADDRESS: ${BGN}$LAN_GW${CL}"
|
||||||
else
|
|
||||||
exit-script
|
|
||||||
fi
|
fi
|
||||||
else
|
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
|
||||||
exit-script
|
|
||||||
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 [ -z $NETMASK ]; then
|
if [ -z $NETMASK ]; then
|
||||||
NETMASK=""
|
echo -e "${DGN}Netmask needs to be set if ip is not dhcp${CL}"
|
||||||
|
fi
|
||||||
|
if [[ -n "$NETMASK" && ! ("$NETMASK" =~ ^[0-9]+$ && "$NETMASK" -ge 1 && "$NETMASK" -le 32) ]]; then
|
||||||
|
msg_error "Invalid LAN NETMASK format. Needs to be 1-32, was $NETMASK"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using LAN NETMASK: ${BGN}$NETMASK${CL}"
|
echo -e "${DGN}Using LAN NETMASK: ${BGN}$NETMASK${CL}"
|
||||||
else
|
else
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
exit-script
|
||||||
|
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
|
||||||
@ -400,6 +412,10 @@ function advanced_settings() {
|
|||||||
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
|
||||||
|
if [[ -n "$WAN_IP_ADDR" && ! "$WAN_IP_ADDR" =~ $ip_regex ]]; then
|
||||||
|
msg_error "Invalid IP Address format for WAN IP. Needs to be 0.0.0.0, was $WAN_IP_ADDR"
|
||||||
|
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
|
||||||
@ -407,22 +423,30 @@ function advanced_settings() {
|
|||||||
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
|
||||||
|
if [[ -n "$WAN_GW" && ! "$WAN_GW" =~ $ip_regex ]]; then
|
||||||
|
msg_error "Invalid IP Address format for WAN Gateway. Needs to be 0.0.0.0, was $WAN_GW"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
echo -e "${DGN}Using WAN GATEWAY ADDRESS: ${BGN}$WAN_GW${CL}"
|
echo -e "${DGN}Using WAN GATEWAY ADDRESS: ${BGN}$WAN_GW${CL}"
|
||||||
else
|
else
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
else
|
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
|
||||||
exit-script
|
|
||||||
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 [ -z $WAN_NETMASK ]; then
|
if [ -z $WAN_NETMASK ]; then
|
||||||
WAN_NETMASK=""
|
echo -e "${DGN}WAN Netmask needs to be set if ip is not dhcp${CL}"
|
||||||
|
fi
|
||||||
|
if [[ -n "$WAN_NETMASK" && ! ("$WAN_NETMASK" =~ ^[0-9]+$ && "$WAN_NETMASK" -ge 1 && "$WAN_NETMASK" -le 32) ]]; then
|
||||||
|
msg_error "Invalid WAN NETMASK format. Needs to be 1-32, was $WAN_NETMASK"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
echo -e "${DGN}Using WAN NETMASK: ${BGN}$WAN_NETMASK${CL}"
|
echo -e "${DGN}Using WAN NETMASK: ${BGN}$WAN_NETMASK${CL}"
|
||||||
else
|
else
|
||||||
exit-script
|
exit-script
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
exit-script
|
||||||
|
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"
|
||||||
@ -445,25 +469,6 @@ function advanced_settings() {
|
|||||||
exit-script
|
exit-script
|
||||||
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 [ -z $VLAN1 ]; then
|
|
||||||
# VLAN1="Default"
|
|
||||||
# VLAN=""
|
|
||||||
# else
|
|
||||||
# VLAN=",tag=$VLAN1"
|
|
||||||
# fi
|
|
||||||
# echo -e "${DGN}Using LAN Vlan: ${BGN}$VLAN1${CL}"
|
|
||||||
#else
|
|
||||||
# exit-script
|
|
||||||
#fi
|
|
||||||
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then
|
|
||||||
START_VM="yes"
|
|
||||||
else
|
|
||||||
START_VM="no"
|
|
||||||
fi
|
|
||||||
echo -e "${DGN}Start VM when completed: ${BGN}$START_VM${CL}"
|
|
||||||
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create OpenSense VM?" --no-button Do-Over 10 58); then
|
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create OpenSense VM?" --no-button Do-Over 10 58); then
|
||||||
echo -e "${RD}Creating a OpenSense VM using the above advanced settings${CL}"
|
echo -e "${RD}Creating a OpenSense VM using the above advanced settings${CL}"
|
||||||
else
|
else
|
||||||
@ -473,20 +478,6 @@ function advanced_settings() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function start_script() {
|
|
||||||
if (whiptail --backtitle "Proxmox VE Helper Scripts" --title "SETTINGS" --yesno "Use Default Settings?" --no-button Advanced 10 58); then
|
|
||||||
header_info
|
|
||||||
echo -e "${BL}Using Default Settings${CL}"
|
|
||||||
default_settings
|
|
||||||
else
|
|
||||||
header_info
|
|
||||||
echo -e "${RD}Using Advanced Settings${CL}"
|
|
||||||
advanced_settings
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
arch_check
|
arch_check
|
||||||
pve_check
|
pve_check
|
||||||
ssh_check
|
ssh_check
|
||||||
|
Loading…
Reference in New Issue
Block a user