diff --git a/setup.sh b/setup.sh index 54e2355..f5509e3 100644 --- a/setup.sh +++ b/setup.sh @@ -12,7 +12,7 @@ fi echo "" echo "Installing required setup configuration utilities..." -errors=$(apt install -y dialog net-tools gdisk zfs-initramfs debootstrap >/dev/null 2>/dev/null) +errors=$(apt install -y net-tools gdisk zfs-initramfs debootstrap >/dev/null 2>/dev/null) if [ "$?" = "0" ]; then echo "Done." else @@ -27,7 +27,7 @@ window=$((height - 5)) # gather input at the start devices=""; for device in $(ls /dev/disk/by-id | grep -v part); do devices="$devices $device off"; done -disks=`dialog --separate-output --no-cancel --no-items --title "Root devices" --checklist "Select root OS disks:" $height $width ${window}$devices 2>&1 1>/dev/tty` +disks=`whiptail --separate-output --no-cancel --no-items --title "Root devices" --checklist "Select root OS disks:" $height $width ${window}$devices 2>&1 1>/dev/tty` diskcount=`echo "$disks" | wc -l` diskoptions="12 35 5 raidz off raidz2 off raidz3 off mirror off none off" if [ "$diskcount" = "0" ] ; then echo "No disks found to use for boot device"; exit 112; fi @@ -39,41 +39,41 @@ if [ "$diskcount" = "5" ]; then diskoptions="12 35 5 raidz off raidz2 off raidz3 if [ "$diskcount" = "6" ]; then diskoptions="12 35 5 raidz off raidz2 off raidz3 off mirror off none off"; fi if [ "$diskcount" -gt "6" ]; then diskoptions="11 35 4 raidz2 off raidz3 off mirror off none off"; fi if [ "$diskcount" -gt "11" ]; then diskoptions="10 35 3 raidz3 off mirror off none off"; fi -raidtype=`dialog --no-items --no-cancel --title "Root pool ZFS RAID" --radiolist "Select root pool ZFS RAID type:" $diskoptions 2>&1 1>/dev/tty` -hostname=""; while [ -z "$hostname" ]; do hostname=`dialog --no-cancel --inputbox "Hostname:" 8 40 2>&1 >/dev/tty`; done -domainname=""; while [ -z "$domainname" ]; do domainname=`dialog --no-cancel --inputbox "Domain name root (for fully qualified domain, e.g. company.com):" 8 40 2>&1 >/dev/tty`; done +raidtype=`whiptail --no-items --no-cancel --title "Root pool ZFS RAID" --radiolist "Select root pool ZFS RAID type:" $diskoptions 2>&1 1>/dev/tty` +hostname=""; while [ -z "$hostname" ]; do hostname=`whiptail --no-cancel --inputbox "Hostname:" 8 40 2>&1 >/dev/tty`; done +domainname=""; while [ -z "$domainname" ]; do domainname=`whiptail --no-cancel --inputbox "Domain name root (for fully qualified domain, e.g. company.com):" 8 40 2>&1 >/dev/tty`; done 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:" 9 40 2 dhcp off static off 2>&1 1>/dev/tty` +nics=`whiptail --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=`whiptail --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 - 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` + address=""; while [ -z "$address" ]; do address=`whiptail --no-cancel --inputbox "IP Address:" 8 40 2>&1 >/dev/tty`; done + subnet=""; while [ -z "$subnet" ]; do subnet=`whiptail --no-cancel --inputbox "Subnet mask:" 8 40 2>&1 >/dev/tty`; done + gateway=""; while [ -z "$gateway" ]; do gateway=`whiptail --no-cancel --inputbox "Gateway:" 8 40 2>&1 >/dev/tty`; done + dns1=""; while [ -z "$dns1" ]; do dns1=`whiptail --no-cancel --inputbox "Primary DNS server:" 8 40 2>&1 >/dev/tty`; done + dns2=`whiptail --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 +admin=""; while [ -z "$admin" ]; do admin=`whiptail --no-cancel --inputbox "Admin user:" 8 40 2>&1 >/dev/tty`; done rootpassword="" while [ "$rootpassword" = "" ]; do - rootpassword=`dialog --no-cancel --title "Root password" --insecure --passwordbox "Enter root password:" 8 40 2>&1 1>/dev/tty` - confirmpassword=`dialog --no-cancel --title "Root password confirmation" --insecure --passwordbox "Re-enter root password:" 8 40 2>&1 1>/dev/tty` + rootpassword=`whiptail --no-cancel --title "Root password" --insecure --passwordbox "Enter root password:" 8 40 2>&1 1>/dev/tty` + confirmpassword=`whiptail --no-cancel --title "Root password confirmation" --insecure --passwordbox "Re-enter root password:" 8 40 2>&1 1>/dev/tty` if ! [ "$rootpassword" = "$confirmpassword" ]; then echo "Password does not match confirmation - please retry the setup" rootpassword="" fi done -admins=`dialog --no-items --no-cancel --title "Root pool ZFS RAID" --inputbox "List administrator e-mail addresses separated by comma:" 10 40 2>&1 1>/dev/tty` +admins=`whiptail --no-items --no-cancel --title "Root pool ZFS RAID" --inputbox "List administrator e-mail addresses separated by comma:" 10 40 2>&1 1>/dev/tty` a=""; for x in `timedatectl list-timezones`; do a="$a $x" ; done -smtp=""; while [ -z "$smtp" ]; do smtp=`dialog --no-cancel --inputbox "Outoing e-mail SMTP proxy server:" 8 40 2>&1 >/dev/tty`; done -email=""; while [ -z "$email" ]; do email=`dialog --no-cancel --inputbox "Outgoing mail username:" 8 40 2>&1 >/dev/tty`; done +smtp=""; while [ -z "$smtp" ]; do smtp=`whiptail --no-cancel --inputbox "Outoing e-mail SMTP proxy server:" 8 40 2>&1 >/dev/tty`; done +email=""; while [ -z "$email" ]; do email=`whiptail --no-cancel --inputbox "Outgoing mail username:" 8 40 2>&1 >/dev/tty`; done emailpassword="" while [ "$emailpassword" = "" ]; do - emailpassword=`dialog --no-cancel --title "Outgoing e-mail SMTP mail password" --insecure --passwordbox "Enter outgoing e-mail SMTP password:" 8 40 2>&1 1>/dev/tty` - confirmpassword=`dialog --no-cancel --title "Outgoing e-mail SMTP mail password" --insecure --passwordbox "Re-enter outgoing e-mail SMTP password:" 8 40 2>&1 1>/dev/tty` + emailpassword=`whiptail --no-cancel --title "Outgoing e-mail SMTP mail password" --insecure --passwordbox "Enter outgoing e-mail SMTP password:" 8 40 2>&1 1>/dev/tty` + confirmpassword=`whiptail --no-cancel --title "Outgoing e-mail SMTP mail password" --insecure --passwordbox "Re-enter outgoing e-mail SMTP password:" 8 40 2>&1 1>/dev/tty` if ! [ "$emailpassword" = "$confirmpassword" ]; then echo "Password does not match confirmation - please retry the setup" emailpassword="" @@ -81,9 +81,9 @@ while [ "$emailpassword" = "" ]; do done -timezone=`dialog --no-items --no-cancel --menu "Select time zone:" $height 40 ${window}${a} 2>&1 1>/dev/tty` +timezone=`whiptail --no-items --no-cancel --menu "Select time zone:" $height 40 ${window}${a} 2>&1 1>/dev/tty` #timedatectl list-timezones -#timezone=`dialog --no-cancel --title "Timezone" --inputbox "Time zone:" 8 40 "America/Los_Angeles" 2>&1 1>/dev/tty` +#timezone=`whiptail --no-cancel --title "Timezone" --inputbox "Time zone:" 8 40 "America/Los_Angeles" 2>&1 1>/dev/tty` for disk in `echo "$disks"`; do echo "" @@ -461,18 +461,19 @@ echo "echo \"AuthUser=${email}\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot. echo "echo \"AuthPass=${emailpassword}\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh echo "echo \"mailhub=${smtp}\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh echo "echo \"UseSTARTTLS=YES\" >> /etc/ssmtp/ssmtp.conf" >> /mnt/setup-chroot.sh - +echo "echo \"root:${email}\" >> /etc/ssmtp/revaliases" >> /mnt/setup-chroot.sh +echo "chfn -f '${email}' root" >> /mnt/setup-chroot.sh echo "echo \"\"" >> /mnt/setup-chroot.sh echo "echo \"Sending SSH key via e-mail...\"" >> /mnt/setup-chroot.sh if [ "$networktype" = "dhcp" ]; then - connection="`hostname -I`/`wget -qO - ifconfig.me`" + connection="`hostname -I` (`wget -qO - ifconfig.me`)" else connection="$address" fi # --content-filename=\"${hostname}.ssh.key\" --content-name=\"${hostname}.ssh.key\" echo "serverinfo=\`cat \"/home/${admin}/.ssh/id_rsa\"\`" >> /mnt/setup-chroot.sh -echo "serverinfo=\"Server available at $connection\\n\$serverinfo\"; echo \"\$serverinfo\" | mail -s \"$hostname SSH key\" -A \"/home/${admin}/.ssh/id_rsa\" -r \"${email}\" \"${admins}\"" >> /mnt/setup-chroot.sh -#echo "echo " | mail -s \"$hostname SSH key\" -A \"/home/${admin}/.ssh/id_rsa\" -r \"${email}\" \"${admins}\"" >> /mnt/setup-chroot.sh +#echo "serverinfo=\"Server available at $connection\\n\$serverinfo\"; echo \"\$serverinfo\" | mail -s \"$hostname SSH key\" -A \"/home/${admin}/.ssh/id_rsa\" -r \"${email}\" \"${admins}\"" >> /mnt/setup-chroot.sh +echo "serverinfo=\"Server available at $connection\\n\\n\$serverinfo\"; echo -e \"\$serverinfo\" | mail -s \"$hostname SSH key\" -r \"${email}\" \"${admins}\"" >> /mnt/setup-chroot.sh echo "echo \"Done.\"" >> /mnt/setup-chroot.sh @@ -539,7 +540,6 @@ for nic in `echo "$nics"`; do echo "iface ${nic} inet manual" >> /mnt/etc/network/interfaces.d/br0 niclist="$niclist $nic" done -echo "niclist: $niclist" if [ "$networktype" = "dhcp" ]; then echo "iface br0 inet dhcp" >> /mnt/etc/network/interfaces.d/br0 else