mirror of
https://github.com/tteck/Proxmox.git
synced 2024-11-29 18:13:10 +01:00
Changes to openwrt.sh (#1460)
* Update openwrt.sh Compactify script and fix text (WAN Vlan). * Update openwrt.sh Switch network devices to match OpenWrt defaults (eth0 is lan, eth1 is wan).
This commit is contained in:
parent
89e933e85e
commit
11e0f3a8ed
@ -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}"
|
||||||
@ -478,11 +463,11 @@ msg_ok "Network interfaces are being configured as OpenWrt initiates."
|
|||||||
send_line_to_vm ""
|
send_line_to_vm ""
|
||||||
send_line_to_vm "uci delete network.@device[0]"
|
send_line_to_vm "uci delete network.@device[0]"
|
||||||
send_line_to_vm "uci set network.wan=interface"
|
send_line_to_vm "uci set network.wan=interface"
|
||||||
send_line_to_vm "uci set network.wan.device=eth0"
|
send_line_to_vm "uci set network.wan.device=eth1"
|
||||||
send_line_to_vm "uci set network.wan.proto=dhcp"
|
send_line_to_vm "uci set network.wan.proto=dhcp"
|
||||||
send_line_to_vm "uci delete network.lan"
|
send_line_to_vm "uci delete network.lan"
|
||||||
send_line_to_vm "uci set network.lan=interface"
|
send_line_to_vm "uci set network.lan=interface"
|
||||||
send_line_to_vm "uci set network.lan.device=eth1"
|
send_line_to_vm "uci set network.lan.device=eth0"
|
||||||
send_line_to_vm "uci set network.lan.proto=static"
|
send_line_to_vm "uci set network.lan.proto=static"
|
||||||
send_line_to_vm "uci set network.lan.ipaddr=192.168.2.1"
|
send_line_to_vm "uci set network.lan.ipaddr=192.168.2.1"
|
||||||
send_line_to_vm "uci set network.lan.netmask=255.255.255.0"
|
send_line_to_vm "uci set network.lan.netmask=255.255.255.0"
|
||||||
@ -496,8 +481,8 @@ until qm status $VMID | grep -q "stopped"; do
|
|||||||
done
|
done
|
||||||
msg_info "Bridge interfaces are being added."
|
msg_info "Bridge interfaces are being added."
|
||||||
qm set $VMID \
|
qm set $VMID \
|
||||||
-net0 virtio,bridge=${BRG},macaddr=${MAC}${VLAN}${MTU} \
|
-net0 virtio,bridge=${LAN_BRG},macaddr=${LAN_MAC}${LAN_VLAN}${MTU} \
|
||||||
-net1 virtio,bridge=${LAN_BRG},macaddr=${LAN_MAC}${LAN_VLAN}${MTU} >/dev/null 2>/dev/null
|
-net1 virtio,bridge=${BRG},macaddr=${MAC}${VLAN}${MTU} >/dev/null 2>/dev/null
|
||||||
msg_ok "Bridge interfaces have been successfully added."
|
msg_ok "Bridge interfaces have been successfully added."
|
||||||
if [ "$START_VM" == "yes" ]; then
|
if [ "$START_VM" == "yes" ]; then
|
||||||
msg_info "Starting OpenWrt VM"
|
msg_info "Starting OpenWrt VM"
|
||||||
|
Loading…
Reference in New Issue
Block a user