From a02cf785e59c26463dd040fc93a94e7a54e53b5f Mon Sep 17 00:00:00 2001 From: sean Date: Tue, 9 Jul 2019 13:21:23 -0700 Subject: [PATCH] tweaks --- setup.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/setup.sh b/setup.sh index cd36d5e..bbcd8b9 100644 --- a/setup.sh +++ b/setup.sh @@ -28,29 +28,32 @@ window=$((height - 5)) # set line separator 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` +raidtype=`dialog --no-items --no-cancel --title "Root pool ZFS RAID" --radiolist "Select root pool ZFS RAID type" 11 35 4 raidz off raidz2 off mirror off none off 2>&1 1>/dev/tty` + hostname=""; while [ -z "$hostname" ]; do hostname=`dialog --no-cancel --inputbox "Host name/Server name" 8 100 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 nics=`dialog --separate-output --no-cancel --no-items --title "Network devices for bridge" --checklist "Select the network devices to be bridged" $height $width ${window}$nicdevices 2>&1 1>/dev/tty` -for disk in "$disks"; do +IFS=$'\n' + +for disk in `echo $disks`; do # remove echo for testing echo "Partitioning disk $disk..." # collect the return values, check them for errors and display them - echo "sgdisk --zap-all /dev/disk/by-id/$disk >/dev/null 2>&1" - echo "sgdisk -n2:1M:+512M -t2:EF00 /dev/disk/by-id/$disk >/dev/null 2>&1" - echo "sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk >/dev/null 2>&1" - echo "sgdisk -n4:0:0 -t4:BF01 /dev/disk/by-id/$disk >/dev/null 2>&1" + errors=`sgdisk --zap-all /dev/disk/by-id/$disk >/dev/null 2>&1 && sgdisk -n2:1M:+512M -t2:EF00 /dev/disk/by-id/$disk >/dev/null 2>&1 && sgdisk -n3:0:+512M -t3:BF01 /dev/disk/by-id/$disk >/dev/null 2>&1 && sgdisk -n4:0:0 -t4:BF01 /dev/disk/by-id/$disk >/dev/null 2>&1` + if ! [ "$?" = "0" ]; then + echo "Failed to partition disk $disk - $errors" + exit 3 + fi echo "Done." done # create boot mirror list bootmirror=""; for disk in "$disks": do bootmirror="$bootmirror /dev/disk/by-id/${disk}-part3"; done - rootraidz=""; for disk in "$disks"; do rootraidz="$rootraidz /dev/disk/by-id/${disk}-part4"; done echo "zpool create -f -o ashift=12 -d -o feature@async_destroy=enable -o feature@bookmarks=enabled -o feature@embedded_data=enabled -o feature@empty_bpobj=enabled -o feature@enabled_txg=enabled -o feature@extensible_dataset=enabled -o feature@filesystem_limits=enabled -o feature@hole_birth=enabled -o feature@large_blocks=enabled -o feature@lz4_compress=enabled -o feature@spacemap_histogram=enabled -o feature@userobj_accounting=enabled -O acltype=posixacl -O canmount=off -O compression=lz4 -O devices=off -O normalization=formD -O relatime=on -O xattr=sa -O mountpoint=/ -R /mnt bpool mirror$bootmirror" -raidtype=`dialog --no-items --no-cancel --title "Root pool ZFS RAID" --radiolist "Select root pool ZFS RAID type" 11 35 4 raidz off raidz2 off mirror off none off 2>&1 1>/dev/tty` if [ "$raidtype" = "none" ]; then raidtype="" else