Compare commits

16 Commits

Author SHA1 Message Date
568c80a05e Commented out (should be) depricated part of setup process 2025-12-24 16:38:08 -05:00
00fe875b44 Removed unneeded double check if 'ID' = 'fedora' 2025-12-24 16:37:13 -05:00
8414563171 Split off ZFS-relatesd tasks into 'zfs.sh' 2025-12-24 16:36:33 -05:00
30b3b58336 Split off creating/formatting EFI partition into 'partition.sh' 2025-12-24 16:35:53 -05:00
3e4eeb7d37 Split off more Fedora-related tasks into 'fedora.sh' 2025-12-24 16:34:29 -05:00
8305fa16cd Split off more Debian-related tasks into 'debian.sh' 2025-12-24 16:32:44 -05:00
16018759fb Split off rsyncing folder of scripts to seperate script 2025-12-24 16:29:35 -05:00
2028fa4396 Split off rbinding operations 2025-12-24 16:28:55 -05:00
637f5b69db Split off mtab related activities 2025-12-24 16:28:18 -05:00
3902f873e9 Split off creating tmpfs directories 2025-12-24 16:27:28 -05:00
8bca55e467 Split off setting hostname 2025-12-24 16:26:47 -05:00
377d56b1cd Split off copying of hostid file 2025-12-24 16:25:49 -05:00
9c8add89e5 Updated variable names and casing 2025-12-24 16:22:32 -05:00
648d07f355 Split off creating and setting up 'home-fix.sh' 2025-12-24 16:14:33 -05:00
f44f7464b9 Split chroot operation into seperate script 2025-12-24 16:12:47 -05:00
ec2d8148e0 Split chroot operation into seperate script 2025-12-24 16:11:14 -05:00
15 changed files with 453 additions and 371 deletions

17
chroot.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
printf \
"\nNow chrooting into /mnt...\n\n"
if [[ "${*}" == *--continue* ]]; then
chroot \
/mnt \
"$(printf "${baseDir}\n" | sed 's|.*\/|\/|')/install.sh"
else
chroot \
/mnt
fi

View File

@@ -9,7 +9,28 @@ source \
"${baseDir}/system.conf" "${baseDir}/system.conf"
if [[ "${1}" == '--mmdebstrap' ]]; then if [[ "${1}" == '--live' ]]; 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
apt \
--update \
install \
--yes \
mmdebstrap \
gdisk \
systemd-timesyncd \
whois \
zfsutils-linux
elif [[ "${1}" == '--mmdebstrap' ]]; then
packages=(\ packages=(\
console-setup \ console-setup \
cryptsetup \ cryptsetup \
@@ -86,4 +107,73 @@ 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
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
elif [[ "${1}" == '--purge-os-prober' ]]; then
apt \
purge \
--yes \
os-prober
elif [[ "${1}" == '--network-manager' ]]; 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
elif [[ "${1}" == '--contrib' ]]; then
cat << EOF | tee --append /etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null
# ${VERSION_CODENAME^} Backports
Enabled: yes
Types: deb deb-src
URIs: http://deb.debian.org/debian/
Suites: ${VERSION_CODENAME}-backports
Components: main non-free-firmware contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
cat << EOF | tee /etc/apt/preferences.d/backports.pref &> /dev/null
Package: *
Pin: release n=${VERSION_CODENAME}*
Pin-Priority: 990
Package: linux-*
Pin: release n=${VERSION_CODENAME}-backports
Pin-Priority: -1
EOF
if [[ "${VERSION_CODENAME}" == 'bookworm' ]]; then
cat << EOF | tee --append /etc/apt/preferences.d/backports.pref &> /dev/null
Package: /wayland/
Pin: release n=${VERSION_CODENAME}-backports
Pin-Priority: -1
EOF
fi
elif [[ "${1}" == '--tasksel' ]]; then
if [[ ! -f /usr/bin/tasksel ]]; then
apt \
--update \
install \
--yes \
tasksel
fi
tasksel \
--new-install
fi fi

View File

@@ -9,7 +9,33 @@ source \
"${baseDir}/system.conf" "${baseDir}/system.conf"
if [[ "${1}" == '--rsync' ]]; then if [[ "${1}" == '--live' ]]; 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-${zolFedoraVer}$(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
elif [[ "${1}" == '--rsync' ]]; then
mkdir -p /run/install mkdir -p /run/install
if [[ "${VERSION_ID}" -lt '41' ]]; then if [[ "${VERSION_ID}" -lt '41' ]]; then

59
home-fix-setup.sh Normal file
View File

@@ -0,0 +1,59 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
source \
/etc/os-release
source \
"${baseDir}/system.conf"
cat << EOF | tee /usr/bin/home-fix.sh &> /dev/null
#!/bin/bash
set -euo pipefail
chown -R ${username}:${username} /home/${username}
sudo -u ${username} cp -a /etc/skel/. /home/${username}
if [[ ! -z "\$(find -P /home/${username}/ | grep '\.face')" ]]; then
find -P /home/${username}/ | grep '\.face' | xargs -d '\n' -I {} rm {}
fi
if [[ ! -z "\$(find -P /var/spool/cron | grep 'root')" ]]; then
rm \$(find -P /var/spool/cron | grep 'root')
fi
printf "\$(date +%Y-%m-%d\ %H:%M:%S) I did the thing\n" | tee /var/log/home-fix.log &> /dev/null
if [[ -f '/usr/bin/home-fix.sh' ]]; then
rm /usr/bin/home-fix.sh
fi
zfs snapshot ${hostname,,}/ROOT/${ID}@home-fix
zfs snapshot -r ${hostname,,}/home/${username}@home-fix
EOF
chmod \
+x \
/usr/bin/home-fix.sh
if [[ "${ID}" == 'fedora' ]]; then
printf \
"@reboot\tsudo -u ${username} '${baseDir}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \
tee /var/spool/cron/root &> /dev/null
elif [[ "${ID}" == 'debian' ]]; then
printf \
"@reboot\tsudo -u ${username} '${baseDir}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \
tee /var/spool/cron/crontabs/root &> /dev/null
chown \
:crontab \
/var/spool/cron/crontabs/root
chmod \
0600 \
/var/spool/cron/crontabs/root
fi

7
host-id.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
cp \
/etc/hostid \
/mnt/etc/

9
hostname.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail
printf \
"${hostname}\n" | tee /mnt/etc/hostname &> /dev/null
printf \
"127.0.1.1\t${hostname}\n" | tee --append /mnt/etc/hosts &> /dev/null

View File

@@ -29,24 +29,21 @@ source \
source \ source \
"${baseDir}/system.conf" "${baseDir}/system.conf"
if [[ ! "${DISK}" == **/dev/disk/by-id/** ]]; then if [[ ! "${disk}" == **/dev/disk/by-id/** ]]; then
if [[ "${DISK}" == **/dev/nvme** ]]; then if [[ "${disk}" == **/dev/nvme** ]]; then
PART1='p1' part1='p1'
PART2='p2' part2='p2'
else else
PART1='1' part1='1'
PART2='2' part2='2'
fi fi
else else
PART1='-part1' part1='-part1'
PART2='-part2' part2='-part2'
fi fi
if [[ ! -f "/etc/mtab" ]]; then if [[ ! -f "/etc/mtab" ]]; then
ln \ "${baseDir}/mtab.sh"
-s \
/proc/self/mounts \
/etc/mtab
fi fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
@@ -60,7 +57,7 @@ if [[ "${ID}" == 'fedora' ]]; then
nofsck="yes" nofsck="yes"
add_dracutmodules+=" zfs " add_dracutmodules+=" zfs "
omit_dracutmodules+=" btrfs " omit_dracutmodules+=" btrfs "
install_items+=" /etc/zfs/keys/${HOSTNAME,,}.key " install_items+=" /etc/zfs/keys/${hostname,,}.key "
EOF EOF
else else
cat <<EOF >/etc/dracut.conf.d/zol.conf cat <<EOF >/etc/dracut.conf.d/zol.conf
@@ -69,9 +66,7 @@ add_dracutmodules+=" zfs "
omit_dracutmodules+=" btrfs " omit_dracutmodules+=" btrfs "
EOF EOF
fi fi
fi
if [[ "${ID}" == 'fedora' ]]; then
if [[ "${VERSION_ID}" -lt '41' ]]; then if [[ "${VERSION_ID}" -lt '41' ]]; then
dnf \ dnf \
config-manager \ config-manager \
@@ -115,53 +110,21 @@ if [[ "${ID}" == 'fedora' ]]; then
fi fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
cat << EOF "${baseDir}/debian.sh" --dpkg-reconfigure
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
fi fi
if [[ "${ID}" == 'debian' ]]; then # if [[ "${ID}" == 'debian' ]]; then
printf \ # printf \
'REMAKE_INITRD=yes\n' | \ # 'REMAKE_INITRD=yes\n' | \
tee /etc/dkms/zfs.conf &> /dev/null # tee /etc/dkms/zfs.conf &> /dev/null
fi # fi
if [[ ! "${*}" = *--no-part* ]]; then if [[ ! "${*}" = *--no-part* ]]; then
mkdosfs \ "${baseDir}/partition.sh" --efi
-F 32 \
-s 1 \
-n EFI \
${DISK}${PART1}
fi 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 if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
apt \ "${baseDir}/debian.sh" --purge-os-prober
purge \
--yes \
os-prober
fi fi
printf \ printf \
@@ -177,9 +140,9 @@ passwd
printf \ printf \
'\033[?47l' '\033[?47l'
if [[ "${ENABLE_SWAP}" == "yes" ]]; then if [[ "${enableSwap}" == "yes" ]]; then
printf \ printf \
"swap\t${DISK}${PART2}\t/dev/random\tswap,cipher=aes-xts-plain64,size=512\n" | \ "swap\t${disk}${part2}\t/dev/random\tswap,cipher=aes-xts-plain64,size=512\n" | \
tee /etc/crypttab &> /dev/null tee /etc/crypttab &> /dev/null
printf \ printf \
@@ -188,14 +151,7 @@ if [[ "${ENABLE_SWAP}" == "yes" ]]; then
fi fi
if [[ "${ID}" == 'debian' ]]; then if [[ "${ID}" == 'debian' ]]; then
cp \ "${baseDir}/debian.sh" --network-manager
/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 fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
@@ -215,14 +171,14 @@ fi
zfs \ zfs \
set \ set \
org.zfsbootmenu:commandline='quiet splash rhgb noresume' \ org.zfsbootmenu:commandline='quiet splash rhgb noresume' \
${HOSTNAME,,}/ROOT/${ID} ${hostname,,}/ROOT/${ID}
if [[ ! "${*}" = *--no-part* ]]; then if [[ ! "${*}" = *--no-part* ]]; then
if [[ ! -z "$(zfs list | grep 'keystore')" ]]; then if [[ ! -z "$(zfs list | grep 'keystore')" ]]; then
zfs \ zfs \
set \ set \
org.zfsbootmenu:keysource=${HOSTNAME,,}/keystore \ org.zfsbootmenu:keysource=${hostname,,}/keystore \
${HOSTNAME,,} ${hostname,,}
fi fi
fi fi
@@ -247,6 +203,6 @@ fi
zfs \ zfs \
snapshot \ snapshot \
${HOSTNAME,,}/ROOT/${ID}@install ${hostname,,}/ROOT/${ID}@install
"${baseDir}/post-inst.sh" "${baseDir}/post-inst.sh"

17
mkdir-tmpfs.sh Normal file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail
mkdir \
-p \
/mnt/run
mount \
-t \
tmpfs \
tmpfs \
/mnt/run
mkdir \
-p \
/mnt/run/lock

8
mtab.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
ln \
-s \
/proc/self/mounts \
/etc/mtab

View File

@@ -8,14 +8,14 @@ source \
source \ source \
"${BASEDIR}/system.conf" "${BASEDIR}/system.conf"
if [[ ! "${DISK}" == **/dev/disk/by-id/** ]]; then if [[ ! "${disk}" == **/dev/disk/by-id/** ]]; then
if [[ "${DISK}" == **/dev/nvme** ]]; then if [[ "${disk}" == **/dev/nvme** ]]; then
PART3='p3' part3='p3'
else else
PART3='3' part3='3'
fi fi
else else
PART3='-part3' part3='-part3'
fi fi
swapoff \ swapoff \
@@ -23,40 +23,61 @@ swapoff \
wipefs \ wipefs \
-a \ -a \
${DISK} ${disk}
if [[ ! "${DISK_TYPE}" == 'HDD' ]]; then if [[ ! "${diskType}" == 'HDD' ]]; then
blkdiscard \ blkdiscard \
-f \ -f \
${DISK} ${disk}
fi fi
sgdisk \ sgdisk \
--zap-all \ --zap-all \
${DISK} ${disk}
sgdisk \ sgdisk \
-n1:0:+512M \ -n1:0:+512M \
-t1:EF00 \ -t1:EF00 \
-c1:EFI \ -c1:EFI \
${DISK} ${disk}
if [[ "${ENABLE_SWAP}" == "yes" ]]; then if [[ "${enableSwap}" == "yes" ]]; then
SWAP_SIZE="$(((($(vmstat -sS M | grep 'total memory' | sed 's/ M total memory//') / 1024) + 1) * 2))" swapSize="$(((($(vmstat -sS M | grep 'total memory' | sed 's/ M total memory//') / 1024) + 1) * 2))"
if [[ "${SWAP_SIZE#}" -gt '32' ]]; then if [[ "${swapSize#}" -gt '32' ]]; then
SWAP_SIZE='32' swapSize='32'
fi fi
sgdisk \ sgdisk \
-n2:0:+${SWAP_SIZE}G \ -n2:0:+${swapSize}G \
-t2:BF02 \ -t2:BF02 \
-c2:swap \ -c2:swap \
${DISK} ${disk}
fi fi
sgdisk \ sgdisk \
-n3:0:0 \ -n3:0:0 \
-t3:BF00 \ -t3:BF00 \
-c3:${ID} \ -c3:${ID} \
${DISK} ${disk}
if [[ "${*}" == *--efi* ]]; then
mkdosfs \
-F 32 \
-s 1 \
-n EFI \
${disk}${part1}
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
fi

View File

@@ -2,7 +2,12 @@
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
source \
/etc/os-release
source \
"${baseDir}/system.conf"
printf \ printf \
@@ -11,7 +16,7 @@ printf \
cat << EOF cat << EOF
####################################### #######################################
## ## ## ##
## $(cat "${BASEDIR}/title") Script ## ## $(cat "${baseDir}/title") Script ##
## ## ## ##
## Jean <jean@easthighnerd.net> ## ## Jean <jean@easthighnerd.net> ##
## ## ## ##
@@ -32,41 +37,41 @@ source \
/etc/os-release /etc/os-release
source \ source \
"${BASEDIR}/system.conf" "${baseDir}/system.conf"
if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
zfs create\ zfs create\
${HOSTNAME,,}/home/${USERNAME} ${hostname,,}/home/${username}
zfs create\ zfs create\
${HOSTNAME,,}/home/${USERNAME}/.config ${hostname,,}/home/${username}/.config
zfs create\ zfs create\
-o canmount=off\ -o canmount=off\
${HOSTNAME,,}/home/${USERNAME}/.var ${hostname,,}/home/${username}/.var
zfs create\ zfs create\
${HOSTNAME,,}/home/${USERNAME}/.var/app ${hostname,,}/home/${username}/.var/app
zfs create\ zfs create\
-o canmount=off\ -o canmount=off\
${HOSTNAME,,}/home/${USERNAME}/.local ${hostname,,}/home/${username}/.local
zfs create\ zfs create\
-o canmount=off\ -o canmount=off\
${HOSTNAME,,}/home/${USERNAME}/.local/share ${hostname,,}/home/${username}/.local/share
zfs create\ zfs create\
${HOSTNAME,,}/home/${USERNAME}/.local/share/flatpak ${hostname,,}/home/${username}/.local/share/flatpak
printf \ printf \
'Adding user account...\n' 'Adding user account...\n'
adduser ${USERNAME} adduser ${username}
else # else
adduser --no-create-home ${USERNAME} # adduser --no-create-home ${username}
fi # fi
if [[ "${ID}" == 'fedora' ]]; then if [[ "${ID}" == 'fedora' ]]; then
printf \ printf \
@@ -77,7 +82,7 @@ if [[ "${ID}" == 'fedora' ]]; then
Enter a password for the new user account: Enter a password for the new user account:
EOF EOF
passwd \ passwd \
${USERNAME} ${username}
printf \ printf \
'\033[?47l' '\033[?47l'
@@ -86,7 +91,7 @@ EOF
-a \ -a \
-G \ -G \
audio,cdrom,dip,floppy,wheel,video,dialout \ audio,cdrom,dip,floppy,wheel,video,dialout \
${USERNAME} ${username}
else else
if [[ -z "$(cat /etc/group | grep 'lpadmin')" ]]; then if [[ -z "$(cat /etc/group | grep 'lpadmin')" ]]; then
groupadd --gid 108 lpadmin groupadd --gid 108 lpadmin
@@ -96,7 +101,7 @@ else
-a \ -a \
-G \ -G \
audio,cdrom,dip,floppy,netdev,plugdev,sudo,video,dialout,lpadmin \ audio,cdrom,dip,floppy,netdev,plugdev,sudo,video,dialout,lpadmin \
${USERNAME} ${username}
fi fi
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
@@ -115,35 +120,7 @@ Pin: release n=${UBUNTU_VERSION_CODENAME}-backports
Pin-Priority: -1 Pin-Priority: -1
EOF EOF
elif [[ "${ID}" == 'debian' ]]; then elif [[ "${ID}" == 'debian' ]]; then
cat << EOF | tee --append /etc/apt/sources.list.d/${VERSION_CODENAME}.sources &> /dev/null "${baseDir}/debian.sh" --contrib
# ${VERSION_CODENAME^} Backports
Enabled: yes
Types: deb deb-src
URIs: http://deb.debian.org/debian/
Suites: ${VERSION_CODENAME}-backports
Components: main non-free-firmware contrib
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
EOF
cat << EOF | tee /etc/apt/preferences.d/backports.pref &> /dev/null
Package: *
Pin: release n=${VERSION_CODENAME}*
Pin-Priority: 990
Package: linux-*
Pin: release n=${VERSION_CODENAME}-backports
Pin-Priority: -1
EOF
if [[ "${VERSION_CODENAME}" == 'bookworm' ]]; then
cat << EOF | tee --append /etc/apt/preferences.d/backports.pref &> /dev/null
Package: /wayland/
Pin: release n=${VERSION_CODENAME}-backports
Pin-Priority: -1
EOF
fi
fi fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
@@ -159,15 +136,7 @@ if [[ "${ID}" == 'elementary' ]]; then
--autoremove \ --autoremove \
elementary-desktop elementary-desktop
elif [[ "${ID}" = 'debian' ]]; then elif [[ "${ID}" = 'debian' ]]; then
if [[ ! -f /usr/bin/tasksel ]]; then "${baseDir}/debian.sh" --tasksel
apt \
install \
--yes \
tasksel
fi
tasksel \
--new-install
fi fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
@@ -203,56 +172,9 @@ EOF
tee /etc/apt/apt.conf.d/99-apt_moo &> /dev/null tee /etc/apt/apt.conf.d/99-apt_moo &> /dev/null
fi fi
if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
cat << EOF | tee /usr/bin/home-fix.sh &> /dev/null "${baseDir}/home-fix-setup.sh"
#!/bin/bash # fi
set -euo pipefail
chown -R ${USERNAME}:${USERNAME} /home/${USERNAME}
sudo -u ${USERNAME} cp -a /etc/skel/. /home/${USERNAME}
if [[ ! -z "\$(find -P /home/${USERNAME}/ | grep '\.face')" ]]; then
find -P /home/${USERNAME}/ | grep '\.face' | xargs -d '\n' -I {} rm {}
fi
if [[ ! -z "\$(find -P /var/spool/cron | grep 'root')" ]]; then
rm \$(find -P /var/spool/cron | grep 'root')
fi
printf "\$(date +%Y-%m-%d\ %H:%M:%S) I did the thing\n" | tee /var/log/home-fix.log &> /dev/null
if [[ -f '/usr/bin/home-fix.sh' ]]; then
rm /usr/bin/home-fix.sh
fi
zfs snapshot ${HOSTNAME,,}/ROOT/${ID}@home-fix
zfs snapshot -r ${HOSTNAME,,}/home/${USERNAME}@home-fix
EOF
chmod \
+x \
/usr/bin/home-fix.sh
if [[ "${ID}" == 'fedora' ]]; then
printf \
"@reboot\tsudo -u ${USERNAME} '${BASEDIR}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \
tee /var/spool/cron/root &> /dev/null
elif [[ "${ID}" == 'debian' ]]; then
printf \
"@reboot\tsudo -u ${USERNAME} '${BASEDIR}/finalize.sh'\n@reboot\t/usr/bin/home-fix.sh\n" | \
tee /var/spool/cron/crontabs/root &> /dev/null
chown \
:crontab \
/var/spool/cron/crontabs/root
chmod \
0600 \
/var/spool/cron/crontabs/root
fi
fi
if [[ ! -f '/usr/bin/shutdown' ]]; then if [[ ! -f '/usr/bin/shutdown' ]]; then
ln -s /sbin/shutdown /usr/bin/shutdown ln -s /sbin/shutdown /usr/bin/shutdown
@@ -264,7 +186,7 @@ fi
zfs \ zfs \
snapshot \ snapshot \
${HOSTNAME,,}/ROOT/${ID}@post-install ${hostname,,}/ROOT/${ID}@post-install
printf \ printf \
'\033[?47h\033[2J\033[H' '\033[?47h\033[2J\033[H'

View File

@@ -31,20 +31,6 @@ source \
"${baseDir}/system.conf" "${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 if [[ -f '/usr/bin/gsettings' ]]; then
gsettings \ gsettings \
set \ set \
@@ -54,50 +40,15 @@ if [[ -f '/usr/bin/gsettings' ]]; then
fi fi
if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'debian' ]] || [[ "${ID}" == 'elementary' ]]; then
apt \ "${baseDir}/debian.sh" --live
update && \
apt \
install \
--yes \
mmdebstrap \
gdisk \
systemd-timesyncd \
whois \
zfsutils-linux
elif [[ "${ID}" == 'fedora' ]]; then elif [[ "${ID}" == 'fedora' ]]; then
if [[ "${VERSION_ID}" -lt '41' ]]; then "${baseDir}/fedora.sh" --live
dnf config-manager \
--disable \
updates
else
dnf config-manager \
setopt \
updates.enabled=0
fi
dnf install \
-y \
https://zfsonlinux.org/fedora/zfs-release-${zolFedoraVer}$(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 fi
timedatectl timedatectl
if [[ ! "$(hostname)" == "debian-live" ]]; then if [[ ! "$(hostname)" == "debian-live" ]]; then
zgenhostid \ "${baseDir}/zfs.sh" --host-id
-f \
0x00bab10c
fi fi
@@ -107,19 +58,7 @@ sleep 5
"${baseDir}/zfs.sh" "${baseDir}/zfs.sh"
mkdir \ "${baseDir}/mkdir-tmpfs.sh"
-p \
/mnt/run
mount \
-t \
tmpfs \
tmpfs \
/mnt/run
mkdir \
-p \
/mnt/run/lock
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/elementary.sh" --mmdebstrap "${baseDir}/elementary.sh" --mmdebstrap
@@ -129,11 +68,7 @@ elif [[ "${ID}" == 'fedora' ]]; then
"${baseDir}/fedora.sh" --rsync "${baseDir}/fedora.sh" --rsync
fi fi
printf \ "${baseDir}/hostname.sh"
"${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 if [[ "${ID}" == 'debian' ]]; then
"${baseDir}/debian.sh" --network-interfaces "${baseDir}/debian.sh" --network-interfaces
@@ -145,32 +80,15 @@ elif [[ "${ID}" == 'debian' ]]; then
"${baseDir}/debian.sh" --sources "${baseDir}/debian.sh" --sources
fi fi
mount \ "${baseDir}/rbind.sh"
--rbind \
/dev \
/mnt/dev
mount \ "${baseDir}/host-id.sh"
--rbind \
/proc \
/mnt/proc
mount \
--rbind \
/sys \
/mnt/sys
cp \
/etc/hostid \
/mnt/etc/
if [[ "${ID}" == 'fedora' ]]; then if [[ "${ID}" == 'fedora' ]]; then
"${baseDir}/fedora.sh" --resolv-conf "${baseDir}/fedora.sh" --resolv-conf
fi fi
rsync -pogAXtlHrDx \ "${baseDir}/rsync.sh"
"${baseDir}" \
/mnt
if [[ "${ID}" == 'elementary' ]]; then if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/elementary.sh" --skel "${baseDir}/elementary.sh" --skel
@@ -178,9 +96,7 @@ fi
# if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
if [[ -f "/etc/zfs/keys/${hostname,,}.key" ]]; then if [[ -f "/etc/zfs/keys/${hostname,,}.key" ]]; then
cp \ "${baseDir}/zfs.sh" --key
/etc/zfs/keys/${hostname,,}.key \
/mnt/etc/zfs/keys/
fi fi
# fi # fi
@@ -188,24 +104,9 @@ if [[ "${ID}" == 'elementary' ]]; then
"${baseDir}/elementary.sh" --elementary "${baseDir}/elementary.sh" --elementary
fi fi
printf \ "${baseDir}/chroot.sh" --continue
"\nNow chrooting into /mnt...\n\n"
chroot \ "${baseDir}/zfs.sh" --unmount
/mnt \
"$(printf "${baseDir}\n" | sed 's|.*\/|\/|')/install.sh"
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 \ printf \
'\033[?47h\033[2J\033[H' '\033[?47h\033[2J\033[H'

18
rbind.sh Normal file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
set -euo pipefail
mount \
--rbind \
/dev \
/mnt/dev
mount \
--rbind \
/proc \
/mnt/proc
mount \
--rbind \
/sys \
/mnt/sys

9
rsync.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail
baseDir="$(realpath "$(dirname "${0}")")"
rsync -pogAXtlHrDx \
"${baseDir}" \
/mnt

154
zfs.sh
View File

@@ -1,55 +1,55 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
BASEDIR="$(dirname "${0}" | sed "s|^\.|${PWD}|")" baseDir="$(realpath "$(dirname "${0}")")"
source \ source \
/etc/os-release /etc/os-release
source \ source \
"${BASEDIR}/system.conf" "${baseDir}/system.conf"
if [[ ! "${DISK}" == **/dev/disk/by-id/** ]]; then if [[ ! "${disk}" == **/dev/disk/by-id/** ]]; then
if [[ "${DISK}" == **/dev/nvme** ]]; then if [[ "${disk}" == **/dev/nvme** ]]; then
PART3='p3' part3='p3'
else else
PART3='3' part3='3'
fi fi
else else
PART3='-part3' part3='-part3'
fi fi
# if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
if [[ "${ENCRYPTION}" == 'yes' ]]; then if [[ "${encryption}" == 'yes' ]]; then
ZPOOL_PASSWORD='A' zpoolPassword='A'
ZPOOL_PASSWORD_VERIFY='B' zpoolPasswordVerify='B'
printf \ printf \
'\033[?47h\033[2J\033[H' '\033[?47h\033[2J\033[H'
while [[ ! "${ZPOOL_PASSWORD}" == "${ZPOOL_PASSWORD_VERIFY}" ]] || [[ -z "${ZPOOL_PASSWORD}" ]] || [[ "${#ZPOOL_PASSWORD}" -lt '8' ]]; do while [[ ! "${zpoolPassword}" == "${zpoolPasswordVerify}" ]] || [[ -z "${zpoolPassword}" ]] || [[ "${#zpoolPassword}" -lt '8' ]]; do
printf \ printf \
"\nEnter a password to encrypt your root pool (minimum 8 characters):\n" "\nEnter a password to encrypt your root pool (minimum 8 characters):\n"
read \ read \
-r \ -r \
-s \ -s \
ZPOOL_PASSWORD zpoolPassword
printf \ printf \
"\nVerify the password to encrypt your root pool:\n" "\nVerify the password to encrypt your root pool:\n"
read \ read \
-r \ -r \
-s \ -s \
ZPOOL_PASSWORD_VERIFY zpoolPasswordVerify
if [[ ! "${ZPOOL_PASSWORD}" == "${ZPOOL_PASSWORD_VERIFY}" ]]; then if [[ ! "${zpoolPassword}" == "${zpoolPasswordVerify}" ]]; then
printf \ printf \
"ERROR:\tPasswords do not match!\n" "ERROR:\tPasswords do not match!\n"
elif [[ -z "${ZPOOL_PASSWORD}" ]]; then elif [[ -z "${zpoolPassword}" ]]; then
printf \ printf \
"ERROR:\tPassword is empty!\n" "ERROR:\tPassword is empty!\n"
elif [[ "${#ZPOOL_PASSWORD}" -lt '8' ]]; then elif [[ "${#zpoolPassword}" -lt '8' ]]; then
printf \ printf \
"ERROR:\tPassword is too short!\n" "ERROR:\tPassword is too short!\n"
fi fi
@@ -63,18 +63,18 @@ fi
/etc/zfs/keys/ /etc/zfs/keys/
printf \ printf \
"${ZPOOL_PASSWORD}\n" | tee /etc/zfs/keys/${HOSTNAME,,}.key &> /dev/null "${zpoolPassword}\n" | tee /etc/zfs/keys/${hostname,,}.key &> /dev/null
chmod \ chmod \
000 \ 000 \
/etc/zfs/keys/${HOSTNAME,,}.key /etc/zfs/keys/${hostname,,}.key
zpool create \ zpool create \
-o ashift=12 \ -o ashift=12 \
-o autotrim=on \ -o autotrim=on \
-o compatibility=openzfs-2.1-linux \ -o compatibility=openzfs-2.1-linux \
-O encryption=on \ -O encryption=on \
-O keylocation=file:///etc/zfs/keys/${HOSTNAME,,}.key \ -O keylocation=file:///etc/zfs/keys/${hostname,,}.key \
-O keyformat=passphrase \ -O keyformat=passphrase \
-O acltype=posixacl \ -O acltype=posixacl \
-O xattr=sa \ -O xattr=sa \
@@ -85,8 +85,8 @@ fi
-O canmount=off \ -O canmount=off \
-O mountpoint=/ \ -O mountpoint=/ \
-R /mnt \ -R /mnt \
${HOSTNAME,,} \ ${hostname,,} \
${DISK}${PART3} ${disk}${part3}
else else
zpool create \ zpool create \
-o ashift=12 \ -o ashift=12 \
@@ -102,42 +102,42 @@ fi
-O canmount=off \ -O canmount=off \
-O mountpoint=/ \ -O mountpoint=/ \
-R /mnt \ -R /mnt \
${HOSTNAME,,} \ ${hostname,,} \
${DISK}${PART3} ${disk}${part3}
fi fi
zfs create \ zfs create \
-o canmount=off \ -o canmount=off \
-o mountpoint=none \ -o mountpoint=none \
${HOSTNAME,,}/ROOT ${hostname,,}/ROOT
# else # else
# zpool import \ # zpool import \
# -N \ # -N \
# -R \ # -R \
# /mnt \ # /mnt \
# ${HOSTNAME,,} # ${hostname,,}
# #
# zfs load-key \ # zfs load-key \
# -r \ # -r \
# -L prompt \ # -L prompt \
# ${HOSTNAME,,} # ${hostname,,}
# fi # fi
zfs create \ zfs create \
-o canmount=noauto \ -o canmount=noauto \
-o mountpoint=/ \ -o mountpoint=/ \
${HOSTNAME,,}/ROOT/${ID} ${hostname,,}/ROOT/${ID}
zfs mount \ zfs mount \
${HOSTNAME,,}/ROOT/${ID} ${hostname,,}/ROOT/${ID}
# if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
zfs create \ zfs create \
${HOSTNAME,,}/home ${hostname,,}/home
zfs create \ zfs create \
-o mountpoint=/root \ -o mountpoint=/root \
${HOSTNAME,,}/home/root ${hostname,,}/home/root
chmod \ chmod \
700 \ 700 \
@@ -146,29 +146,29 @@ zfs mount \
zfs create \ zfs create \
-o canmount=off \ -o canmount=off \
-o mountpoint=/var \ -o mountpoint=/var \
${HOSTNAME,,}/var ${hostname,,}/var
zfs create \ zfs create \
-o canmount=off \ -o canmount=off \
${HOSTNAME,,}/var/lib ${hostname,,}/var/lib
zfs create \ zfs create \
${HOSTNAME,,}/var/log ${hostname,,}/var/log
zfs create \ zfs create \
${HOSTNAME,,}/var/spool ${hostname,,}/var/spool
zfs create \ zfs create \
-o com.sun:auto-snapshot=false \ -o com.sun:auto-snapshot=false \
${HOSTNAME,,}/var/cache ${hostname,,}/var/cache
zfs create \ zfs create \
-o com.sun:auto-snapshot=false \ -o com.sun:auto-snapshot=false \
${HOSTNAME,,}/var/lib/nfs ${hostname,,}/var/lib/nfs
zfs create \ zfs create \
-o com.sun:auto-snapshot=false \ -o com.sun:auto-snapshot=false \
${HOSTNAME,,}/var/tmp ${hostname,,}/var/tmp
chmod \ chmod \
1777 \ 1777 \
@@ -176,99 +176,121 @@ zfs mount \
zfs create \ zfs create \
-o mountpoint=/srv \ -o mountpoint=/srv \
${HOSTNAME,,}/srv ${hostname,,}/srv
zfs create \ zfs create \
-o canmount=off \ -o canmount=off \
-o mountpoint=/usr \ -o mountpoint=/usr \
${HOSTNAME,,}/usr ${hostname,,}/usr
zfs create \ zfs create \
${HOSTNAME,,}/usr/local ${hostname,,}/usr/local
zfs create \ zfs create \
${HOSTNAME,,}/var/games ${hostname,,}/var/games
zfs create \ zfs create \
${HOSTNAME,,}/var/lib/AccountsService ${hostname,,}/var/lib/AccountsService
zfs create \ zfs create \
${HOSTNAME,,}/var/lib/NetworkManager ${hostname,,}/var/lib/NetworkManager
zfs create \ zfs create \
${HOSTNAME,,}/var/www ${hostname,,}/var/www
zfs create \ zfs create \
-o com.sun:auto-snapshot=false \ -o com.sun:auto-snapshot=false \
-o mountpoint=/tmp \ -o mountpoint=/tmp \
${HOSTNAME,,}/tmp ${hostname,,}/tmp
if [[ "${ENCRYPTION}" == 'yes' ]]; then if [[ "${encryption}" == 'yes' ]]; then
zfs create \ zfs create \
-o com.sun:auto-snapshot=false \ -o com.sun:auto-snapshot=false \
-o mountpoint=/etc/zfs/keys \ -o mountpoint=/etc/zfs/keys \
${HOSTNAME,,}/keystore ${hostname,,}/keystore
fi fi
zpool set \ zpool set \
bootfs=${HOSTNAME,,}/ROOT/${ID} \ bootfs=${hostname,,}/ROOT/${ID} \
${HOSTNAME,,} ${hostname,,}
# else # else
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/home # ${hostname,,}/home
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/home/root # ${hostname,,}/home/root
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/log # ${hostname,,}/var/log
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/spool # ${hostname,,}/var/spool
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/cache # ${hostname,,}/var/cache
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/lib/nfs # ${hostname,,}/var/lib/nfs
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/tmp # ${hostname,,}/var/tmp
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/srv # ${hostname,,}/srv
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/usr/local # ${hostname,,}/usr/local
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/games # ${hostname,,}/var/games
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/lib/AccountsService # ${hostname,,}/var/lib/AccountsService
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/lib/NetworkManager # ${hostname,,}/var/lib/NetworkManager
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/www # ${hostname,,}/var/www
# #
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/keystore # ${hostname,,}/keystore
# fi # fi
if [[ "${ID}" == 'fedora' ]]; then if [[ "${ID}" == 'fedora' ]]; then
"${BASEDIR}/base-fedora.sh" -1 "${baseDir}/fedora.sh" -1
fi fi
# if [[ ! "${*}" = *--no-part* ]]; then # if [[ ! "${*}" = *--no-part* ]]; then
zfs create \ zfs create \
${HOSTNAME,,}/var/mail ${hostname,,}/var/mail
chmod \ chmod \
1777 \ 1777 \
/mnt/tmp /mnt/tmp
# else # else
# zfs mount \ # zfs mount \
# ${HOSTNAME,,}/var/mail # ${hostname,,}/var/mail
# fi # fi
if [[ "${1}" == '--key' ]]; then
cp \
/etc/zfs/keys/${hostname,,}.key \
/mnt/etc/zfs/keys/
elif [[ "${1}" == '--unmount' ]]; then
mount | grep -v zfs | tac | awk '/\/mnt/ {print $3}' | xargs -I {} umount -Rlf {}
if [[ "${ID}" == 'fedora' ]]; then
umount \
-nR \
/mnt
fi
zpool \
export \
-a
elif [[ "${1}" == '--host-id' ]]; then
zgenhostid \
-f \
0x00bab10c
fi