From 048ad22ea71e5380d58932fda6a4041a84d179ee Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Tue, 10 Mar 2020 23:17:12 +0100 Subject: [PATCH 1/3] Use $v_rpool_name/ROOT/debian for Debian --- hetzner-debian10-zfs-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hetzner-debian10-zfs-setup.sh b/hetzner-debian10-zfs-setup.sh index 4b4eeff..ba86bc9 100644 --- a/hetzner-debian10-zfs-setup.sh +++ b/hetzner-debian10-zfs-setup.sh @@ -547,8 +547,8 @@ echo -n "$v_passphrase" | zpool create \ zfs create -o canmount=off -o mountpoint=none "$v_rpool_name/ROOT" zfs create -o canmount=off -o mountpoint=none "$v_bpool_name/BOOT" -zfs create -o canmount=noauto -o mountpoint=/ "$v_rpool_name/ROOT/ubuntu" -zfs mount "$v_rpool_name/ROOT/ubuntu" +zfs create -o canmount=noauto -o mountpoint=/ "$v_rpool_name/ROOT/debian" +zfs mount "$v_rpool_name/ROOT/debian" zfs create -o canmount=noauto -o mountpoint=/boot "$v_bpool_name/BOOT/ubuntu" zfs mount "$v_bpool_name/BOOT/ubuntu" @@ -754,7 +754,7 @@ chroot_execute "grub-install ${v_selected_disks[0]}" chroot_execute "sed -i 's/#GRUB_TERMINAL=console/GRUB_TERMINAL=console/g' /etc/default/grub" chroot_execute "sed -i 's|GRUB_CMDLINE_LINUX_DEFAULT=.*|GRUB_CMDLINE_LINUX_DEFAULT=\"net.ifnames=0\"|' /etc/default/grub" -chroot_execute "sed -i 's|GRUB_CMDLINE_LINUX=\"\"|GRUB_CMDLINE_LINUX=\"root=ZFS=rpool/ROOT/ubuntu\"|g' /etc/default/grub" +chroot_execute "sed -i 's|GRUB_CMDLINE_LINUX=\"\"|GRUB_CMDLINE_LINUX=\"root=ZFS=rpool/ROOT/debian\"|g' /etc/default/grub" chroot_execute "sed -i 's/quiet//g' /etc/default/grub" chroot_execute "sed -i 's/splash//g' /etc/default/grub" From 27a6e93441c4db7b4a2fb58c6613036350eb6fc6 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Tue, 10 Mar 2020 23:17:31 +0100 Subject: [PATCH 2/3] Use `grep -q` instead of redirection --- hetzner-debian10-zfs-setup.sh | 4 ++-- hetzner-ubuntu18-zfs-setup.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hetzner-debian10-zfs-setup.sh b/hetzner-debian10-zfs-setup.sh index ba86bc9..e47aa7b 100644 --- a/hetzner-debian10-zfs-setup.sh +++ b/hetzner-debian10-zfs-setup.sh @@ -127,7 +127,7 @@ function check_prerequisites { echo "SSH pubkey file is absent, please add it to the rescue system setting, then reboot into rescue system and run the script" exit 1 fi - if ! dpkg-query --showformat="\${Status}" -W dialog 2> /dev/null | grep "install ok installed" &> /dev/null; then + if ! dpkg-query --showformat="\${Status}" -W dialog 2> /dev/null | grep -q "install ok installed"; then apt install --yes dialog fi } @@ -389,7 +389,7 @@ function ask_hostname { } function determine_kernel_variant { - if dmidecode | grep vServer 2>&1; then + if dmidecode | grep -q vServer; then v_kernel_variant="-cloud" fi } diff --git a/hetzner-ubuntu18-zfs-setup.sh b/hetzner-ubuntu18-zfs-setup.sh index 9b772b0..932909b 100644 --- a/hetzner-ubuntu18-zfs-setup.sh +++ b/hetzner-ubuntu18-zfs-setup.sh @@ -127,7 +127,7 @@ function check_prerequisites { echo "SSH pubkey file is absent, please add it to the rescue system setting, then reboot into rescue system and run the script" exit 1 fi - if ! dpkg-query --showformat="\${Status}" -W dialog 2> /dev/null | grep "install ok installed" &> /dev/null; then + if ! dpkg-query --showformat="\${Status}" -W dialog 2> /dev/null | grep -q "install ok installed"; then apt install --yes dialog fi } @@ -354,7 +354,7 @@ function ask_hostname { } function determine_kernel_variant { - if dmidecode | grep vServer 2>&1; then + if dmidecode | grep -q vServer; then v_kernel_variant="-virtual" fi } From 328fd85cdc393eaa85496aa5fedaa03d8615056d Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Tue, 10 Mar 2020 23:17:50 +0100 Subject: [PATCH 3/3] Fix installation for non-virtualized ubuntu hosts --- hetzner-debian10-zfs-setup.sh | 2 ++ hetzner-ubuntu18-zfs-setup.sh | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hetzner-debian10-zfs-setup.sh b/hetzner-debian10-zfs-setup.sh index e47aa7b..77ee1cb 100644 --- a/hetzner-debian10-zfs-setup.sh +++ b/hetzner-debian10-zfs-setup.sh @@ -479,6 +479,8 @@ ask_root_password ask_hostname +determine_kernel_variant + clear echo "===========remove unused kernels in rescue system=========" diff --git a/hetzner-ubuntu18-zfs-setup.sh b/hetzner-ubuntu18-zfs-setup.sh index 932909b..238ee92 100644 --- a/hetzner-ubuntu18-zfs-setup.sh +++ b/hetzner-ubuntu18-zfs-setup.sh @@ -356,6 +356,8 @@ function ask_hostname { function determine_kernel_variant { if dmidecode | grep -q vServer; then v_kernel_variant="-virtual" + else + v_kernel_variant="-generic" fi } @@ -444,6 +446,8 @@ ask_root_password ask_hostname +determine_kernel_variant + clear echo "===========remove unused kernels in rescue system=========" @@ -665,7 +669,12 @@ chroot_execute "rm -f /etc/localtime /etc/timezone" chroot_execute "dpkg-reconfigure tzdata -f noninteractive " echo "======= installing latest kernel=============" -chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-headers${v_kernel_variant}-hwe-18.04 linux-image${v_kernel_variant}-hwe-18.04 linux-image-extra${v_kernel_variant}-hwe-18.04" +chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-headers${v_kernel_variant}-hwe-18.04 linux-image${v_kernel_variant}-hwe-18.04" +if [[ $v_kernel_variant == "-virtual" ]]; then + # linux-image-extra is only available for virtual hosts + chroot_execute "DEBIAN_FRONTEND=noninteractive apt install --yes linux-image-extra-virtual-hwe-18.04" +fi + echo "======= installing aux packages ==========" chroot_execute "apt install --yes man wget curl software-properties-common nano htop gnupg"