Split [zfs.sh] into multiple scripts inside a [zfs] directory, adjusted references in other files to reflect changes
This commit is contained in:
Executable
+116
@@ -0,0 +1,116 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
zfs create \
|
||||
-o canmount=off \
|
||||
-o mountpoint=none \
|
||||
${hostname,,}/ROOT
|
||||
|
||||
zfs create \
|
||||
-o canmount=noauto \
|
||||
-o mountpoint=/ \
|
||||
${hostname,,}/ROOT/${ID}
|
||||
|
||||
zfs mount \
|
||||
${hostname,,}/ROOT/${ID}
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/home
|
||||
|
||||
zfs create \
|
||||
-o mountpoint=/root \
|
||||
${hostname,,}/home/root
|
||||
|
||||
chmod \
|
||||
700 \
|
||||
/mnt/root
|
||||
|
||||
zfs create \
|
||||
-o canmount=off \
|
||||
-o mountpoint=/var \
|
||||
${hostname,,}/var
|
||||
|
||||
zfs create \
|
||||
-o canmount=off \
|
||||
${hostname,,}/var/lib
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/log
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/spool
|
||||
|
||||
zfs create \
|
||||
-o com.sun:auto-snapshot=false \
|
||||
${hostname,,}/var/cache
|
||||
|
||||
zfs create \
|
||||
-o com.sun:auto-snapshot=false \
|
||||
${hostname,,}/var/lib/nfs
|
||||
|
||||
zfs create \
|
||||
-o com.sun:auto-snapshot=false \
|
||||
${hostname,,}/var/tmp
|
||||
|
||||
chmod \
|
||||
1777 \
|
||||
/mnt/var/tmp
|
||||
|
||||
zfs create \
|
||||
-o mountpoint=/srv \
|
||||
${hostname,,}/srv
|
||||
|
||||
zfs create \
|
||||
-o canmount=off \
|
||||
-o mountpoint=/usr \
|
||||
${hostname,,}/usr
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/usr/local
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/games
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/lib/AccountsService
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/lib/NetworkManager
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/www
|
||||
|
||||
zfs create \
|
||||
-o com.sun:auto-snapshot=false \
|
||||
-o mountpoint=/tmp \
|
||||
${hostname,,}/tmp
|
||||
|
||||
if [[ "${encryption}" == 'yes' ]]; then
|
||||
zfs create \
|
||||
-o com.sun:auto-snapshot=false \
|
||||
-o mountpoint=/etc/zfs/keys \
|
||||
${hostname,,}/keystore
|
||||
fi
|
||||
|
||||
zpool set \
|
||||
bootfs=${hostname,,}/ROOT/${ID} \
|
||||
${hostname,,}
|
||||
|
||||
if [[ "${ID}" == 'fedora' ]]; then
|
||||
"${baseDir}/fedora.sh" --rsync
|
||||
fi
|
||||
|
||||
zfs create \
|
||||
${hostname,,}/var/mail
|
||||
|
||||
chmod \
|
||||
1777 \
|
||||
/mnt/tmp
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
if [[ ! "${disk}" == **/dev/disk/by-id/** ]]; then
|
||||
if [[ "${disk}" == **/dev/nvme** ]]; then
|
||||
part3='p3'
|
||||
else
|
||||
part3='3'
|
||||
fi
|
||||
else
|
||||
part3='-part3'
|
||||
fi
|
||||
|
||||
|
||||
if [[ "${encryption}" == 'yes' ]]; then
|
||||
zpoolPassword='A'
|
||||
zpoolPasswordVerify='B'
|
||||
|
||||
printf \
|
||||
'\033[?47h\033[2J\033[H'
|
||||
|
||||
while [[ ! "${zpoolPassword}" == "${zpoolPasswordVerify}" ]] || [[ -z "${zpoolPassword}" ]] || [[ "${#zpoolPassword}" -lt '8' ]]; do
|
||||
printf \
|
||||
"Enter a password to encrypt your root pool (minimum 8 characters):\n"
|
||||
read \
|
||||
-r \
|
||||
-s \
|
||||
zpoolPassword
|
||||
|
||||
printf \
|
||||
"Verify the password to encrypt your root pool:\n"
|
||||
read \
|
||||
-r \
|
||||
-s \
|
||||
zpoolPasswordVerify
|
||||
|
||||
if [[ ! "${zpoolPassword}" == "${zpoolPasswordVerify}" ]]; then
|
||||
printf \
|
||||
"ERROR:\tPasswords do not match!\n\n"
|
||||
elif [[ -z "${zpoolPassword}" ]]; then
|
||||
printf \
|
||||
"ERROR:\tPassword is empty!\n\n"
|
||||
elif [[ "${#zpoolPassword}" -lt '8' ]]; then
|
||||
printf \
|
||||
"ERROR:\tPassword is too short!\n\n"
|
||||
fi
|
||||
done
|
||||
|
||||
printf \
|
||||
'\033[?47l'
|
||||
mkdir \
|
||||
-p \
|
||||
/etc/zfs/keys/
|
||||
|
||||
printf \
|
||||
"${zpoolPassword}\n" | tee /etc/zfs/keys/${hostname,,}.key &> /dev/null
|
||||
|
||||
chmod \
|
||||
000 \
|
||||
/etc/zfs/keys/${hostname,,}.key
|
||||
|
||||
zpool create \
|
||||
-o ashift=12 \
|
||||
-o autotrim=on \
|
||||
-o compatibility=openzfs-2.1-linux \
|
||||
-O encryption=on \
|
||||
-O keylocation=file:///etc/zfs/keys/${hostname,,}.key \
|
||||
-O keyformat=passphrase \
|
||||
-O acltype=posixacl \
|
||||
-O xattr=sa \
|
||||
-O dnodesize=auto \
|
||||
-O compression=zstd-3 \
|
||||
-O normalization=formD \
|
||||
-O relatime=on \
|
||||
-O canmount=off \
|
||||
-O mountpoint=/ \
|
||||
-R /mnt \
|
||||
${hostname,,} \
|
||||
${disk}${part3}
|
||||
else
|
||||
zpool create \
|
||||
-o ashift=12 \
|
||||
-o autotrim=on \
|
||||
-o compatibility=openzfs-2.1-linux \
|
||||
-O encryption=off \
|
||||
-O acltype=posixacl \
|
||||
-O xattr=sa \
|
||||
-O dnodesize=auto \
|
||||
-O compression=zstd-3 \
|
||||
-O normalization=formD \
|
||||
-O relatime=on \
|
||||
-O canmount=off \
|
||||
-O mountpoint=/ \
|
||||
-R /mnt \
|
||||
${hostname,,} \
|
||||
${disk}${part3}
|
||||
fi
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
zfs create\
|
||||
${hostname,,}/home/${username}
|
||||
|
||||
zfs create\
|
||||
${hostname,,}/home/${username}/.config
|
||||
|
||||
zfs create\
|
||||
-o canmount=off\
|
||||
${hostname,,}/home/${username}/.var
|
||||
|
||||
zfs create\
|
||||
${hostname,,}/home/${username}/.var/app
|
||||
|
||||
zfs create\
|
||||
-o canmount=off\
|
||||
${hostname,,}/home/${username}/.local
|
||||
|
||||
zfs create\
|
||||
-o canmount=off\
|
||||
${hostname,,}/home/${username}/.local/share
|
||||
|
||||
zfs create\
|
||||
${hostname,,}/home/${username}/.local/share/flatpak
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
zgenhostid \
|
||||
-f \
|
||||
0x00bab10c
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
cp \
|
||||
/etc/zfs/keys/${hostname,,}.key \
|
||||
/mnt/etc/zfs/keys/
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
zfs \
|
||||
set \
|
||||
org.zfsbootmenu:keysource=${hostname,,}/keystore \
|
||||
${hostname,,}
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
/etc/os-release
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
zfs \
|
||||
set \
|
||||
org.zfsbootmenu:commandline='quiet splash rhgb noresume' \
|
||||
${hostname,,}/ROOT/${ID}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
baseDir="$(realpath "$(dirname "${0}")/../")"
|
||||
|
||||
source \
|
||||
"${baseDir}/system.conf"
|
||||
|
||||
|
||||
umount \
|
||||
-nR \
|
||||
/mnt
|
||||
|
||||
zpool \
|
||||
export \
|
||||
${hostname,,}
|
||||
Reference in New Issue
Block a user