Update openwrt.sh

Compactify script and fix text (WAN Vlan).
pull/1460/head
Rani Hod 2 years ago
parent 89e933e85e
commit 29faf8d718
  1. 39
      vm/openwrt.sh

@ -243,11 +243,10 @@ function advanced_settings() {
if VM_NAME=$(whiptail --inputbox "Set Hostname" 8 58 openwrt --title "HOSTNAME" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if VM_NAME=$(whiptail --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"
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}"
fi fi
echo -e "${DGN}Using Hostname: ${BGN}$HN${CL}"
else else
exit-script exit-script
fi fi
@ -255,10 +254,8 @@ function advanced_settings() {
if CORE_COUNT=$(whiptail --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 --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"
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
else
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
fi fi
echo -e "${DGN}Allocated Cores: ${BGN}$CORE_COUNT${CL}"
else else
exit-script exit-script
fi fi
@ -266,10 +263,8 @@ function advanced_settings() {
if RAM_SIZE=$(whiptail --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 --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"
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
else
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
fi fi
echo -e "${DGN}Allocated RAM: ${BGN}$RAM_SIZE${CL}"
else else
exit-script exit-script
fi fi
@ -277,10 +272,8 @@ function advanced_settings() {
if BRG=$(whiptail --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 --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"
echo -e "${DGN}Using WAN Bridge: ${BGN}$BRG${CL}"
else
echo -e "${DGN}Using WAN Bridge: ${BGN}$BRG${CL}"
fi fi
echo -e "${DGN}Using WAN Bridge: ${BGN}$BRG${CL}"
else else
exit-script exit-script
fi fi
@ -288,10 +281,8 @@ function advanced_settings() {
if LAN_BRG=$(whiptail --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 --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"
echo -e "${DGN}Using LAN Bridge: ${BGN}$LAN_BRG${CL}"
else
echo -e "${DGN}Using LAN Bridge: ${BGN}$LAN_BRG${CL}"
fi fi
echo -e "${DGN}Using LAN Bridge: ${BGN}$LAN_BRG${CL}"
else else
exit-script exit-script
fi fi
@ -299,11 +290,10 @@ function advanced_settings() {
if MAC1=$(whiptail --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 --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"
echo -e "${DGN}Using WAN MAC Address: ${BGN}$MAC${CL}"
else else
MAC="$MAC1" MAC="$MAC1"
echo -e "${DGN}Using WAN MAC Address: ${BGN}$MAC1${CL}"
fi fi
echo -e "${DGN}Using WAN MAC Address: ${BGN}$MAC${CL}"
else else
exit-script exit-script
fi fi
@ -311,24 +301,22 @@ function advanced_settings() {
if MAC2=$(whiptail --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 --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"
echo -e "${DGN}Using LAN MAC Address: ${BGN}$LAN_MAC${CL}"
else else
LAN_MAC="$MAC2" LAN_MAC="$MAC2"
echo -e "${DGN}Using LAN MAC Address: ${BGN}$MAC2${CL}"
fi fi
echo -e "${DGN}Using LAN MAC Address: ${BGN}$LAN_MAC${CL}"
else else
exit-script exit-script
fi fi
if VLAN1=$(whiptail --inputbox "Set a Vlan(leave blank for default)" 8 58 --title "WAN VLAN" --cancel-button Exit-Script 3>&1 1>&2 2>&3); then if VLAN1=$(whiptail --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=""
echo -e "${DGN}Using WAN Vlan: ${BGN}$VLAN1${CL}"
else else
VLAN=",tag=$VLAN1" VLAN=",tag=$VLAN1"
echo -e "${DGN}Using WAN Vlan: ${BGN}$VLAN1${CL}"
fi fi
echo -e "${DGN}Using WAN Vlan: ${BGN}$VLAN1${CL}"
else else
exit-script exit-script
fi fi
@ -337,11 +325,10 @@ function advanced_settings() {
if [ -z $VLAN2 ]; then if [ -z $VLAN2 ]; then
VLAN2="999" VLAN2="999"
LAN_VLAN=",tag=$VLAN2" LAN_VLAN=",tag=$VLAN2"
echo -e "${DGN}Using LAN Vlan: ${BGN}$VLAN2${CL}"
else else
LAN_VLAN=",tag=$VLAN2" LAN_VLAN=",tag=$VLAN2"
echo -e "${DGN}Using LAN Vlan: ${BGN}$VLAN2${CL}"
fi fi
echo -e "${DGN}Using LAN Vlan: ${BGN}$VLAN2${CL}"
else else
exit-script exit-script
fi fi
@ -350,22 +337,20 @@ function advanced_settings() {
if [ -z $MTU1 ]; then if [ -z $MTU1 ]; then
MTU1="Default" MTU1="Default"
MTU="" MTU=""
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
else else
MTU=",mtu=$MTU1" MTU=",mtu=$MTU1"
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
fi fi
echo -e "${DGN}Using Interface MTU Size: ${BGN}$MTU1${CL}"
else else
exit-script exit-script
fi fi
if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then if (whiptail --title "START VIRTUAL MACHINE" --yesno "Start VM when completed?" 10 58); then
echo -e "${DGN}Start VM when completed: ${BGN}yes${CL}"
START_VM="yes" START_VM="yes"
else else
echo -e "${DGN}Start VM when completed: ${BGN}no${CL}"
START_VM="no" START_VM="no"
fi fi
echo -e "${DGN}Start VM when completed: ${BGN}$START_VM${CL}"
if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create OpenWrt VM?" --no-button Do-Over 10 58); then if (whiptail --title "ADVANCED SETTINGS COMPLETE" --yesno "Ready to create OpenWrt VM?" --no-button Do-Over 10 58); then
echo -e "${RD}Creating a OpenWrt VM using the above advanced settings${CL}" echo -e "${RD}Creating a OpenWrt VM using the above advanced settings${CL}"

Loading…
Cancel
Save