Remove parentheses from variables and add more colours

This commit is contained in:
Le0xFF 2022-07-23 16:11:04 +02:00
parent 047bdebc92
commit 3d55e32a45

View File

@ -33,7 +33,7 @@ function check_if_bash {
function check_if_run_as_root {
if [[ "${UID}" != "0" ]] ; then
if [[ "$UID" != "0" ]] ; then
echo -e -n "Please run this script as root.\n"
exit 1
fi
@ -53,11 +53,11 @@ function check_if_uefi {
function create_chroot_script {
if [[ -f "${HOME}"/chroot.sh ]] ; then
rm -f "${HOME}"/chroot.sh
if [[ -f "$HOME"/chroot.sh ]] ; then
rm -f "$HOME"/chroot.sh
fi
cat << EOD >> "${HOME}"/chroot.sh
cat << EOD >> "$HOME"/chroot.sh
#! /bin/bash
function set_root {
@ -90,10 +90,10 @@ function edit_fstab {
echo -e -n "\e[0;32m#######################################\e[0m\n"
echo -e -n "\nExporting variables that will be used for fstab...\n"
export UEFI_UUID=\$(blkid -s UUID -o value "\${boot_partition}")
export LUKS_UUID=\$(blkid -s UUID -o value "\${encrypted_partition}")
export ROOT_UUID=\$(blkid -s UUID -o value /dev/mapper/"\${vg_name}"-"\${lv_root_name}")
export HOME_UUID=\$(blkid -s UUID -o value /dev/mapper/"\${vg_name}"-"\${lv_home_name}")
export UEFI_UUID=\$(blkid -s UUID -o value "\$boot_partition")
export LUKS_UUID=\$(blkid -s UUID -o value "\$encrypted_partition")
export ROOT_UUID=\$(blkid -s UUID -o value /dev/mapper/"\$vg_name"-"\$lv_root_name")
export HOME_UUID=\$(blkid -s UUID -o value /dev/mapper/"\$vg_name"-"\$lv_home_name")
echo -e -n "\nWriting fstab...\n\n"
sed -i '/tmpfs/d' /etc/fstab
@ -132,7 +132,7 @@ function generate_random_key {
dd bs=512 count=4 if=/dev/random of=/boot/volume.key
echo -e -n "\nRandom key generated, unlocking the encrypted partition...\n"
cryptsetup luksAddKey "\${encrypted_partition}" /boot/volume.key
cryptsetup luksAddKey "\$encrypted_partition" /boot/volume.key
chmod 000 /boot/volume.key
chmod -R g-rwx,o-rwx /boot
@ -204,7 +204,7 @@ EOF
mount -t efivarfs efivarfs /sys/firmware/efi/efivars/
fi
if [[ -z "\${user_drive}" ]] ; then
if [[ -z "\$user_drive" ]] ; then
while true ; do
clear
header_ig
@ -213,20 +213,20 @@ EOF
lsblk -p
echo -e -n "\nOn Which drive do you want to install GRUB?\nPlease enter the full drive path (i.e. /dev/sda): "
read -r user_drive
if [[ ! -b "\${user_drive}" ]] ; then
if [[ ! -b "\$user_drive" ]] ; then
echo -e -n "\nPlease select a valid drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
else
while true; do
echo -e -n "\nYou selected: "\e[1;34m\${user_drive}"\e[0m.\n\n"
echo -e -n "\nYou selected: \e[1;34m\$user_drive\e[0m.\n\n"
echo -e -n "\e[1;31mAre you sure you want to continue? (y/n and [ENTER]):\e[0m "
read -r yn
if [[ "\${yn}" == "n" ]] || [[ "\${yn}" == "N" ]] ; then
if [[ "\$yn" == "n" ]] || [[ "\$yn" == "N" ]] ; then
echo -e -n "\nAborting, select another drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
break
elif [[ "\${yn}" == "y" ]] || [[ "\${yn}" == "Y" ]] ; then
elif [[ "\$yn" == "y" ]] || [[ "\$yn" == "Y" ]] ; then
echo -e -n "\nCorrect drive selected, continuing with grub installation...\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
break 2
@ -242,7 +242,7 @@ EOF
clear
header_ig
echo -e -n "\nInstalling GRUB on \e[1;34m"\${user_drive}"\e[0m with \"VoidLinux\" as bootloader-id...\n\n"
echo -e -n "\nInstalling GRUB on \e[1;34m\$user_drive\e[0m with \"\e[1;34mVoidLinux\e[0m\" as bootloader-id...\n\n"
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=VoidLinux --boot-directory=/boot --recheck
echo -e -n "\nEnabling SSD trim...\n\n"
@ -286,12 +286,12 @@ read -n 1 -r -p "[Press any key to continue...]" key
clear
EOD
if [[ ! -f "${HOME}"/chroot.sh ]] ; then
echo -e -n "Please run this script again to be sure that "${HOME}"/chroot.sh script is created too."
if [[ ! -f "$HOME"/chroot.sh ]] ; then
echo -e -n "Please run this script again to be sure that $HOME/chroot.sh script is created too."
exit 1
fi
chmod +x "${HOME}"/chroot.sh
chmod +x "$HOME"/chroot.sh
}
@ -336,7 +336,7 @@ function set_keyboard_layout {
echo -e -n "\nDo you want to change your keyboard layout? (y/n): "
read -n 1 -r yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nPress any key to list all the keyboard layouts.\nMove with arrow keys and press \"q\" to exit the list."
read -n 1 -r key
@ -349,14 +349,14 @@ function set_keyboard_layout {
echo
read -r -p "Type the keyboard layout you want to set and press [ENTER] or just press [ENTER] to keep the one currently set: " user_keyboard_layout
if [[ -z "${user_keyboard_layout}" ]] ; then
if [[ -z "$user_keyboard_layout" ]] ; then
echo -e -n "\nNo keyboard layout selected, keeping the previous one.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
else
if loadkeys ${user_keyboard_layout} 2> /dev/null ; then
echo -e -n "\nKeyboad layout set to: \"$"{user_keyboard_layout}"\".\n\n"
if loadkeys "$user_keyboard_layout" 2> /dev/null ; then
echo -e -n "\nKeyboad layout set to: \"\e[1;34m$user_keyboard_layout\e[0m\".\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
@ -367,7 +367,7 @@ function set_keyboard_layout {
done
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nKeeping the last selected keyboard layout.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -403,14 +403,14 @@ function check_and_connect_to_internet {
echo -e -n "\nNo internet connection found.\n\n"
read -n 1 -r -p "Do you want to connect to the internet? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
while true ; do
echo -e -n "\n\nDo you want to use wifi? (y/n): "
read -n 1 -r yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
if [[ -L /var/service/NetworkManager ]] ; then
@ -419,7 +419,7 @@ function check_and_connect_to_internet {
echo
read -n 1 -r -p "Is your ESSID hidden? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo
echo
nmcli device wifi
@ -429,7 +429,7 @@ function check_and_connect_to_internet {
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo
echo
nmcli device wifi
@ -459,7 +459,7 @@ function check_and_connect_to_internet {
echo -e -n "Enter the wifi interface and press [ENTER]: "
read -r wifi_interface
if [[ -n "${wifi_interface}" ]] ; then
if [[ -n "$wifi_interface" ]] ; then
echo -e -n "\nEnabling wpa_supplicant service...\n"
@ -482,8 +482,8 @@ function check_and_connect_to_internet {
fi
echo -e -n "\nGenerating configuration files..."
wpa_passphrase "${wifi_essid}" | tee /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i "${wifi_interface}"
wpa_passphrase "$wifi_essid" | tee /etc/wpa_supplicant/wpa_supplicant.conf
wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i "$wifi_interface"
break 2
else
echo -e -n "\nPlease input a valid wifi interface.\n"
@ -498,7 +498,7 @@ function check_and_connect_to_internet {
fi
break
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease connect your ethernet cable and wait a minute before pressing any key."
read -n 1 -r key
clear
@ -510,7 +510,7 @@ function check_and_connect_to_internet {
done
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nNot connecting to the internet.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -549,7 +549,7 @@ function disk_wiping {
echo
read -n 1 -r -p "Do you want to wipe any drive? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
while true ; do
@ -562,33 +562,33 @@ function disk_wiping {
echo -e -n "\nWhich drive do you want to wipe?\nIt will be automatically selected as the drive to be partitioned.\n\nPlease enter the full drive path (i.e. /dev/sda): "
read -r user_drive
if [[ ! -b "${user_drive}" ]] ; then
if [[ ! -b "$user_drive" ]] ; then
echo -e -n "\nPlease select a valid drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true; do
echo -e -n "\nDrive selected for wiping: "${user_drive}"\n"
echo -e -n "\nDrive selected for wiping: \e[1;34m$user_drive\e[0m\n"
echo -e -n "\n\e[1;31mTHIS DRIVE WILL BE WIPED, EVERY DATA INSIDE WILL BE LOST.\e[0m\n"
echo -e -n "\e[1;31mAre you sure you want to continue? (y/n and [ENTER]):\e[0m "
read -r yn
if [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
if [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\nAborting, select another drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break
elif [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if grep -q "${user_drive}" /proc/mounts ; then
echo -e -n "\nDrive already mounted.\nChanging directory to "${HOME}" and unmounting every partition before wiping...\n"
cd $HOME
umount -l "${user_drive}"?*
elif [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
if grep -q "$user_drive" /proc/mounts ; then
echo -e -n "\nDrive already mounted.\nChanging directory to $HOME and unmounting every partition before wiping...\n"
cd "$HOME"
umount -l "$user_drive"?*
echo -e -n "\nDrive unmounted successfully.\n"
fi
echo -e -n "\nWiping the drive...\n"
wipefs -a "${user_drive}"
wipefs -a "$user_drive"
sync
echo -e -n "\nDrive successfully wiped.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
@ -602,7 +602,7 @@ function disk_wiping {
fi
done
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nNo additional changes were made.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -631,19 +631,19 @@ function disk_partitioning {
header_dp
if [[ -z "${user_drive}" ]] ; then
if [[ -z "$user_drive" ]] ; then
echo -e -n "\nNo drive previously selected for partitioning.\n\n"
read -n 1 -r -p "Do you want to partition any drive? (y/n): " yn
else
while true ; do
echo -e -n "\nDrive previously selected for partitioning: "${user_drive}".\n\n"
echo -e -n "\nDrive previously selected for partitioning: \e[1;34m$user_drive\e[0m.\n\n"
read -n 1 -r -p "Do you want to change it? (y/n): " yn
if [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
if [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nKeeping the previously selected drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
yn="y"
break
elif [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
elif [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nPlease select another drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
user_drive=''
@ -656,16 +656,16 @@ function disk_partitioning {
done
fi
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
while true ; do
if [[ -n "${user_drive}" ]] ; then
if [[ -n "$user_drive" ]] ; then
if grep -q "${user_drive}" /proc/mounts ; then
echo -e -n "\nDrive already mounted.\nChanging directory to "${HOME}" and unmounting every partition before partitioning...\n"
cd $HOME
umount -l "${user_drive}"?*
if grep -q "$user_drive" /proc/mounts ; then
echo -e -n "\nDrive already mounted.\nChanging directory to $HOME and unmounting every partition before partitioning...\n"
cd "$HOME"
umount -l "$user_drive"?*
echo -e -n "\nDrive unmounted successfully.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -682,23 +682,23 @@ function disk_partitioning {
echo -e -n "\n- Rest of the disk for the partition that will be logically partitioned with LVM (/ and /home) [Linux filesystem]."
echo -e -n "\n\nThose two will be physical partition.\nYou don't need to create a /home partition now because it will be created later as a logical one.\n"
echo -e -n "\nDrive selected for partitioning: ${user_drive}\n\n"
echo -e -n "\nDrive selected for partitioning: \e[1;34m$user_drive\e[0m\n\n"
read -r -p "Which tool do you want to use? (fdisk/cfdisk/sfdisk): " tool
case "${tool}" in
case "$tool" in
fdisk)
fdisk "${user_drive}"
fdisk "$user_drive"
sync
break
;;
cfdisk)
cfdisk "${user_drive}"
cfdisk "$user_drive"
sync
break
;;
sfdisk)
sfdisk "${user_drive}"
sfdisk "$user_drive"
sync
break
;;
@ -716,16 +716,16 @@ function disk_partitioning {
header_dp
echo
lsblk -p "${user_drive}"
lsblk -p "$user_drive"
echo
read -n 1 -r -p "Is this the desired partition table? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nDrive partitioned, keeping changes.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 3
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease partition your drive again.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
break
@ -750,27 +750,27 @@ function disk_partitioning {
echo -e -n "\nWhich drive do you want to partition?\nPlease enter the full drive path (i.e. /dev/sda): "
read -r user_drive
if [[ ! -b "${user_drive}" ]] ; then
if [[ ! -b "$user_drive" ]] ; then
echo -e -n "\nPlease select a valid drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
else
while true; do
echo -e -n "\nYou selected "${user_drive}".\n"
echo -e -n "\nYou selected "$user_drive".\n"
echo -e -n "\n\e[1;31mTHIS DRIVE WILL BE PARTITIONED, EVERY DATA INSIDE WILL BE LOST.\e[0m\n"
echo -e -n "\e[1;31mAre you sure you want to continue? (y/n and [ENTER]):\e[0m "
read -r yn
if [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
if [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\nAborting, select another drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
break
elif [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if grep -q "${user_drive}" /proc/mounts ; then
echo -e -n "\nDrive already mounted.\nChanging directory to "${HOME}" and unmounting every partition before selecting it for partitioning...\n"
elif [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
if grep -q "$user_drive" /proc/mounts ; then
echo -e -n "\nDrive already mounted.\nChanging directory to $HOME and unmounting every partition before selecting it for partitioning...\n"
cd "$HOME"
umount -l "${user_drive}"?*
umount -l "$user_drive"?*
echo -e -n "\nDrive unmounted successfully.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
fi
@ -792,7 +792,7 @@ function disk_partitioning {
done
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nNo additional changes were made.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -825,25 +825,25 @@ function disk_encryption {
echo -e -n "\nPrinting all the connected drives:\n\n"
lsblk -p
echo -e -n "\nWhich / [root] partition do you want to encrypt?\nPlease enter the full partition path (i.e. /dev/sda1): "
echo -e -n "\nWhich \e[1;34m/ [root]\e[0m partition do you want to \e[1;34mencrypt\e[0m?\nPlease enter the full partition path (i.e. /dev/sda1): "
read -r encrypted_partition
if [[ ! -b "${encrypted_partition}" ]] ; then
if [[ ! -b "$encrypted_partition" ]] ; then
echo -e -n "\nPlease select a valid partition.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true; do
echo -e -n "\nYou selected: ${encrypted_partition}.\n\n"
echo -e -n "\nYou selected: $encrypted_partition.\n\n"
read -r -p "Is this correct? (y/n and [ENTER]): " yn
if [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
if [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\nAborting, select another partition.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break
elif [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
elif [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\nCorrect partition selected.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -851,14 +851,14 @@ function disk_encryption {
header_de
echo -e -n "\nThe selected partition will now be encrypted with LUKS.\n"
echo -e -n "\nKeep in mind that GRUB LUKS version 2 support is still limited (https://savannah.gnu.org/bugs/?55093).\nChoosing it could result in an unbootable system so it's strongly recommended to use LUKS version 1.\n"
echo -e -n "\nKeep in mind that GRUB LUKS version 2 support is still limited (https://savannah.gnu.org/bugs/?55093).\n\e[1;31mChoosing it could result in an unbootable system so it's strongly recommended to use LUKS version 1.\e[0m\n"
while true ; do
echo -e -n "\nWhich LUKS version do you want to use? (1/2 and [ENTER]): "
read ot
if [[ "${ot}" == "1" ]] || [[ "${ot}" == "2" ]] ; then
echo -e -n "\nUsing LUKS version "${ot}".\n\n"
cryptsetup luksFormat --type=luks"${ot}" "${encrypted_partition}"
if [[ "$ot" == "1" ]] || [[ "$ot" == "2" ]] ; then
echo -e -n "\nUsing LUKS version \e[1;34m$ot\e[0m.\n\n"
cryptsetup luksFormat --type=luks"$ot" "$encrypted_partition"
echo -e -n "\nPartition successfully encrypted.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -872,25 +872,25 @@ function disk_encryption {
while true ; do
header_de
echo -e -n "\nEnter a name for the encrypted partition without any spaces (i.e. MyEncryptedLinuxPartition): "
echo -e -n "\nEnter a \e[1;34mname\e[0m for the \e[1;34mencrypted partition\e[0m without any spaces (i.e. MyEncryptedLinuxPartition): "
read -r encrypted_name
if [[ -z "${encrypted_name}" ]] ; then
if [[ -z "$encrypted_name" ]] ; then
echo -e -n "\nPlease enter a valid name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${encrypted_name}".\n\n"
echo -e -n "\nYou entered: "$encrypted_name".\n\n"
read -n 1 -r -p "Is this the desired name? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nPartition will now be mounted as: /dev/mapper/"${encrypted_name}"\n\n"
cryptsetup open "${encrypted_partition}" "${encrypted_name}"
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nPartition will now be mounted as: \e[1;34m/dev/mapper/"$encrypted_name"\e[0m\n\n"
cryptsetup open "$encrypted_partition" "$encrypted_name"
echo -e -n "\nEncrypted partition successfully mounted.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select another name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -933,26 +933,26 @@ function lvm_creation {
echo -e -n "\nCreating logical partitions wih LVM.\n"
echo -e -n "\nEnter a name for the volume group without any spaces (i.e. MyLinuxVolumeGroup): "
echo -e -n "\nEnter a \e[1;34mname\e[0m for the \e[1;34mVolume Group\e[0m without any spaces (i.e. MyLinuxVolumeGroup): "
read -r vg_name
if [[ -z "${vg_name}" ]] ; then
if [[ -z "$vg_name" ]] ; then
echo -e -n "\nPlease enter a valid name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${vg_name}".\n\n"
echo -e -n "\nYou entered: "$vg_name".\n\n"
read -n 1 -r -p "Is this the desired name? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nVolume group will now be created and mounted as: /dev/mapper/"${vg_name}"\n\n"
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nVolume Group will now be created and mounted as: \e[1;34m/dev/mapper/$vg_name\e[0m\n\n"
vgcreate "${vg_name}" /dev/mapper/"${encrypted_name}"
echo
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select another name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -970,26 +970,26 @@ function lvm_creation {
header_lc
echo -e -n "\nEnter a name for the logical root partition without any spaces and its size.\nBe sure to make no errors (i.e. MyLogicLinuxRootPartition 100G): "
echo -e -n "\nEnter a \e[1;34mname\e[0m for the \e[1;34mLogical root Volume\e[0m without any spaces and its size.\nBe sure to make no errors (i.e. MyLogicLinuxRootPartition 100G): "
read -r lv_root_name lv_root_size
if [[ -z "${lv_root_name}" ]] || [[ -z "${lv_root_size}" ]] ; then
if [[ -z "$lv_root_name" ]] || [[ -z "$lv_root_size" ]] ; then
echo -e -n "\nPlease enter valid values.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${lv_root_name}" and "${lv_root_size}".\n\n"
echo -e -n "\nYou entered: \e[1;34m$lv_root_name\e[0m and \e[1;34m$lv_root_size\e[0m.\n\n"
read -n 1 -r -p "Are these correct? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nLogical volume "${lv_root_name}" of size "${lv_root_size}" will now be created.\n\n"
lvcreate --name "${lv_root_name}" -L "${lv_root_size}" "${vg_name}"
if [[ "$yn" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nLogical Volume \e[1;34m$lv_root_name\e[0m of size \e[1;34m$lv_root_size\e[0m will now be created.\n\n"
lvcreate --name "$lv_root_name" -L "$lv_root_size" "$vg_name"
echo
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select other values.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -1007,26 +1007,26 @@ function lvm_creation {
header_lc
echo -e -n "\nEnter a name for the logical home partition without any spaces.\nIts size will be the remaining free space (i.e. MyLogicLinuxHomePartition): "
echo -e -n "\nEnter a \e[1;34mname\e[0m for the \e[1;34mLogical home Volume\e[0m without any spaces.\nIts size will be the remaining free space (i.e. MyLogicLinuxHomePartition): "
read -r lv_home_name
if [[ -z "${lv_home_name}" ]] ; then
if [[ -z "$lv_home_name" ]] ; then
echo -e -n "\nPlease enter a valid name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${lv_home_name}".\n\n"
echo -e -n "\nYou entered: \e[1;34m$lv_home_name\e[0m.\n\n"
read -n 1 -r -p "Is this the desired name? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nLogical volume "${lv_home_name}" will now be created.\n\n"
lvcreate --name "${lv_home_name}" -l +100%FREE "${vg_name}"
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nLogical Volume \e[1;34m$lv_home_name\e[0m will now be created.\n\n"
lvcreate --name "$lv_home_name" -l +100%FREE "$vg_name"
echo
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select another name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -1056,36 +1056,36 @@ function create_filesystems {
header_cf
echo -e -n "\nFormatting partitions with proper filesystems.\n\nEFI partition will be formatted as FAT32.\nRoot and home partition will be formatted as BTRFS.\n"
echo -e -n "\nFormatting partitions with proper filesystems.\n\nEFI partition will be formatted as \e[1;34mFAT32\e[0m.\nRoot and home partition will be formatted as \e[1;34mBTRFS\e[0m.\n"
echo
lsblk -p
echo
echo -e -n "\nWhich partition will be the /boot/efi partition?\n"
echo -e -n "\nWhich partition will be the \e[1;34m/boot/efi\e[0m partition?\n"
read -r -p "Please enter the full partition path (i.e. /dev/sda1): " boot_partition
if [[ ! -b "${boot_partition}" ]] ; then
if [[ ! -b "$boot_partition" ]] ; then
echo -e -n "\nPlease select a valid drive.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true; do
echo -e -n "\nYou selected: "${boot_partition}".\n"
echo -e -n "\nYou selected: \e[1;34m$boot_partition\e[0m.\n"
echo -e -n "\n\e[1;31mTHIS PARTITION WILL BE FORMATTED, EVERY DATA INSIDE WILL BE LOST.\e[0m\n"
echo -e -n "\e[1;31mAre you sure you want to continue? (y/n and [ENTER]):\e[0m "
read -r yn
if [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
if [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\nAborting, select another partition.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break
elif [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
if grep -q "${boot_partition}" /proc/mounts ; then
echo -e -n "\nPartition already mounted.\nChanging directory to "${HOME}" and unmounting it before formatting...\n"
cd "${HOME}"
umount -l "${boot_partition}"
elif [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
if grep -q "$boot_partition" /proc/mounts ; then
echo -e -n "\nPartition already mounted.\nChanging directory to $HOME and unmounting it before formatting...\n"
cd "$HOME"
umount -l "$boot_partition"
echo -e -n "\nDrive unmounted successfully.\n"
read -n 1 -r -p "[Press any key to continue...]" key
fi
@ -1098,27 +1098,27 @@ function create_filesystems {
header_cf
echo -e -n "\nEnter a label for the boot partition without any spaces (i.e. MYBOOTPARTITION): "
echo -e -n "\nEnter a \e[1;34mlabel\e[0m for the \e[1;34mboot\e[0m partition without any spaces (i.e. MYBOOTPARTITION): "
read -r boot_name
if [[ -z "${boot_name}" ]] ; then
if [[ -z "$boot_name" ]] ; then
echo -e -n "\nPlease enter a valid name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${boot_name}".\n\n"
echo -e -n "\nYou entered: \e[1;34m$boot_name\e[0m.\n\n"
read -n 1 -r -p "Is this the desired name? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nBoot partition "${boot_partition}" will now be formatted as FAT32 with "${boot_name}" label.\n\n"
mkfs.vfat -n "${boot_name}" -F 32 "${boot_partition}"
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\nBoot partition \e[1;34m$boot_partition\e[0m will now be formatted as \e[1;34mFAT32\e[0m with \e[1;34m$boot_name\e[0m label.\n\n"
mkfs.vfat -n "$boot_name" -F 32 "$boot_partition"
sync
echo -e -n "\nPartition successfully formatted.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 4
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select another name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -1146,28 +1146,28 @@ function create_filesystems {
header_cf
echo -e -n "\nEnter a label for the root partition without any spaces (i.e. MyRootPartition): "
echo -e -n "\nEnter a \e[1;34mlabel\e[0m for the \e[1;34mroot\e[0m partition without any spaces (i.e. MyRootPartition): "
read -r root_name
if [[ -z "${root_name}" ]] ; then
if [[ -z "$root_name" ]] ; then
echo -e -n "\nPlease enter a valid name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${root_name}".\n\n"
echo -e -n "\nYou entered: \e[1;34m$root_name\e[0m.\n\n"
read -n 1 -r -p "Is this the desired name? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nRoot partition /dev/mapper/"${vg_name}"-"${lv_root_name}" will now be formatted as BTRFS with "${root_name}" label.\n\n"
mkfs.btrfs -L "${root_name}" /dev/mapper/"${vg_name}"-"${lv_root_name}"
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\n\e[1;34mRoot\e[0m partition \e[1;34m/dev/mapper/$vg_name-$lv_root_name\e[0m will now be formatted as \e[1;34mBTRFS\e[0m with \e[1;34m$root_name\e[0m label.\n\n"
mkfs.btrfs -L "$root_name" /dev/mapper/"$vg_name"-"$lv_root_name"
sync
echo -e -n "\nPartition successfully formatted.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select another name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -1185,27 +1185,27 @@ function create_filesystems {
header_cf
echo -e -n "\nEnter a label for the home partition without any spaces (i.e. MyHomePartition): "
echo -e -n "\nEnter a \e[1;34mlabel\e[0m for the \e[1;34mhome\e[0m partition without any spaces (i.e. MyHomePartition): "
read -r home_name
if [[ -z "${home_name}" ]] ; then
if [[ -z "$home_name" ]] ; then
echo -e -n "\nPlease enter a valid name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
else
while true ; do
echo -e -n "\nYou entered: "${home_name}".\n\n"
echo -e -n "\nYou entered: \e[1;34m$home_name\e[0m.\n\n"
read -n 1 -r -p "Is this the desired name? (y/n): " yn
if [[ "${yn}" == "y" ]] || [[ "${yn}" == "Y" ]] ; then
echo -e -n "\n\nHome partition /dev/mapper/"${vg_name}"-"${lv_home_name}" will now be formatted as BTRFS with "${home_name}" label.\n\n"
mkfs.btrfs -L "${home_name}" /dev/mapper/"${vg_name}"-"${lv_home_name}"
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]] ; then
echo -e -n "\n\n\e[1;34mHome\e[0m partition \e[1;34m/dev/mapper/$vg_name-$lv_home_name\e[0m will now be formatted as \e[1;34mBTRFS\e[0m with \e[1;34m$home_name\e[0m label.\n\n"
mkfs.btrfs -L "$home_name" /dev/mapper/"$vg_name"-"$lv_home_name"
sync
echo -e -n "\nPartition successfully formatted.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
break 2
elif [[ "${yn}" == "n" ]] || [[ "${yn}" == "N" ]] ; then
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]] ; then
echo -e -n "\n\nPlease select another name.\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
clear
@ -1250,10 +1250,10 @@ function create_btrfs_subvolumes {
echo -e -n "- /var/tmp\n"
echo -e -n "- /var/log\n"
echo -e -n "\nIf you prefer to change any option, please quit this script NOW and modify it according to you tastes.\n\n"
echo -e -n "\n\e[1;34mIf you prefer to change any option, please quit this script NOW and modify it according to you tastes.\e[0m\n\n"
read -n 1 -r -p "Press any key to continue or Ctrl+C to quit now..." key
echo -e -n "\n\nThe root partition you selected (/dev/mapper/"${vg_name}"-"${lv_root_name}") will now be mounted to /mnt.\n"
echo -e -n "\n\nThe root partition you selected (/dev/mapper/$vg_name-$lv_root_name) will now be mounted to /mnt.\n"
if grep -q /mnt /proc/mounts ; then
echo -e -n "Everything mounted to /mnt will now be unmounted...\n"
cd "$HOME"
@ -1265,21 +1265,21 @@ function create_btrfs_subvolumes {
echo -e -n "\nCreating BTRFS subvolumes and mounting them to /mnt...\n"
export BTRFS_OPT=rw,noatime,ssd,compress=zstd,space_cache=v2,commit=120
mount -o "${BTRFS_OPT}" /dev/mapper/"${vg_name}"-"${lv_root_name}" /mnt
mount -o "$BTRFS_OPT" /dev/mapper/"$vg_name"-"$lv_root_name" /mnt
mkdir /mnt/home
mount -o "${BTRFS_OPT}" /dev/mapper/"${vg_name}"-"${lv_home_name}" /mnt/home
mount -o "$BTRFS_OPT" /dev/mapper/"$vg_name"-"$lv_home_name" /mnt/home
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@snapshots
btrfs subvolume create /mnt/home/@home
umount /mnt/home
umount /mnt
mount -o "${BTRFS_OPT}",subvol=@ /dev/mapper/"${vg_name}"-"${lv_root_name}" /mnt
mount -o "$BTRFS_OPT",subvol=@ /dev/mapper/"$vg_name"-"$lv_root_name" /mnt
mkdir /mnt/home
mkdir /mnt/.snapshots
mount -o "${BTRFS_OPT}",subvol=@home /dev/mapper/"${vg_name}"-"${lv_home_name}" /mnt/home/
mount -o "${BTRFS_OPT}",subvol=@snapshots /dev/mapper/"${vg_name}"-"${lv_root_name}" /mnt/.snapshots/
mount -o "$BTRFS_OPT",subvol=@home /dev/mapper/"$vg_name"-"$lv_home_name" /mnt/home/
mount -o "$BTRFS_OPT",subvol=@snapshots /dev/mapper/"$vg_name"-"$lv_root_name" /mnt/.snapshots/
mkdir -p /mnt/boot/efi
mount -o rw,noatime "${boot_partition}" /mnt/boot/efi/
mount -o rw,noatime "$boot_partition" /mnt/boot/efi/
mkdir -p /mnt/var/cache
btrfs subvolume create /mnt/var/cache/xbps
btrfs subvolume create /mnt/var/tmp
@ -1305,20 +1305,20 @@ function install_base_system_and_chroot {
while true ; do
echo -e -n "\nSelect which architecture do you want to use:\n\n"
echo -e -n "\nSelect which \e[1;34marchitecture\e[0m do you want to use:\n\n"
select user_arch in x86_64 x86_64-musl ; do
case "${user_arch}" in
case "$user_arch" in
x86_64)
echo -e -n "\n"${user_arch}" selected.\n\n"
ARCH="${user_arch}"
echo -e -n "\n\e[1;34m$user_arch\e[0m selected.\n\n"
ARCH="$user_arch"
export REPO=https://repo-default.voidlinux.org/current
read -n 1 -r -p "[Press any key to continue...]" key
break 2
;;
x86_64-musl)
echo -e -n "\n"${user_arch}" selected.\n"
ARCH="${user_arch}"
echo -e -n "\n\e[1;34m$user_arch\e[0m selected.\n\n"
ARCH="$user_arch"
export REPO=https://repo-default.voidlinux.org/current/musl
read -n 1 -r -p "[Press any key to continue...]" key
break 2
@ -1333,8 +1333,8 @@ function install_base_system_and_chroot {
done
echo -e -n "\nInstalling base system...\n\n"
XBPS_ARCH="${ARCH}" xbps-install -Suy xbps
XBPS_ARCH="${ARCH}" xbps-install -Sy -r /mnt -R "$REPO" base-system btrfs-progs cryptsetup grub-x86_64-efi lvm2 grub-btrfs grub-btrfs-runit NetworkManager bash-completion nano
XBPS_ARCH="$ARCH" xbps-install -Suy xbps
XBPS_ARCH="$ARCH" xbps-install -Sy -r /mnt -R "$REPO" base-system btrfs-progs cryptsetup grub-x86_64-efi lvm2 grub-btrfs grub-btrfs-runit NetworkManager bash-completion nano
echo -e -n "\nMounting folders for chroot...\n"
for dir in sys dev proc ; do
@ -1352,8 +1352,8 @@ function install_base_system_and_chroot {
echo -e -n "\nChrooting...\n\n"
read -n 1 -r -p "[Press any key to continue...]" key
cp "${HOME}"/chroot.sh /mnt/root/
BTRFS_OPT="${BTRFS_OPT}" boot_partition="${boot_partition}" encrypted_partition="${encrypted_partition}" encrypted_name="${encrypted_name}" vg_name="${vg_name}" lv_root_name="${lv_root_name}" lv_home_name="${lv_home_name}" user_drive="${user_drive}" PS1='(chroot) # ' chroot /mnt/ /bin/bash "${HOME}"/chroot.sh
cp "$HOME"/chroot.sh /mnt/root/
BTRFS_OPT="$BTRFS_OPT" boot_partition="$boot_partition" encrypted_partition="$encrypted_partition" encrypted_name="$encrypted_name" vg_name="$vg_name" lv_root_name="$lv_root_name" lv_home_name="$lv_home_name" user_drive="$user_drive" PS1='(chroot) # ' chroot /mnt/ /bin/bash "$HOME"/chroot.sh
header_ibsac
@ -1361,12 +1361,12 @@ function install_base_system_and_chroot {
rm -f /mnt/home/root/chroot.sh
echo -e -n "\nUnmounting partitions...\n\n"
umount /dev/mapper/"${vg_name}"-"${lv_home_name}"
umount /dev/mapper/"${vg_name}"-"${lv_root_name}"
umount -l /dev/mapper/"${vg_name}"-"${lv_root_name}"
lvchange -an /dev/mapper/"${vg_name}"-"${lv_home_name}"
lvchange -an /dev/mapper/"${vg_name}"-"${lv_root_name}"
cryptsetup close /dev/mapper/"${encrypted_name}"
umount /dev/mapper/"$vg_name"-"$lv_home_name"
umount /dev/mapper/"$vg_name"-"$lv_root_name"
umount -l /dev/mapper/"$vg_name"-"$lv_root_name"
lvchange -an /dev/mapper/"$vg_name"-"$lv_home_name"
lvchange -an /dev/mapper/"$vg_name"-"$lv_root_name"
cryptsetup close /dev/mapper/"$encrypted_name"
read -n 1 -r -p "[Press any key to continue...]" key
clear