Updated variable names and casing

This commit is contained in:
2025-12-24 16:22:32 -05:00
parent 648d07f355
commit 9c8add89e5
4 changed files with 121 additions and 116 deletions

View File

@@ -29,17 +29,17 @@ 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
@@ -60,7 +60,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
@@ -177,9 +177,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 \
@@ -215,14 +215,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 +247,6 @@ fi
zfs \ zfs \
snapshot \ snapshot \
${HOSTNAME,,}/ROOT/${ID}@install ${hostname,,}/ROOT/${ID}@install
"${baseDir}/post-inst.sh" "${baseDir}/post-inst.sh"

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,36 +23,36 @@ 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 \

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
@@ -217,7 +222,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'

132
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,99 @@ 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