commit f8ed279e29d334624e6cbfbfad43dfc40472b69c
parent c0aa7665f5a80e799954e3e20ae173c7ef70546d
Author: awy <awy@awy.one>
Date: Sun, 9 Mar 2025 19:25:28 +0300
shcheck+
Diffstat:
M | install.sh | | | 76 | ++++++++++++++++++++++++++++++++++++---------------------------------------- |
M | post_chroot.sh | | | 20 | ++++++++++---------- |
2 files changed, 46 insertions(+), 50 deletions(-)
diff --git a/install.sh b/install.sh
@@ -1,13 +1,9 @@
#!/bin/sh
set -e
-export red="\033[1;31m"
-export green="\033[1;32m"
-export cyan="\033[0;36m"
-export normal="\033[0m"
dinitctl start ntpd
-cpuVendorID=$(grep -m 1 'vendor_id' /proc/cpuinfo | awk '{print $3}')
+cpuvendor=$(grep -m 1 'vendor_id' /proc/cpuinfo | awk '{print $3}')
title() {
clear
@@ -25,60 +21,60 @@ title() {
}
diskpart(){
- mkfs.fat -F32 /dev/"$boot_drive"
- mkfs.ext4 -F /dev/"$root_drive"
- mount /dev/"$root_drive" /mnt
+ mkfs.fat -F32 /dev/"$bootdrive"
+ mkfs.ext4 -F /dev/"$rootdrive"
+ mount /dev/"$rootdrive" /mnt
mkdir /mnt/boot
mkdir /mnt/home
}
-binKernel(){
+binkernel(){
mkdir /mnt/boot/efi
- mount /dev/"$boot_drive" /mnt/boot/efi
+ mount /dev/"$bootdrive" /mnt/boot/efi
pacman -Sy --confirm
- case $choosenKernel in
+ case $kerneltype in
1) basestrap /mnt base dinit seatd-dinit linux linux-headers ;;
2) basestrap /mnt base dinit seatd-dinit linux-zen linux-zen-headers ;;
- *) printf ${red}"Invalid kernel${normal}" && exit 1 ;;
+ *) printf "Invalid kernel" && exit 1 ;;
esac
}
-customKernel(){
- mount /dev/"$boot_drive" /mnt/boot
+customkernel(){
+ mount /dev/"$bootdrive" /mnt/boot
pacman -Sy --confirm
basestrap /mnt base dinit seatd-dinit
cp .config /mnt/usr/src
}
-getPass(){
+getpass(){
stty -echo
read -r choice
stty echo
echo "$choice"
}
-getUserData(){
+getuserdata(){
printf "Enter root password: "
- rootpass=$(getPass)
+ rootpass=$(getpass)
echo
printf "Enter username: "
read -r username
printf "Enter password for %s: " "$username"
- userpass=$(getPass)
+ userpass=$(getpass)
echo
printf "Enter hostname: "
read -r hostname
- printf ${red}"Choose Linux Kernel:${normal}\n1. Default kernel\n2. Zen kernel\n3. Custom kernel${normal}\nYour choose: "
- read -r choosenKernel
+ printf "Choose Linux Kernel:\n1. Default kernel\n2. Zen kernel\n3. Custom kernel\nYour choose: "
+ read -r kerneltype
printf "Enter disk label (e.g. sda, nvme0n1p <- p is mandatory in nvme case): "
- read -r disk_drive
+ read -r diskdrive
printf "Enter space-separated partition numbers (e.g., 5 6 for 5 boot 6 root): "
read -r partitions
- root_drive="$disk_drive${partitions##* }"
- boot_drive="$disk_drive${partitions%% *}"
+ rootdrive="$diskdrive${partitions##* }"
+ bootdrive="$diskdrive${partitions%% *}"
while true; do
title
- printf ${normal}"Your CPU Vendor detected as ${green}$cpuVendorID${normal}, is that right? Y/N:\n"
+ printf "Your CPU Vendor detected as %s, is that right? Y/N: " "$cpuvendor"
read -r answer
case "$answer" in
y|Y)
@@ -93,19 +89,19 @@ getUserData(){
}
title
-getUserData
+getuserdata
diskpart
-case $choosenKernel in
- 1 | 2) binKernel ;;
- 3) customKernel ;;
- *) printf ${red}"Invalid kernel${normal}" && exit 1 ;;
+case $kerneltype in
+ 1 | 2) binkernel ;;
+ 3) customkernel ;;
+ *) printf "Invalid kernel type" && exit 1 ;;
esac
-case $cpuVendorID in
+case $cpuvendor in
GenuineIntel)
basestrap /mnt intel-ucode
- if [ "$choosenKernel" = 3 ]; then
+ if [ "$kerneltype" = 3 ]; then
pacman -S iucode-tool --noconfirm
CPUFAM=$(printf '%02x\n' "$(lscpu | grep -E '^CPU family:' | awk '{print $3}')")
MODEL=$(printf '%02x\n' "$(lscpu | grep -E '^Model:' | awk '{print $2}')")
@@ -119,13 +115,13 @@ case $cpuVendorID in
AuthenticAMD)
basestrap /mnt amd-ucode ;;
*)
- printf ${red}"Unsupported CPU Vendor. Possibly there is error in detection script.${normal}\n" && exit 1 ;;
+ printf "Unsupported CPU Vendor. Possibly there is error in detection script.\n" && exit 1 ;;
esac
-UUID_ROOT=$(blkid -s UUID -o value /dev/"$root_drive")
-UUID_BOOT=$(blkid -s UUID -o value /dev/"$boot_drive")
+UUID_ROOT=$(blkid -s UUID -o value /dev/"$rootdrive")
+UUID_BOOT=$(blkid -s UUID -o value /dev/"$bootdrive")
-if [ "$choosenKernel" = 3 ]; then
+if [ "$kerneltype" = 3 ]; then
echo "UUID=$UUID_BOOT /boot vfat defaults,noatime 0 2" > /mnt/etc/fstab
else
echo "UUID=$UUID_BOOT /boot/efi vfat defaults,noatime 0 2" > /mnt/etc/fstab
@@ -133,20 +129,20 @@ fi
echo "UUID=$UUID_ROOT / ext4 defaults,noatime 0 1" >> /mnt/etc/fstab
-export disk_drive
-export root_drive
-export boot_drive
+export diskdrive
+export rootdrive
+export bootdrive
export hostname
export username
export rootpass
export userpass
-export choosenKernel
+export kerneltype
export partitions
cp post_chroot.sh /mnt
artix-chroot /mnt ./post_chroot.sh
-if [ "$choosenKernel" != 3 ]; then
+if [ "$kerneltype" != 3 ]; then
mv /mnt/boot/efi/EFI/grub /mnt/boot/efi/EFI/BOOT
mv /mnt/boot/efi/EFI/BOOT/grubx64.efi /mnt/boot/efi/EFI/BOOT/BOOTX64.EFI
fi
diff --git a/post_chroot.sh b/post_chroot.sh
@@ -20,22 +20,22 @@ export LC_COLLATE="C"
echo "$hostname" > /etc/hostname
-PARTUUID_ROOT=$(blkid -s PARTUUID -o value /dev/"$root_drive")
+PARTUUID_ROOT=$(blkid -s PARTUUID -o value /dev/"$rootdrive")
-binKernel(){
+binkernel(){
echo "options hid_apple fnmode=0" > /etc/modprobe.d/hid_apple.conf
pacman -S grub os-prober efibootmgr --noconfirm
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
sed -i "s#GRUB_CMDLINE_LINUX_DEFAULT=.*#GRUB_CMDLINE_LINUX_DEFAULT=\"loglevel=3 quiet options root=PARTUUID=$PARTUUID_ROOT rw nvidia-drm.modeset=1 modeset=1 fbdev=1 intel_iommu=on\"#g" /etc/default/grub
sed -i -e 's/MODULES=()/MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)/g' /etc/mkinitcpio.conf
- case $choosenKernel in
+ case $kerneltype in
1) pacman -S linux-headers --noconfirm ;;
2) pacman -S linux-zen-headers --noconfirm ;;
- *) printf ${red}"Invalid kernel${normal}" && exit 1 ;;
+ *) printf "Invalid kernel" && exit 1 ;;
esac
}
-customKernel(){
+customkernel(){
latestKernel=$(curl -s https://www.kernel.org/ | grep -A 1 'latest_link' | grep -oP '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1)
majorVersion=$(echo "$latestKernel" | cut -d'.' -f1)
pacman -S efibootmgr --noconfirm
@@ -57,14 +57,14 @@ customKernel(){
make headers_install
mkdir -p /boot/EFI/BOOT
cp arch/x86/boot/bzImage /boot/EFI/BOOT/BOOTX64.EFI
- _diskdrivewop="${disk_drive%p}"
+ _diskdrivewop="${diskdrive%p}"
efibootmgr -c -d /dev/"$_diskdrivewop" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI'
}
-case $choosenKernel in
- 1 | 2) binKernel && grub-mkconfig -o /boot/grub/grub.cfg ;;
- 3) customKernel ;;
- *) printf ${red}"Invalid kernel${normal}" && exit 1 ;;
+case $kerneltype in
+ 1 | 2) binkernel && grub-mkconfig -o /boot/grub/grub.cfg ;;
+ 3) customkernel ;;
+ *) printf "Invalid kernel" && exit 1 ;;
esac
# use dash as sh