mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-22 05:12:27 +00:00
Compare commits
2 Commits
d0bc7197bc
...
23c848cea7
Author | SHA1 | Date | |
---|---|---|---|
|
23c848cea7 | ||
|
99c7f984b4 |
|
@ -130,7 +130,7 @@ echo -ne "
|
||||||
██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║
|
██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║
|
||||||
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
|
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
Please select presetup settings for your system
|
Please select presetup settings for your system
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ filesystem () {
|
||||||
case $? in
|
case $? in
|
||||||
0) export FS=btrfs;;
|
0) export FS=btrfs;;
|
||||||
1) export FS=ext4;;
|
1) export FS=ext4;;
|
||||||
2)
|
2)
|
||||||
set_password "LUKS_PASSWORD"
|
set_password "LUKS_PASSWORD"
|
||||||
export FS=luks
|
export FS=luks
|
||||||
;;
|
;;
|
||||||
|
@ -155,14 +155,14 @@ filesystem () {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# @description Detects and sets timezone.
|
# @description Detects and sets timezone.
|
||||||
timezone () {
|
timezone () {
|
||||||
# Added this from arch wiki https://wiki.archlinux.org/title/System_time
|
# Added this from arch wiki https://wiki.archlinux.org/title/System_time
|
||||||
time_zone="$(curl --fail https://ipapi.co/timezone)"
|
time_zone="$(curl --fail https://ipapi.co/timezone)"
|
||||||
echo -ne "
|
echo -ne "
|
||||||
System detected your timezone to be '$time_zone' \n"
|
System detected your timezone to be '$time_zone' \n"
|
||||||
echo -ne "Is this correct?
|
echo -ne "Is this correct?
|
||||||
"
|
"
|
||||||
options=("Yes" "No")
|
options=("Yes" "No")
|
||||||
select_option "${options[@]}"
|
select_option "${options[@]}"
|
||||||
|
|
||||||
|
@ -171,14 +171,14 @@ timezone () {
|
||||||
echo "${time_zone} set as timezone"
|
echo "${time_zone} set as timezone"
|
||||||
export TIMEZONE=$time_zone;;
|
export TIMEZONE=$time_zone;;
|
||||||
n|N|no|NO|No)
|
n|N|no|NO|No)
|
||||||
echo "Please enter your desired timezone e.g. Europe/London :"
|
echo "Please enter your desired timezone e.g. Europe/London :"
|
||||||
read -r new_timezone
|
read -r new_timezone
|
||||||
echo "${new_timezone} set as timezone"
|
echo "${new_timezone} set as timezone"
|
||||||
export TIMEZONE=$new_timezone;;
|
export TIMEZONE=$new_timezone;;
|
||||||
*) echo "Wrong option. Try again";timezone;;
|
*) echo "Wrong option. Try again";timezone;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
# @description Set user's keyboard mapping.
|
# @description Set user's keyboard mapping.
|
||||||
keymap () {
|
keymap () {
|
||||||
echo -ne "
|
echo -ne "
|
||||||
Please select key board layout from this list"
|
Please select key board layout from this list"
|
||||||
|
@ -236,18 +236,18 @@ echo -ne "
|
||||||
drivessd
|
drivessd
|
||||||
}
|
}
|
||||||
|
|
||||||
# @description Gather username and password to be used for installation.
|
# @description Gather username and password to be used for installation.
|
||||||
userinfo () {
|
userinfo () {
|
||||||
# Loop through user input until the user gives a valid username
|
# Loop through user input until the user gives a valid username
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -r -p "Please enter username: " username
|
read -r -p "Please enter username: " username
|
||||||
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
|
if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
echo "Incorrect username."
|
echo "Incorrect username."
|
||||||
done
|
done
|
||||||
export USERNAME=$username
|
export USERNAME=$username
|
||||||
|
|
||||||
while true
|
while true
|
||||||
|
@ -264,22 +264,22 @@ userinfo () {
|
||||||
done
|
done
|
||||||
export PASSWORD=$PASSWORD1
|
export PASSWORD=$PASSWORD1
|
||||||
|
|
||||||
# Loop through user input until the user gives a valid hostname, but allow the user to force save
|
# Loop through user input until the user gives a valid hostname, but allow the user to force save
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
read -r -p "Please name your machine: " name_of_machine
|
read -r -p "Please name your machine: " name_of_machine
|
||||||
# hostname regex (!!couldn't find spec for computer name!!)
|
# hostname regex (!!couldn't find spec for computer name!!)
|
||||||
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
|
if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
# if validation fails allow the user to force saving of the hostname
|
# if validation fails allow the user to force saving of the hostname
|
||||||
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
|
read -r -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force
|
||||||
if [[ "${force,,}" = "y" ]]
|
if [[ "${force,,}" = "y" ]]
|
||||||
then
|
then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
export NAME_OF_MACHINE=$name_of_machine
|
export NAME_OF_MACHINE=$name_of_machine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ echo -ne "
|
||||||
Creating Filesystems
|
Creating Filesystems
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
# @description Creates the btrfs subvolumes.
|
# @description Creates the btrfs subvolumes.
|
||||||
createsubvolumes () {
|
createsubvolumes () {
|
||||||
btrfs subvolume create /mnt/@
|
btrfs subvolume create /mnt/@
|
||||||
btrfs subvolume create /mnt/@home
|
btrfs subvolume create /mnt/@home
|
||||||
|
@ -362,11 +362,11 @@ mountallsubvol () {
|
||||||
mount -o "${MOUNT_OPTIONS}",subvol=@home "${partition3}" /mnt/home
|
mount -o "${MOUNT_OPTIONS}",subvol=@home "${partition3}" /mnt/home
|
||||||
}
|
}
|
||||||
|
|
||||||
# @description BTRFS subvolulme creation and mounting.
|
# @description BTRFS subvolulme creation and mounting.
|
||||||
subvolumesetup () {
|
subvolumesetup () {
|
||||||
# create nonroot subvolumes
|
# create nonroot subvolumes
|
||||||
createsubvolumes
|
createsubvolumes
|
||||||
# unmount root to remount with subvolume
|
# unmount root to remount with subvolume
|
||||||
umount /mnt
|
umount /mnt
|
||||||
# mount @ subvolume
|
# mount @ subvolume
|
||||||
mount -o "${MOUNT_OPTIONS}",subvol=@ "${partition3}" /mnt
|
mount -o "${MOUNT_OPTIONS}",subvol=@ "${partition3}" /mnt
|
||||||
|
@ -386,33 +386,36 @@ fi
|
||||||
|
|
||||||
if [[ "${FS}" == "btrfs" ]]; then
|
if [[ "${FS}" == "btrfs" ]]; then
|
||||||
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
|
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
|
||||||
mkfs.btrfs -L ROOT "${partition3}" -f
|
mkfs.btrfs -f "${partition3}"
|
||||||
mount -t btrfs "${partition3}" /mnt
|
mount -t btrfs "${partition3}" /mnt
|
||||||
subvolumesetup
|
subvolumesetup
|
||||||
elif [[ "${FS}" == "ext4" ]]; then
|
elif [[ "${FS}" == "ext4" ]]; then
|
||||||
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
|
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
|
||||||
mkfs.ext4 -L ROOT "${partition3}"
|
mkfs.ext4 "${partition3}"
|
||||||
mount -t ext4 "${partition3}" /mnt
|
mount -t ext4 "${partition3}" /mnt
|
||||||
elif [[ "${FS}" == "luks" ]]; then
|
elif [[ "${FS}" == "luks" ]]; then
|
||||||
mkfs.vfat -F32 -n "EFIBOOT" "${partition2}"
|
mkfs.vfat -F32 "${partition2}"
|
||||||
# enter luks password to cryptsetup and format root partition
|
# enter luks password to cryptsetup and format root partition
|
||||||
echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat "${partition3}" -
|
echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat "${partition3}" -
|
||||||
# open luks container and ROOT will be place holder
|
# open luks container and ROOT will be place holder
|
||||||
echo -n "${LUKS_PASSWORD}" | cryptsetup open "${partition3}" ROOT -
|
echo -n "${LUKS_PASSWORD}" | cryptsetup open "${partition3}" ROOT -
|
||||||
# now format that container
|
# now format that container
|
||||||
mkfs.btrfs -L ROOT "${partition3}"
|
mkfs.btrfs "${partition3}"
|
||||||
# create subvolumes for btrfs
|
# create subvolumes for btrfs
|
||||||
mount -t btrfs "${partition3}" /mnt
|
mount -t btrfs "${partition3}" /mnt
|
||||||
subvolumesetup
|
subvolumesetup
|
||||||
|
ENCRYPTED_PARTITION_UUID=$(blkid -s UUID -o value "${partition3}")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
BOOT_UUID=$(blkid -s UUID -o value "${partition2}")
|
||||||
|
|
||||||
sync
|
sync
|
||||||
if ! mountpoint -q /mnt; then
|
if ! mountpoint -q /mnt; then
|
||||||
echo "ERROR! Failed to mount ${partition3} to /mnt after multiple attempts."
|
echo "ERROR! Failed to mount ${partition3} to /mnt after multiple attempts."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p /mnt/boot/efi
|
mkdir -p /mnt/boot/efi
|
||||||
mount -t vfat -L EFIBOOT /mnt/boot/
|
mount -t vfat -U "${BOOT_UUID}" /mnt/boot/
|
||||||
|
|
||||||
if ! grep -qs '/mnt' /proc/mounts; then
|
if ! grep -qs '/mnt' /proc/mounts; then
|
||||||
echo "Drive is not mounted can not continue"
|
echo "Drive is not mounted can not continue"
|
||||||
|
@ -435,8 +438,8 @@ fi
|
||||||
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
|
echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf
|
||||||
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
|
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
|
||||||
|
|
||||||
genfstab -L /mnt >> /mnt/etc/fstab
|
genfstab -U /mnt >> /mnt/etc/fstab
|
||||||
echo "
|
echo "
|
||||||
Generated /etc/fstab:
|
Generated /etc/fstab:
|
||||||
"
|
"
|
||||||
cat /mnt/etc/fstab
|
cat /mnt/etc/fstab
|
||||||
|
@ -475,14 +478,14 @@ arch-chroot /mnt /bin/bash -c "KEYMAP='${KEYMAP}' /bin/bash" <<EOF
|
||||||
|
|
||||||
echo -ne "
|
echo -ne "
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Network Setup
|
Network Setup
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
pacman -S --noconfirm --needed networkmanager dhclient
|
pacman -S --noconfirm --needed networkmanager dhclient
|
||||||
systemctl enable --now NetworkManager
|
systemctl enable --now NetworkManager
|
||||||
echo -ne "
|
echo -ne "
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Setting up mirrors for optimal download
|
Setting up mirrors for optimal download
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
pacman -S --noconfirm --needed pacman-contrib curl
|
pacman -S --noconfirm --needed pacman-contrib curl
|
||||||
|
@ -504,7 +507,7 @@ sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg
|
||||||
fi
|
fi
|
||||||
echo -ne "
|
echo -ne "
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
Setup Language to US and set locale
|
Setup Language to US and set locale
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
||||||
|
@ -572,7 +575,7 @@ echo -ne "
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
"
|
"
|
||||||
groupadd libvirt
|
groupadd libvirt
|
||||||
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
|
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
|
||||||
echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash"
|
echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash"
|
||||||
echo "$USERNAME:$PASSWORD" | chpasswd
|
echo "$USERNAME:$PASSWORD" | chpasswd
|
||||||
echo "$USERNAME password set"
|
echo "$USERNAME password set"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user