Files
ZFSBootMenu-Root-Install/install.sh

172 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
baseDir="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
printf \
'\033[?47l\012'
cat << EOF
#######################################
## ##
## $(cat "${baseDir}/title") Script ##
## ##
## Jean <jean@easthighnerd.net> ##
## ##
#######################################
###############
## ##
## Install ##
## ##
###############
EOF
source \
/etc/os-release
source \
"${baseDir}/system.conf"
if [[ ! -f "/etc/mtab" ]]; then
"${baseDir}/mtab.sh"
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 <<EOF >/etc/dracut.conf.d/zol.conf
nofsck="yes"
add_dracutmodules+=" zfs "
omit_dracutmodules+=" btrfs "
EOF
fi
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
"${baseDir}/debian.sh" --dpkg-reconfigure
fi
"${baseDir}/partition.sh" --efi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/debian.sh" --purge-os-prober
fi
if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/elementary.sh" --desktop
"${baseDir}/elementary.sh" --purge
"${baseDir}/elementary.sh" --apps
fi
printf \
'\033[?47h\033[2J\033[H'
cat << EOF
Enter a password for the root account:
EOF
passwd
printf \
'\033[?47l'
"${baseDir}/swap.sh"
if [[ "${ID}" == 'debian' ]]; then
"${baseDir}/debian.sh" --network-manager
fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/debian.sh" --initramfs
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
"${baseDir}/efi.sh"
fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/debian.sh" --systemctl-enable
fi
zfs \
snapshot \
${hostname,,}/ROOT/${ID}@install
"${baseDir}/post-inst.sh"