Changed unneeded 'elif' statements to simple individual 'if' statements

This commit is contained in:
2026-01-01 12:40:03 -05:00
parent 8d3c013539
commit 8b892d207d
4 changed files with 81 additions and 27 deletions

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,14 +52,18 @@ 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

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' \