From 89943c40929c30e3ba918b8ec7970cf9879fef58 Mon Sep 17 00:00:00 2001 From: sean Date: Tue, 16 Jul 2019 17:37:19 -0700 Subject: [PATCH] tweaks --- setup.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/setup.sh b/setup.sh index 82c4407..097d775 100644 --- a/setup.sh +++ b/setup.sh @@ -45,6 +45,17 @@ domainname=""; while [ -z "$domainname" ]; do domainname=`dialog --no-cancel --i fqdn="${hostname}.${domainname}" nicdevices=""; for nic in $(ip -o link show | awk -F': ' '{print $2}' | grep -v '^lo'); do nicdevices="$nicdevices $nic off"; done 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` +networktype=`dialog --no-items --no-cancel --title "Network type" --radiolist "Select the network type:" 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 + subnet=""; while [ -z "$subnet" ]; do subnet=`dialog --no-cancel --inputbox "Subnet mask:" 8 40 2>&1 >/dev/tty`; done + gateway=""; while [ -z "$gateway" ]; do gateway=`dialog --no-cancel --inputbox "Gateway:" 8 40 2>&1 >/dev/tty`; done + dns1=""; while [ -z "$dns1" ]; do dns1=`dialog --no-cancel --inputbox "Primary DNS server:" 8 40 2>&1 >/dev/tty`; done + dns2=`dialog --no-cancel --inputbox "Secondary DNS server:" 8 40 2>&1 >/dev/tty` +fi + + + admin=""; while [ -z "$admin" ]; do admin=`dialog --no-cancel --inputbox "Admin user:" 8 40 2>&1 >/dev/tty`; done rootpassword="" while [ "$rootpassword" = "" ]; do @@ -430,10 +441,11 @@ echo "chown smmsp:smmsp /var/spool/mqueue-client" >> /mnt/setup-chroot.sh echo "chmod g+w /var/spool/mqueue-client" >> /mnt/setup-chroot.sh echo "HOME=\"/root\"" >> /mnt/setup-chroot.sh echo "HOSTNAME=\"$hostname\"" >> /mnt/setup-chroot.sh +echo "echo \"y\\ny\\ny\\n\" | sendmailconfig" >> /mnt/setup-chroot.sh echo "service sendmail start" >> /mnt/setup-chroot.sh echo "cat \"/home/${admin}/.ssh/id_rsa.pub\" | mail -s \"$hostname SSH key\" -A \"/home/${admin}/.ssh/id_rsa.pub\" admin" >> /mnt/setup-chroot.sh # uuencode test.csv test.csv | mail -v -s "Subject test" -r no-reply@mydomain.co.uk recepient@mydomain.co.uk -echo "sendmail -OTimeout.hoststatus=0m -q -v" >> /mnt/setup-chroot.sh +#echo "sendmail -OTimeout.hoststatus=0m -q -v" >> /mnt/setup-chroot.sh echo "service sendmail stop" >> /mnt/setup-chroot.sh @@ -463,14 +475,22 @@ for nic in "$nics"; do echo "iface ${nic} inet manual" >> /mnt/etc/network/interfaces.d/br0 niclist="$niclist $nic" done -echo "iface br0 inet dhcp" >> /mnt/etc/network/interfaces.d/br0 -#echo " post-up ip link set br0 address $macaddr" >> /mnt/etc/network/interfaces.d/br0 +if [ "$networktype" = "dhcp" ]; then + echo "iface br0 inet dhcp" >> /mnt/etc/network/interfaces.d/br0 +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 + 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/br0 echo "source-directory /etc/network/interfaces.d" > /mnt/etc/network/interfaces echo "Done."