From c77fb27dabff0803c54c7cf43fede47a896a13aa Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 5 Aug 2019 17:07:59 -0700 Subject: [PATCH] Tweaks --- setup.sh | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/setup.sh b/setup.sh index 79ce06e..94467dd 100644 --- a/setup.sh +++ b/setup.sh @@ -58,7 +58,13 @@ swapspace=$(($swapspace * `getconf PAGESIZE`)) # 20% swap space with 2G minimum if [ "$swapspace" -lt "2048000" ]; then swapspace="2048000" ; fi -nics=`dialog --separate-output --no-cancel --no-items --title "Bridged network devices" --checklist "Select the network devices to be bridged to br0:" $height $width ${window}$nicdevices 2>&1 1>/dev/tty` +nics=`dialog --separate-output --no-cancel --no-items --title "Bridged network devices" --checklist "Select the network devices to be bridged to bridge - select none for no bridge:" $height $width ${window}$nicdevices 2>&1 1>/dev/tty` +if [ -z "$nics" ]; then nobridge=1 else nobridge=0; fi +if [ "$nobridge" = "1" ]; then + bridgedevice=`dialog --no-cancel --no-items --title "Bridged network devices" --radiolist "Select the network devices to be bridged to bridge - select none for no bridge:" $height $width ${window}$nicdevices 2>&1 1>/dev/tty` +else + bridgedevice="br0" +fi networktype=`dialog --no-items --no-cancel --title "Network type" --radiolist "Select the network type:" 9 40 2 dhcp off static off 2>&1 1>/dev/tty` if [ "$networktype" = "static" ]; then address=""; while [ -z "$address" ]; do address=`dialog --no-cancel --inputbox "IP Address:" 8 40 2>&1 >/dev/tty`; done @@ -574,29 +580,29 @@ echo "" echo "Writing network interfaces file..." macaddr=$(echo $hostname|md5sum|sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:\1:\2:\3:\4:\5/') mkdir -p /mnt/etc/network && mkdir -p /mnt/etc/network/interfaces.d -echo "auto lo br0" > /mnt/etc/network/interfaces.d/br0 -echo "iface lo inet loopback" >> /mnt/etc/network/interfaces.d/br0 +echo "auto lo $bridgedevice" > /mnt/etc/network/interfaces.d/$bridgedevice +echo "iface lo inet loopback" >> /mnt/etc/network/interfaces.d/$bridgedevice niclist="" for nic in `echo "$nics"`; do - echo "iface ${nic} inet manual" >> /mnt/etc/network/interfaces.d/br0 + echo "iface ${nic} inet manual" >> /mnt/etc/network/interfaces.d/$bridgedevice niclist="$niclist $nic" done if [ "$networktype" = "dhcp" ]; then - echo "iface br0 inet dhcp" >> /mnt/etc/network/interfaces.d/br0 + echo "iface $bridgedevice inet dhcp" >> /mnt/etc/network/interfaces.d/$bridgedevice else - echo "iface br0 inet static" >> /mnt/etc/network/interfaces.d/br0 - echo " address $address" >> /mnt/etc/network/interfaces.d/br0 - echo " netmask $subnet" >> /mnt/etc/network/interfaces.d/br0 - echo " gateway $gateway" >> /mnt/etc/network/interfaces.d/br0 + echo "iface $bridgedevice inet static" >> /mnt/etc/network/interfaces.d/$bridgedevice + echo " address $address" >> /mnt/etc/network/interfaces.d/$bridgedevice + echo " netmask $subnet" >> /mnt/etc/network/interfaces.d/$bridgedevice + echo " gateway $gateway" >> /mnt/etc/network/interfaces.d/$bridgedevice sed -ir "s/^#DNS=.*/DNS=${dns1}/g" /mnt/etc/systemd/resolved.conf if ! [ -z "$dns2" ]; then sed -ir "s/^#FallbackDNS=.*/FallbackDNS=${dns2}/g" /mnt/etc/systemd/resolved.conf ; fi fi #echo " bridge_hw $macaddr" >> /mnt/etc/network/interfaces.d/br0 -echo " dns-nameservers 127.0.0.53" >> /mnt/etc/network/interfaces.d/br0 -echo " bridge_waitport 0" >> /mnt/etc/network/interfaces.d/br0 -echo " bridge_fd 0" >> /mnt/etc/network/interfaces.d/br0 -echo " bridge_ports${niclist}" >> /mnt/etc/network/interfaces.d/br0 -echo " bridge_stp on" >> /mnt/etc/network/interfaces.d/br0 +echo " dns-nameservers 127.0.0.53" >> /mnt/etc/network/interfaces.d/$bridgedevice +echo " bridge_waitport 0" >> /mnt/etc/network/interfaces.d/$bridgedevice +echo " bridge_fd 0" >> /mnt/etc/network/interfaces.d/$bridgedevice +echo " bridge_ports${niclist}" >> /mnt/etc/network/interfaces.d/$bridgedevice +echo " bridge_stp on" >> /mnt/etc/network/interfaces.d/$bridgedevice echo "source-directory /etc/network/interfaces.d" > /mnt/etc/network/interfaces echo "Done." @@ -604,7 +610,7 @@ echo "Done." echo "" echo "Opening SSH port on firewall..." -sed -ir 's/### RULES ###/### RULES ###\n-A ufw-user-input -i br0 -p tcp --dport 22 -j ACCEPT/g' /mnt/etc/ufw/user.rules 2>&1 1>/dev/null +sed -ir 's/### RULES ###/### RULES ###\n-A ufw-user-input -p tcp --dport 22 -j ACCEPT/g' /mnt/etc/ufw/user.rules 2>&1 1>/dev/null echo "Done." # commented out for debugging echo ""