diff --git a/setup.sh b/setup.sh index 6d4218a..959c74b 100644 --- a/setup.sh +++ b/setup.sh @@ -28,6 +28,19 @@ 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 boot drives:" $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 +if [ "$diskcount" = "1" ]; then diskoptions="8 35 1 none off"; fi +if [ "$diskcount" = "2" ]; then diskoptions="9 35 2 mirror off none off"; fi +if [ "$diskcount" = "3" ]; then diskoptions="10 35 3 raidz off mirror off none off"; fi +if [ "$diskcount" = "4" ]; then diskoptions="12 35 5 raidz off raidz2 off raidz3 off mirror off none off"; fi +if [ "$diskcount" = "5" ]; then diskoptions="12 35 5 raidz off raidz2 off raidz3 off mirror off none off"; fi +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:" 12 35 5 raidz off raidz2 off raidz3 off mirror off none off 2>&1 1>/dev/tty` hostname=""; while [ -z "$hostname" ]; do hostname=`dialog --no-cancel --inputbox "Hostname:" 8 40 2>&1 >/dev/tty`; done nicdevices=""; for nic in $(ip -o link show | awk -F': ' '{print $2}' | grep -v '^lo'); do nicdevices="$nicdevices $nic off"; done