Broke out differnt sections of the 'partition.sh' script into seperate scripts, called on by a new 'pre-inst.sh' script

This commit is contained in:
2025-07-21 13:11:35 -04:00
parent 7442994d18
commit 62861d8c7b
7 changed files with 691 additions and 597 deletions

220
pre-inst.sh Executable file
View File

@@ -0,0 +1,220 @@
#!/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> ##
## ##
#######################################
####################
## ##
## Pre ##
## Installation ##
## ##
####################
EOF
source \
/etc/os-release
source \
"${BASEDIR}/system.conf"
if [[ "${ID}" == 'debian' ]]; then
if [[ ! "$(hostname)" == "debian-live" ]]; then
cat << EOF | tee /etc/apt/sources.list.d/contrib.sources 1> /dev/null
Enabled: yes
Types: deb
URIs: http://deb.debian.org/debian/
Suites: ${VERSION_CODENAME}
Components: contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
fi
fi
if [[ -f '/usr/bin/gsettings' ]]; then
gsettings \
set \
org.gnome.desktop.media-handling \
automount \
false
fi
if [[ "${ID}" == 'debian' ]]; then
apt \
update && \
apt \
install \
--yes \
mmdebstrap \
gdisk \
zfsutils-linux \
systemd-timesyncd
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://zfsonlinux.org/fedora/zfs-release-${ZOL_FEDORA_VER}$(rpm --eval "%{dist}").noarch.rpm
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 install \
-y \
zfs \
gdisk
modprobe \
zfs
fi
timedatectl
if [[ ! "$(hostname)" == "debian-live" ]]; then
zgenhostid \
-f \
0x00bab10c
fi
"${BASEDIR}/partition.sh"
sleep 5
"${BASEDIR}/mkfs.zfs.sh"
mkdir \
-p \
/mnt/run
mount \
-t \
tmpfs \
tmpfs \
/mnt/run
mkdir \
-p \
/mnt/run/lock
if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -1
elif [[ "${ID}" == 'debian' ]]; then
"${BASEDIR}/base-debian.sh" -1
fi
printf \
"${HOSTNAME}\n" | tee /mnt/etc/hostname &> /dev/null
printf \
"127.0.1.1\t${HOSTNAME}\n" | tee --append /mnt/etc/hosts &> /dev/null
if [[ "${ID}" == 'debian' ]]; then
"${BASEDIR}/base-debian.sh" -2
fi
if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -2
elif [[ "${ID}" == 'debian' ]]; then
"${BASEDIR}/base-debian.sh" -3
fi
mount \
--rbind \
/dev \
/mnt/dev
mount \
--rbind \
/proc \
/mnt/proc
mount \
--rbind \
/sys \
/mnt/sys
cp \
/etc/hostid \
/mnt/etc/
if [[ "${ID}" == 'fedora' ]]; then
"${BASEDIR}/base-fedora.sh" -2
fi
rsync -pogAXtlHrDx \
"${BASEDIR}" \
/mnt
if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -3
fi
# if [[ ! "${*}" = *--no-part* ]]; then
if [[ -f "/etc/zfs/keys/${HOSTNAME,,}.key" ]]; then
cp \
/etc/zfs/keys/${HOSTNAME,,}.key \
/mnt/etc/zfs/keys/
fi
# fi
if [[ "${ID}" == 'elementary' ]]; then
"${BASEDIR}/base-elementary.sh" -4
fi
printf \
"\nNow chrooting into /mnt...\n\n"
chroot \
/mnt \
bash \
--login
mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | xargs -I {} umount -Rlf {}
if [[ "${ID}" == 'fedora' ]]; then
umount \
-nR \
/mnt
fi
zpool \
export \
-a
printf \
'\033[?47h\033[2J\033[H'
cat <<EOF
Script has finished running
Please reboot your computer
Press any key to return to the main menu
EOF
read -srn 1