test
sean 7 years ago
parent b75109612f
commit def54b1a4f

@ -29,12 +29,12 @@ window=$((height - 5))
devices=""; for device in $(ls /dev/disk/by-id | grep -v part); do devices="$devices $device off"; done 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` 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" 12 35 5 raidz off raidz2 off raidz3 off mirror off none off 2>&1 1>/dev/tty` 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 "Host name/Server name" 8 100 2>&1 >/dev/tty`; done hostname=""; while [ -z "$hostname" ]; do hostname=`dialog --no-cancel --inputbox "Host name/Server name" 8 30 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 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` 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`
admin=""; while [ -z "$admin" ]; do admin=`dialog --no-cancel --inputbox "Admin account/first user (with sudo capability)" 8 100 2>&1 >/dev/tty`; done admin=""; while [ -z "$admin" ]; do admin=`dialog --no-cancel --inputbox "Admin account/first user (with sudo capability)" 8 30 2>&1 >/dev/tty`; done
rootpassword=`dialog --no-cancel --title "Root password" --insecure --passwordbox "Enter root password" 10 30 2>&1 1>/dev/tty` rootpassword=`dialog --no-cancel --title "Root password" --insecure --passwordbox "Enter root password" 8 30 2>&1 1>/dev/tty`
confirmpassword=`dialog --no-cancel --title "Root password confirmation" --insecure --passwordbox "Re-enter root password" 10 30 2>&1 1>/dev/tty` confirmpassword=`dialog --no-cancel --title "Root password confirmation" --insecure --passwordbox "Re-enter root password" 8 30 2>&1 1>/dev/tty`
if ! [ "$rootpassword" = "$confirmpassword" ]; then if ! [ "$rootpassword" = "$confirmpassword" ]; then
echo "Password does not match confirmation - please retry the setup" echo "Password does not match confirmation - please retry the setup"
exit 10 exit 10
@ -58,6 +58,15 @@ bootmirror=""; rootraidz=""; for disk in `echo "$disks"`; do bootmirror="$bootmi
# refresh drives or there are missing partitions # refresh drives or there are missing partitions
partprobe 2>/dev/null 1>/dev/null partprobe 2>/dev/null 1>/dev/null
# wait for the partitions to show up
for disk in `echo "$disks"`
do
while ! [ -e "/dev/disk/by-id/${disk}-part3" ]; do
partprobe 2>/dev/null 1>/dev/null
sleep 1
done
done
echo "" echo ""
echo "Creating boot zpool..." echo "Creating boot zpool..."
errors=`zpool create -f -o ashift=12 -d -o feature@async_destroy=enabled -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 2>&1 1>/dev/null` errors=`zpool create -f -o ashift=12 -d -o feature@async_destroy=enabled -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 2>&1 1>/dev/null`
@ -216,26 +225,34 @@ echo "echo \"Done.\""
echo "echo \"\"" echo "echo \"\""
echo "echo \"Installing linux image, bash, screen, tmux, zfs, dosfstools, openssh...\"" echo "echo \"Installing linux image, bash, screen, tmux, zfs, dosfstools, openssh...\""
echo 'errors=`apt install -y --no-install-recommends linux-image-generic 2>&1 1>/dev/null && apt install -y vim bash screen tmux zfs-initramfs dosfstools openssh-server 2>&1 1>/dev/null`' >> /mnt/setup-chroot.sh echo "errors=\$(apt install -y --no-install-recommends linux-image-generic 2\>\&1 1\>/dev/null \&\& apt install -y vim bash screen tmux zfs-initramfs dosfstools openssh-server 2\>\&1 1\>/dev/null)" >> /mnt/setup-chroot.sh
echo 'if ! [ "$?" = "0" ]; then '>> /mnt/setup-chroot.sh echo 'if ! [ "$?" = "0" ]; then '>> /mnt/setup-chroot.sh
echo ' echo "Failed to install preliminary software - $errors"' >> /mnt/setup-chroot.sh echo ' echo "Failed to install preliminary software - $errors"' >> /mnt/setup-chroot.sh
echo " exit 1">> /mnt/setup-chroot.sh echo " exit 1">> /mnt/setup-chroot.sh
echo "fi">> /mnt/setup-chroot.sh echo "fi">> /mnt/setup-chroot.sh
echo "echo \"Done.\"" >> /mnt/setup-chroot.sh echo "echo \"Done.\"" >> /mnt/setup-chroot.sh
echo 'echo ""' >> /mnt/setup-chroot.sh
echo 'echo "Creating EFI partition..."' >> /mnt/setup-chroot.sh
firstdisk=`echo "$disks" | head -n1` firstdisk=`echo "$disks" | head -n1`
echo "mkdosfs -F 32 -s 1 -n EFI /dev/disk/by-id/${firstdisk}-part2" >> /mnt/setup-chroot.sh echo "mkdosfs -F 32 -s 1 -n EFI /dev/disk/by-id/${firstdisk}-part2" >> /mnt/setup-chroot.sh
echo "mkdir /boot/efi" >> /mnt/setup-chroot.sh echo "mkdir /boot/efi" >> /mnt/setup-chroot.sh
echo "echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-id/${firstdisk}-part2) /boot/efi vfat nofail,x-systemd.device-timeout=0 0 1 >> /etc/fstab" >> /mnt/setup-chroot.sh echo "echo PARTUUID=$(blkid -s PARTUUID -o value /dev/disk/by-id/${firstdisk}-part2) /boot/efi vfat nofail,x-systemd.device-timeout=0 0 1 >> /etc/fstab" >> /mnt/setup-chroot.sh
echo "mount /boot/efi" >> /mnt/setup-chroot.sh echo "mount /boot/efi" >> /mnt/setup-chroot.sh
echo "apt install -y grub-efi-amd64-signed shim-signed" >> /mnt/setup-chroot.sh echo "apt install -y grub-efi-amd64-signed shim-signed" >> /mnt/setup-chroot.sh
echo 'echo "Done..."' >> /mnt/setup-chroot.sh
i="2" if ! [ "$disks" = "" ]; then
for disk in `echo "$disks" | tail -n+2`; do echo 'echo ""' >> /mnt/setup-chroot.sh
echo 'echo "Copying EFI partition to other boot disks..."' >> /mnt/setup-chroot.sh
i="2"
for disk in `echo "$disks" | tail -n+2`; do
echo "dd if=/dev/disk/by-id/${firstdisk}-part2 of=/dev/disk/by-id/${disk}-part2" >> /mnt/setup-chroot.sh echo "dd if=/dev/disk/by-id/${firstdisk}-part2 of=/dev/disk/by-id/${disk}-part2" >> /mnt/setup-chroot.sh
echo "efibootmgr -c -g -d /dev/disk/by-id/${disk} -p 3 -L "ubuntu-$i" -l '\EFI\ubuntu\grubx64.efi'" >> /mnt/setup-chroot.sh echo "efibootmgr -c -g -d /dev/disk/by-id/${disk} -p 3 -L "ubuntu-$i" -l '\EFI\ubuntu\grubx64.efi'" >> /mnt/setup-chroot.sh
i=$((i + 1)) i=$((i + 1))
done done
echo 'echo "Done."' >> /mnt/setup-chroot.sh
fi
echo "echo 'root:${rootpassword}' | chpasswd" >> /mnt/setup-chroot.sh echo "echo 'root:${rootpassword}' | chpasswd" >> /mnt/setup-chroot.sh

Loading…
Cancel
Save