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 ## Checklist
[X] Rename all `base-` scripts to remove `base-` [X] Rename all `base-` scripts to remove `base-`
[X] Move (at least almost) all Debian related commands and tasks to `debian.sh` [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] 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] 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 [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 [X] Point any distro-specific commands/tasks that are shared with Debian to use `debian.sh` to avoid any unnecessary duplication
[ ] Rewrite `README.md` [ ] Rewrite `README.md`
[X] Rename all script-specific variables to lowercase with singular capital letters to seperate words in variable name [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 \ systemd-timesyncd \
whois \ whois \
zfsutils-linux zfsutils-linux
elif [[ "${1}" == '--mmdebstrap' ]]; then fi
if [[ "${1}" == '--mmdebstrap' ]]; then
packages=(\ packages=(\
console-setup \ console-setup \
cryptsetup \ cryptsetup \
@@ -71,7 +73,9 @@ zstd\
${include} \ ${include} \
"${VERSION_CODENAME}" \ "${VERSION_CODENAME}" \
/mnt /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')) networkInterface=($(ip -br addr show | sed 's| .*$||g' | grep -v '^lo' | grep -v 'tailscale' | grep -v '^wg'))
shopt -s extglob shopt -s extglob
@@ -81,7 +85,9 @@ allow-hotplug ${networkInterface[$i]}
iface ${networkInterface[$i]} inet dhcp iface ${networkInterface[$i]} inet dhcp
EOF EOF
done done
elif [[ "${1}" == '--sources' ]]; then fi
if [[ "${1}" == '--sources' ]]; then
cat << EOF | tee /mnt/etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null cat << EOF | tee /mnt/etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
# ${VERSION_CODENAME^} # ${VERSION_CODENAME^}
Enabled: yes Enabled: yes
@@ -109,7 +115,9 @@ Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF EOF
rm /mnt/etc/apt/sources.list rm /mnt/etc/apt/sources.list
elif [[ "${1}" == '--dpkg-reconfigure' ]]; then fi
if [[ "${1}" == '--dpkg-reconfigure' ]]; then
cat << EOF cat << EOF
Regardless of the language(s) you choose, be sure to enable 'en_US.UTF-8'! Regardless of the language(s) you choose, be sure to enable 'en_US.UTF-8'!
@@ -123,12 +131,16 @@ EOF
tzdata \ tzdata \
keyboard-configuration \ keyboard-configuration \
console-setup console-setup
elif [[ "${1}" == '--purge-os-prober' ]]; then fi
if [[ "${1}" == '--purge-os-prober' ]]; then
apt \ apt \
purge \ purge \
--yes \ --yes \
os-prober os-prober
elif [[ "${1}" == '--network-manager' ]]; then fi
if [[ "${1}" == '--network-manager' ]]; then
cp \ cp \
/etc/NetworkManager/NetworkManager.conf \ /etc/NetworkManager/NetworkManager.conf \
/etc/NetworkManager/NetworkManager.conf.orig /etc/NetworkManager/NetworkManager.conf.orig
@@ -137,7 +149,9 @@ elif [[ "${1}" == '--network-manager' ]]; then
/etc/NetworkManager/NetworkManager.conf.orig | \ /etc/NetworkManager/NetworkManager.conf.orig | \
sed 's|managed=false|managed=true|' | \ sed 's|managed=false|managed=true|' | \
tee /etc/NetworkManager/NetworkManager.conf &> /dev/null 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 cat << EOF | tee --append /etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
# ${VERSION_CODENAME^} Backports # ${VERSION_CODENAME^} Backports
@@ -167,7 +181,9 @@ Pin: release n=${VERSION_CODENAME}-backports
Pin-Priority: -1 Pin-Priority: -1
EOF EOF
fi fi
elif [[ "${1}" == '--tasksel' ]]; then fi
if [[ "${1}" == '--tasksel' ]]; then
if [[ ! -f /usr/bin/tasksel ]]; then if [[ ! -f /usr/bin/tasksel ]]; then
apt \ apt \
--update \ --update \
@@ -178,7 +194,9 @@ elif [[ "${1}" == '--tasksel' ]]; then
tasksel \ tasksel \
--new-install --new-install
elif [[ "${1}" == '--initramfs' ]]; then fi
if [[ "${1}" == '--initramfs' ]]; then
printf \ printf \
"UMASK=0077\n" | \ "UMASK=0077\n" | \
tee /etc/initramfs-tools/conf.d/umask.conf &> /dev/null tee /etc/initramfs-tools/conf.d/umask.conf &> /dev/null
@@ -186,13 +204,17 @@ elif [[ "${1}" == '--initramfs' ]]; then
update-initramfs \ update-initramfs \
-c \ -c \
-k all -k all
elif [[ "${1}" == '--logrotate' ]]; then fi
if [[ "${1}" == '--logrotate' ]]; then
for file in /etc/logrotate.d/* ; do for file in /etc/logrotate.d/* ; do
if grep -Eq "(^|[^#y])compress" "$file" ; then if grep -Eq "(^|[^#y])compress" "$file" ; then
sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file" sed -i -r "s/(^|[^#y])(compress)/\1#\2/" "$file"
fi fi
done done
elif [[ "${1}" == '--systemctl-enable' ]]; then fi
if [[ "${1}" == '--systemctl-enable' ]]; then
systemctl \ systemctl \
enable \ enable \
zfs.target zfs.target

View File

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

View File

@@ -35,7 +35,9 @@ if [[ "${1}" == '--live' ]]; then
modprobe \ modprobe \
zfs zfs
elif [[ "${1}" == '--rsync' ]]; then fi
if [[ "${1}" == '--rsync' ]]; then
mkdir -p /run/install mkdir -p /run/install
if [[ "${VERSION_ID}" -lt '41' ]]; then if [[ "${VERSION_ID}" -lt '41' ]]; then
@@ -50,15 +52,77 @@ elif [[ "${1}" == '--rsync' ]]; then
--exclude=/etc/machine-id \ --exclude=/etc/machine-id \
--info=progress2 \ --info=progress2 \
/run/install/ /mnt /run/install/ /mnt
elif [[ "${1}" == '--resolv-conf' ]]; then fi
if [[ "${1}" == '--resolv-conf' ]]; then
mv /mnt/etc/resolv.conf \ mv /mnt/etc/resolv.conf \
/mnt/etc/resolv.conf.orig /mnt/etc/resolv.conf.orig
cp -L \ cp -L \
/etc/resolv.conf \ /etc/resolv.conf \
/mnt/etc /mnt/etc
elif [[ "${1}" == '--dracut' ]]; then fi
if [[ "${1}" == '--dracut' ]]; then
dracut \ dracut \
--force \ --force \
--regenerate-all --regenerate-all
fi 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 #!/bin/bash
set -euo pipefail set -euo pipefail
baseDir="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
printf \ printf \
'\033[?47l\012' '\033[?47l\012'
@@ -35,61 +35,7 @@ if [[ ! -f "/etc/mtab" ]]; then
fi fi
if [[ "${ID}" == 'fedora' ]]; then if [[ "${ID}" == 'fedora' ]]; then
if [[ "${encryption}" == 'yes' ]]; then "${baseDir}/fedora.sh" --zfs-install
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 fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then

View File

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

20
zfs.sh
View File

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