#!/bin/bash set -euo pipefail BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" printf \ '\033[?47l\012' cat << EOF ####################################### ## ## ## $(cat "${BASEDIR}/title") Script ## ## ## ## Jean ## ## ## ####################################### ############### ## ## ## Install ## ## ## ############### EOF source \ /etc/os-release source \ "${BASEDIR}/system.conf" if [[ ! "${DISK}" == **/dev/disk/by-id/** ]]; then if [[ "${DISK}" == **/dev/nvme** ]]; then PART1='p1' PART2='p2' else PART1='1' PART2='2' fi else PART1='-part1' PART2='-part2' fi if [[ ! -f "/etc/mtab" ]]; then ln \ -s \ /proc/self/mounts \ /etc/mtab fi if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then apt \ update fi if [[ "${ID}" == 'fedora' ]]; then if [[ "${ENCRYPTION}" == 'yes' ]]; then cat << EOF | tee /etc/dracut.conf.d/zol.conf &> /dev/null nofsck="yes" add_dracutmodules+=" zfs " omit_dracutmodules+=" btrfs " install_items+=" /etc/zfs/keys/${HOSTNAME,,}.key " EOF else cat </etc/dracut.conf.d/zol.conf nofsck="yes" add_dracutmodules+=" zfs " omit_dracutmodules+=" btrfs " EOF fi fi if [[ "${ID}" == 'elementary' ]]; then apt \ install \ --yes \ --no-install-recommends \ console-setup \ cryptsetup \ curl \ dpkg-dev \ efibootmgr \ ethtool \ flatpak \ keyboard-configuration \ linux-generic \ locales \ nano \ network-manager \ openssh-{client,server} \ popularity-contest elif [[ "${ID}" == 'debian' ]]; then apt \ install \ --yes \ console-setup \ cryptsetup \ curl \ dpkg-dev \ efibootmgr \ ethtool \ firmware-{ast,atheros,bnx{2,2x},brcm80211,ipw2x00,iwlwifi,libertas,linux,realtek,zd1211} \ flatpak \ keyboard-configuration \ linux-{headers,image}-amd64 \ locales \ nano \ network-manager \ openssh-{client,server} \ popularity-contest \ printer-driver-all \ tasksel elif [[ "${ID}" == 'fedora' ]]; then if [[ "${VERSION_ID}" -lt '41' ]]; then dnf \ config-manager \ --disable \ updates else dnf \ config-manager \ setopt \ updates.enabled=0 fi dnf \ install \ -y \ https://dl.fedoraproject.org/pub/fedora/linux/releases/${VERSION_ID}/Everything/x86_64/os/Packages/k/kernel-devel-$(uname -r).rpm dnf \ --releasever=${VERSION_ID} \ install \ -y \ https://zfsonlinux.org/fedora/zfs-release-${ZOL_FEDORA_VER}$(rpm --eval "%{dist}").noarch.rpm dnf \ install \ -y \ zfs \ zfs-dracut if [[ "${VERSION_ID}" -lt '41' ]]; then dnf \ config-manager \ --enable \ updates else dnf \ config-manager \ setopt \ updates.enabled=1 fi fi if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then cat << EOF Regardless of the language(s) you choose, be sure to enable 'en_US.UTF-8'! Press any key to continue... EOF read -srn 1 dpkg-reconfigure \ locales \ tzdata \ keyboard-configuration \ console-setup apt install \ --yes \ dosfstools \ systemd-timesyncd \ zfs-initramfs fi if [[ "${ID}" == 'debian' ]]; then printf \ 'REMAKE_INITRD=yes\n' | \ tee /etc/dkms/zfs.conf &> /dev/null fi if [[ ! "${*}" = *--no-part* ]]; then mkdosfs \ -F 32 \ -s 1 \ -n EFI \ ${DISK}${PART1} fi mkdir \ -p \ /boot/efi printf \ "/dev/disk/by-uuid/$(blkid -s UUID -o value ${DISK}${PART1}) /boot/efi vfat defaults 0 0\n" | \ tee --append /etc/fstab &> /dev/null sleep 5 mount \ /boot/efi if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then apt \ purge \ --yes \ os-prober fi printf \ '\033[?47h\033[2J\033[H' cat << EOF Enter a password for the root account: EOF passwd printf \ '\033[?47l' if [[ "${ENABLE_SWAP}" == "yes" ]]; then printf \ "swap\t${DISK}${PART2}\t/dev/random\tswap,cipher=aes-xts-plain64,size=512\n" | \ tee /etc/crypttab &> /dev/null printf \ 'dev/mapper/swap\tnone\tswap\tsw\t0\t0\n' | \ tee --append /etc/fstab &> /dev/null fi if [[ "${ID}" == 'debian' ]]; then cp \ /etc/NetworkManager/NetworkManager.conf \ /etc/NetworkManager/NetworkManager.conf.orig cat \ /etc/NetworkManager/NetworkManager.conf.orig | \ sed 's|managed=false|managed=true|' | \ tee /etc/NetworkManager/NetworkManager.conf &> /dev/null fi if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then printf \ "UMASK=0077\n" | \ tee /etc/initramfs-tools/conf.d/umask.conf &> /dev/null update-initramfs \ -c \ -k all elif [[ "${ID}" == 'fedora' ]]; then dracut \ --force \ --regenerate-all fi zfs \ set \ org.zfsbootmenu:commandline='quiet splash rhgb noresume' \ ${HOSTNAME,,}/ROOT/${ID} if [[ ! "${*}" = *--no-part* ]]; then if [[ ! -z "$(zfs list | grep 'keystore')" ]]; then zfs \ set \ org.zfsbootmenu:keysource=${HOSTNAME,,}/keystore \ ${HOSTNAME,,} fi fi if [[ ! "${*}" = *--no-part* ]]; then mkdir \ -p \ /boot/efi/EFI/ZBM mkdir \ -p \ /boot/efi/EFI/BOOT curl \ --progress-bar \ --show-error \ --output \ /boot/efi/EFI/ZBM/VMLINUZ.EFI \ --location \ https://get.zfsbootmenu.org/efi cp \ /boot/efi/EFI/ZBM/VMLINUZ.EFI \ /boot/efi/EFI/ZBM/VMLINUZ-BACKUP.EFI cp \ /boot/efi/EFI/ZBM/VMLINUZ.EFI \ /boot/efi/EFI/BOOT/BOOTX64.EFI cp \ /boot/efi/EFI/ZBM/VMLINUZ.EFI \ /boot/efi/EFI/BOOT/shellx64.efi efibootmgr \ -c \ -d "${DISK}" \ -p '1' \ -L 'ZFSBootMenu (Backup)' \ -l '\EFI\ZBM\VMLINUZ-BACKUP.EFI' efibootmgr \ -c \ -d "${DISK}" \ -p '1' \ -L 'ZFSBootMenu' \ -l '\EFI\ZBM\VMLINUZ.EFI' fi if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then systemctl \ enable \ zfs.target systemctl \ enable \ zfs-import-cache systemctl \ enable \ zfs-mount systemctl \ enable \ zfs-import.target fi zfs \ snapshot \ ${HOSTNAME,,}/ROOT/${ID}@install "${BASEDIR}/post-inst.sh"