Compare commits

6 Commits

7 changed files with 146 additions and 90 deletions

View File

@@ -7,7 +7,7 @@ The purpose of this branch is to modularize as many functions of the scripts as
## Checklist
[X] Rename all `base-` scripts to remove `base-`
[X] Move (at least almost) all Debian related commands and tasks to `debian.sh`
[ ] Move (at least almost) all Fedora related commands and tasks to `fedora.sh`
[X] Move (at least almost) all Fedora related commands and tasks to `fedora.sh`
[X] Move (at least almost) all elementary OS related commands and tasks to `elementary.sh`
[X] Rename flags in all distro specific scripts from numbered (i.e. `-1`, `-2`) to descriptive (i.e. `--mmdebstrap`, `--network-interfaces`)
[X] Move all EFI related commands and tasks to a new `efi.sh` script
@@ -15,4 +15,4 @@ The purpose of this branch is to modularize as many functions of the scripts as
[X] Point any distro-specific commands/tasks that are shared with Debian to use `debian.sh` to avoid any unnecessary duplication
[ ] Rewrite `README.md`
[X] Rename all script-specific variables to lowercase with singular capital letters to seperate words in variable name
[X] Update how `baseDir` is set using `realpath $(basedir "${0}")`
[X] Update how `baseDir` is set using `realpath $(dirname "${0}")`

View File

@@ -31,7 +31,9 @@ EOF
systemd-timesyncd \
whois \
zfsutils-linux
elif [[ "${1}" == '--mmdebstrap' ]]; then
fi
if [[ "${1}" == '--mmdebstrap' ]]; then
packages=(\
console-setup \
cryptsetup \
@@ -71,7 +73,9 @@ zstd\
${include} \
"${VERSION_CODENAME}" \
/mnt
elif [[ "${1}" == '--network-interfaces' ]]; then
fi
if [[ "${1}" == '--network-interfaces' ]]; then
networkInterface=($(ip -br addr show | sed 's| .*$||g' | grep -v '^lo' | grep -v 'tailscale' | grep -v '^wg'))
shopt -s extglob
@@ -81,7 +85,9 @@ allow-hotplug ${networkInterface[$i]}
iface ${networkInterface[$i]} inet dhcp
EOF
done
elif [[ "${1}" == '--sources' ]]; then
fi
if [[ "${1}" == '--sources' ]]; then
cat << EOF | tee /mnt/etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
# ${VERSION_CODENAME^}
Enabled: yes
@@ -109,7 +115,9 @@ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
rm /mnt/etc/apt/sources.list
elif [[ "${1}" == '--dpkg-reconfigure' ]]; then
fi
if [[ "${1}" == '--dpkg-reconfigure' ]]; then
cat << EOF
Regardless of the language(s) you choose, be sure to enable 'en_US.UTF-8'!
@@ -123,12 +131,16 @@ EOF
tzdata \
keyboard-configuration \
console-setup
elif [[ "${1}" == '--purge-os-prober' ]]; then
fi
if [[ "${1}" == '--purge-os-prober' ]]; then
apt \
purge \
--yes \
os-prober
elif [[ "${1}" == '--network-manager' ]]; then
fi
if [[ "${1}" == '--network-manager' ]]; then
cp \
/etc/NetworkManager/NetworkManager.conf \
/etc/NetworkManager/NetworkManager.conf.orig
@@ -137,7 +149,9 @@ elif [[ "${1}" == '--network-manager' ]]; then
/etc/NetworkManager/NetworkManager.conf.orig | \
sed 's|managed=false|managed=true|' | \
tee /etc/NetworkManager/NetworkManager.conf &> /dev/null
elif [[ "${1}" == '--contrib' ]]; then
fi
if [[ "${1}" == '--contrib' ]]; then
cat << EOF | tee --append /etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
# ${VERSION_CODENAME^} Backports
@@ -167,7 +181,9 @@ Pin: release n=${VERSION_CODENAME}-backports
Pin-Priority: -1
EOF
fi
elif [[ "${1}" == '--tasksel' ]]; then
fi
if [[ "${1}" == '--tasksel' ]]; then
if [[ ! -f /usr/bin/tasksel ]]; then
apt \
--update \
@@ -178,7 +194,9 @@ elif [[ "${1}" == '--tasksel' ]]; then
tasksel \
--new-install
elif [[ "${1}" == '--initramfs' ]]; then
fi
if [[ "${1}" == '--initramfs' ]]; then
printf \
"UMASK=0077\n" | \
tee /etc/initramfs-tools/conf.d/umask.conf &> /dev/null
@@ -186,13 +204,17 @@ elif [[ "${1}" == '--initramfs' ]]; then
update-initramfs \
-c \
-k all
elif [[ "${1}" == '--logrotate' ]]; then
fi
if [[ "${1}" == '--logrotate' ]]; then
for file in /etc/logrotate.d/* ; do
if grep -Eq "(^|[^#y])compress" "$file" ; then
sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
fi
done
elif [[ "${1}" == '--systemctl-enable' ]]; then
fi
if [[ "${1}" == '--systemctl-enable' ]]; then
systemctl \
enable \
zfs.target

View File

@@ -45,7 +45,9 @@ zstd\
${include} \
"${UBUNTU_VERSION_CODENAME}" \
/mnt
elif [[ "${1}" == '--sources' ]]; then
fi
if [[ "${1}" == '--sources' ]]; then
cat <<EOF >/mnt/etc/apt/sources.list.d/${UBUNTU_VERSION_CODENAME}.sources
# ${UBUNTU_VERSION_CODENAME^}
Enabled: yes
@@ -91,11 +93,15 @@ Signed-By: /etc/apt/trusted.gpg.d/patches.key.asc
EOF
rm /mnt/etc/apt/sources.list
elif [[ "${1}" == '--skel' ]]; then
fi
if [[ "${1}" == '--skel' ]]; then
rsync -pogAXtlHrDx \
/etc/skel \
/mnt/etc
elif [[ "${1}" == '--elementary' ]]; then
fi
if [[ "${1}" == '--elementary' ]]; then
cp \
/etc/os-release \
/mnt/etc
@@ -103,7 +109,9 @@ elif [[ "${1}" == '--elementary' ]]; then
cp \
/etc/apt/trusted.gpg.d/{elementary,patches}.key.asc \
/mnt/etc/apt/trusted.gpg.d/
elif [[ "${1}" == '--network' ]]; then
fi
if [[ "${1}" == '--network' ]]; then
mkdir \
-p \
/mnt/run/systemd/resolve/
@@ -115,7 +123,9 @@ elif [[ "${1}" == '--network' ]]; then
touch \
/mnt/etc/NetworkManager/conf.d/10-globally-managed-devices.conf
elif [[ "${1}" == '--apps' ]]; then
fi
if [[ "${1}" == '--apps' ]]; then
app=(\
io.elementary.calculator \
io.elementary.camera \
@@ -141,19 +151,25 @@ org.gnome.font-viewer\
appcenter \
-y \
${apps}
elif [[ "${1}" == '--purge' ]]; then
fi
if [[ "${1}" == '--purge' ]]; then
apt \
purge \
--yes \
--autoremove \
gnome-software \
snapd
elif [[ "${1}" == '--desktop' ]]; then
fi
if [[ "${1}" == '--desktop' ]]; then
apt \
install \
--yes \
elementary-desktop
elif [[ "${1}" == '--namarupa' ]]; then
fi
if [[ "${1}" == '--namarupa' ]]; then
curl \
--progress \
--location \

View File

@@ -35,7 +35,9 @@ if [[ "${1}" == '--live' ]]; then
modprobe \
zfs
elif [[ "${1}" == '--rsync' ]]; then
fi
if [[ "${1}" == '--rsync' ]]; then
mkdir -p /run/install
if [[ "${VERSION_ID}" -lt '41' ]]; then
@@ -50,15 +52,77 @@ elif [[ "${1}" == '--rsync' ]]; then
--exclude=/etc/machine-id \
--info=progress2 \
/run/install/ /mnt
elif [[ "${1}" == '--resolv-conf' ]]; then
fi
if [[ "${1}" == '--resolv-conf' ]]; then
mv /mnt/etc/resolv.conf \
/mnt/etc/resolv.conf.orig
cp -L \
/etc/resolv.conf \
/mnt/etc
elif [[ "${1}" == '--dracut' ]]; then
fi
if [[ "${1}" == '--dracut' ]]; then
dracut \
--force \
--regenerate-all
fi
if [[ "${1}" == '--zfs-install' ]]; 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

View File

@@ -1,7 +1,7 @@
#!/bin/bash
set -euo pipefail
baseDir="$(dirname "${0}" | sed "s|^\.|${PWD}|")"
baseDir="$(realpath "$(dirname "${0}")")"
printf \
'\033[?47l\012'
@@ -35,61 +35,7 @@ if [[ ! -f "/etc/mtab" ]]; then
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
"${baseDir}/fedora.sh" --zfs-install
fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then

View File

@@ -98,11 +98,9 @@ if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/elementary.sh" --skel
fi
# if [[ ! "${*}" = *--no-part* ]]; then
if [[ -f "/etc/zfs/keys/${hostname,,}.key" ]]; then
"${baseDir}/zfs.sh" --key
fi
# fi
if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/elementary.sh" --elementary

20
zfs.sh
View File

@@ -219,7 +219,9 @@ if [[ "${1}" == '--key' ]]; then
cp \
/etc/zfs/keys/${hostname,,}.key \
/mnt/etc/zfs/keys/
elif [[ "${1}" == '--unmount' ]]; then
fi
if [[ "${1}" == '--unmount' ]]; then
mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | xargs -I {} umount -Rlf {}
if [[ "${ID}" == 'fedora' ]]; then
@@ -231,11 +233,15 @@ elif [[ "${1}" == '--unmount' ]]; then
zpool \
export \
-a
elif [[ "${1}" == '--host-id' ]]; then
fi
if [[ "${1}" == '--host-id' ]]; then
zgenhostid \
-f \
0x00bab10c
elif [[ "${1}" == '--home' ]]; then
fi
if [[ "${1}" == '--home' ]]; then
zfs create\
${hostname,,}/home/${username}
@@ -259,12 +265,16 @@ elif [[ "${1}" == '--home' ]]; then
zfs create\
${hostname,,}/home/${username}/.local/share/flatpak
elif [[ "${1}" == '--keystore' ]]; then
fi
if [[ "${1}" == '--keystore' ]]; then
zfs \
set \
org.zfsbootmenu:keysource=${hostname,,}/keystore \
${hostname,,}
elif [[ "${1}" == '--splash' ]]; then
fi
if [[ "${1}" == '--splash' ]]; then
zfs \
set \
org.zfsbootmenu:commandline='quiet splash rhgb noresume' \