@@ -9,12 +9,12 @@ source /dev/stdin <<<$(curl -fsSL https://raw.githubusercontent.com/community-sc
99function header_info {
1010 clear
1111 cat << "EOF "
12- ____ ____ _ __
13- / __ \/ __ \/ | / /_______ ____ ________
12+ ____ ____ _ __
13+ / __ \/ __ \/ | / /_______ ____ ________
1414 / / / / /_/ / |/ / ___/ _ \/ __ \/ ___/ _ \
1515/ /_/ / ____/ /| (__ ) __/ / / (__ ) __/
16- \____/_/ /_/ |_/____/\___/_/ /_/____/\___/
17-
16+ \____/_/ /_/ |_/____/\___/_/ /_/____/\___/
17+
1818EOF
1919}
2020header_info
@@ -137,7 +137,7 @@ function send_line_to_vm() {
137137 " U" ) character=" shift-u" ;;
138138 " V" ) character=" shift-v" ;;
139139 " W" ) character=" shift-w" ;;
140- " X" ) character=" shift= x" ;;
140+ " X" ) character=" shift- x" ;;
141141 " Y" ) character=" shift-y" ;;
142142 " Z" ) character=" shift-z" ;;
143143 " !" ) character=" shift-1" ;;
@@ -156,9 +156,6 @@ function send_line_to_vm() {
156156 qm sendkey $VMID ret
157157}
158158
159- TEMP_DIR=$( mktemp -d)
160- pushd $TEMP_DIR > /dev/null
161-
162159if (whiptail --backtitle " Proxmox VE Helper Scripts" --title " OPNsense VM" --yesno " This will create a New OPNsense VM. Proceed?" 10 58); then
163160 :
164161else
@@ -278,12 +275,27 @@ function default_settings() {
278275 fi
279276 echo -e " ${DGN} Using LAN VLAN: ${BGN} Default${CL} "
280277 echo -e " ${DGN} Using LAN MAC Address: ${BGN}${MAC}${CL} "
281- echo -e " ${DGN} Using WAN MAC Address: ${BGN}${WAN_MAC}${CL} "
282- if ! grep -q " ^iface ${WAN_BRG} " /etc/network/interfaces; then
283- msg_error " Bridge '${WAN_BRG} ' does not exist in /etc/network/interfaces"
284- exit
278+
279+ if NETWORK_MODE=$( whiptail --backtitle " Proxmox VE Helper Scripts" --title " NETWORK CONFIGURATION" --radiolist --cancel-button Exit-Script \
280+ " Choose network setup mode for OPNsense:\n" 14 70 2 \
281+ " dual" " Dual Interface (Traditional Firewall/Router)" ON \
282+ " single" " Single Interface (Proxy/VPN/IDS Server)" OFF \
283+ 3>&1 1>&2 2>&3 ) ; then
284+ if [ " $NETWORK_MODE " = " dual" ]; then
285+ echo -e " ${DGN} Network Mode: ${BGN} Dual Interface (Firewall)${CL} "
286+ echo -e " ${DGN} Using WAN MAC Address: ${BGN}${WAN_MAC}${CL} "
287+ if ! grep -q " ^iface ${WAN_BRG} " /etc/network/interfaces; then
288+ msg_error " Bridge '${WAN_BRG} ' does not exist in /etc/network/interfaces"
289+ exit
290+ else
291+ echo -e " ${DGN} Using WAN Bridge: ${BGN}${WAN_BRG}${CL} "
292+ fi
293+ else
294+ echo -e " ${DGN} Network Mode: ${BGN} Single Interface (Proxy/VPN/IDS)${CL} "
295+ WAN_BRG=" "
296+ fi
285297 else
286- echo -e " ${DGN} Using WAN Bridge: ${BGN}${WAN_BRG}${CL} "
298+ exit-script
287299 fi
288300 echo -e " ${DGN} Using Interface MTU Size: ${BGN} Default${CL} "
289301 echo -e " ${DGN} Start VM when completed: ${BGN} yes${CL} "
@@ -359,7 +371,7 @@ function advanced_settings() {
359371 fi
360372
361373 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
362- if [ -z $VM_NAME ]; then
374+ if [ -z " $VM_NAME " ]; then
363375 HN=" OPNsense"
364376 else
365377 HN=$( echo ${VM_NAME,,} | tr -d ' ' )
@@ -370,7 +382,7 @@ function advanced_settings() {
370382 fi
371383
372384 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
373- if [ -z $CORE_COUNT ]; then
385+ if [ -z " $CORE_COUNT " ]; then
374386 CORE_COUNT=" 2"
375387 fi
376388 echo -e " ${DGN} Allocated Cores: ${BGN} $CORE_COUNT ${CL} "
566578msg_ok " Using ${CL}${BL} $STORAGE ${CL} ${GN} for Storage Location."
567579msg_ok " Virtual Machine ID is ${CL}${BL} $VMID ${CL} ."
568580msg_info " Retrieving the URL for the OPNsense Qcow2 Disk Image"
569- URL=https://download.freebsd.org/releases/VM-IMAGES/14.2-RELEASE/amd64/Latest/FreeBSD-14.2-RELEASE-amd64.qcow2.xz
570- sleep 2
571- msg_ok " ${CL}${BL}${URL}${CL} "
581+ URL=" https://download.freebsd.org/releases/VM-IMAGES/14.2-RELEASE/amd64/Latest/FreeBSD-14.2-RELEASE-amd64.qcow2.xz"
582+ msg_ok " Download URL: ${CL}${BL}${URL}${CL} "
572583curl -f#SL -o " $( basename " $URL " ) " " $URL "
573584echo -en " \e[1A\e[0K"
574- FILE=Fressbsd .qcow2
585+ FILE=FreeBSD .qcow2
575586unxz -cv $( basename $URL ) > ${FILE}
576587msg_ok " Downloaded ${CL}${BL}${FILE}${CL} "
577588
@@ -623,7 +634,7 @@ DESCRIPTION=$(
623634 <img src='https://img.shields.io/badge/☕-Buy us a coffee-blue' alt='spend Coffee' />
624635 </a>
625636 </p>
626-
637+
627638 <span style='margin: 0 10px;'>
628639 <i class="fa fa-github fa-fw" style="color: #f5f5f5;"></i>
629640 <a href='https://github.com/community-scripts/ProxmoxVE' target='_blank' rel='noopener noreferrer' style='text-decoration: none; color: #00617f;'>GitHub</a>
@@ -652,9 +663,13 @@ qm start $VMID
652663sleep 90
653664send_line_to_vm " root"
654665send_line_to_vm " fetch https://raw.githubusercontent.com/opnsense/update/master/src/bootstrap/opnsense-bootstrap.sh.in"
655- qm set $VMID \
656- -net1 virtio,bridge=${WAN_BRG} ,macaddr=${WAN_MAC} & > /dev/null
657- sleep 10
666+ if [ -n " $WAN_BRG " ]; then
667+ msg_info " Adding WAN interface"
668+ qm set $VMID \
669+ -net1 virtio,bridge=${WAN_BRG} ,macaddr=${WAN_MAC} & > /dev/null
670+ msg_ok " WAN interface added"
671+ sleep 5 # Brief pause after adding network interface
672+ fi
658673send_line_to_vm " sh ./opnsense-bootstrap.sh.in -y -f -r 25.1"
659674msg_ok " OPNsense VM is being installed, do not close the terminal, or the installation will fail."
660675# We need to wait for the OPNsense build proccess to finish, this takes a few minutes
689704 send_line_to_vm " n"
690705 send_line_to_vm " n"
691706fi
692- # we need to wait for the Config changes to be saved
707+ # Wait for config changes to be saved
693708sleep 20
694- if [ " $WAN_IP_ADDR " != " " ]; then
709+ if [ -n " $WAN_BRG " ] && [ " $WAN_IP_ADDR " != " " ]; then
695710 send_line_to_vm " 2"
696711 send_line_to_vm " 2"
697712 send_line_to_vm " n"
0 commit comments