post_chroot.sh (4927B)
1 #!/bin/sh 2 set -e 3 4 ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime 5 hwclock --systohc 6 7 # nvidia fixes 8 mkdir -p /etc/modprobe.d/ 9 cat <<EOL >> /etc/modprobe.d/nvidia.conf 10 options nvidia NVreg_UsePageAttributeTable=1 11 options nvidia-drm fbdev=1 12 options nvidia NVreg_RegistryDwords="PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3" 13 EOL 14 15 sed -i -e "/^#en_US.UTF-8/s/^#//" /etc/locale.gen 16 locale-gen 17 echo LANG=en_US.UTF-8 > /etc/locale.conf 18 export LANG="en_US.UTF-8" 19 export LC_COLLATE="C" 20 21 echo "$hostname" > /etc/hostname 22 23 UUID_ROOT=$(blkid -s UUID -o value /dev/"$rootdrive") 24 if [ "$encryption" = 1 ]; then 25 UUID_CRYPTROOT=$(blkid -s UUID -o value /dev/mapper/cryptlvm) 26 fi 27 28 binkernel() 29 { 30 pacman -S efibootmgr --noconfirm 31 echo "options hid_apple fnmode=0" > /etc/modprobe.d/hid_apple.conf 32 mkdir -p /etc/kernel 33 mkdir -p /boot/EFI/BOOT 34 cat <<EOL > /etc/mkinitcpio.d/linux.preset 35 ALL_kver="/boot/vmlinuz-linux" 36 PRESETS=('default') 37 default_uki="/boot/EFI/BOOT/BOOTX64.efi" 38 EOL 39 if [ "$encryption" = 1 ]; then 40 echo "cryptdevice=UUID=$UUID_ROOT:cryptlvm root=UUID=$UUID_CRYPTROOT rw intel_iommu=on" > /etc/kernel/cmdline 41 sed -i "s#HOOKS=.*#HOOKS=(base udev autodetect microcode modconf keyboard keymap consolefont block encrypt lvm2 filesystems fsck)#g" /etc/mkinitcpio.conf 42 else 43 echo "root=UUID=$UUID_ROOT rw intel_iommu=on" > /etc/kernel/cmdline 44 sed -i "s#HOOKS=.*#HOOKS=(base udev autodetect microcode modconf keyboard keymap consolefont block filesystems fsck)#g" /etc/mkinitcpio.conf 45 fi 46 case $kerneltype in 47 1) pacman -S linux-headers --noconfirm ;; 48 2) pacman -S linux-zen-headers --noconfirm ;; 49 *) printf "Invalid kernel" && exit 1 ;; 50 esac 51 _diskdrivewop="${diskdrive%p}" 52 efibootmgr -c -d /dev/"$_diskdrivewop" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI' 53 } 54 55 customkernel() 56 { 57 latestkernel=$(curl -s https://www.kernel.org/ | grep -A 1 'latest_link' | grep -oP '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1) 58 majorversion=$(echo "$latestkernel" | cut -d'.' -f1) 59 pacman -S efibootmgr --noconfirm 60 cd /usr/src/ 61 curl -Lo /usr/src/linux.tar.xz "https://cdn.kernel.org/pub/linux/kernel/v$majorversion.x/linux-$latestkernel.tar.xz" 62 tar -xf "linux.tar.xz" 63 rm -f "linux.tar.xz" 64 mv "linux-$latestkernel" "linux" 65 cd "linux" 66 mv /usr/src/.config .config 67 sed -i -e '/^CONFIG_CMDLINE="root=.*/c\' -e "CONFIG_CMDLINE=\"root=UUID=$UUID_ROOT init=/sbin/dinit-init\"" .config 68 pacman -S bc perl bison make diffutils gcc flex rsync --noconfirm 69 make olddefconfig 70 make menuconfig 71 make -j"$(nproc)" 72 make modules 73 make modules_install 74 make headers 75 make headers_install 76 mkdir -p /boot/EFI/BOOT 77 cp arch/x86/boot/bzImage /boot/EFI/BOOT/BOOTX64.EFI 78 _diskdrivewop="${diskdrive%p}" 79 efibootmgr -c -d /dev/"$_diskdrivewop" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI' 80 } 81 82 case $kerneltype in 83 1 | 2) binkernel ;; 84 3) customkernel ;; 85 *) printf "Invalid kernel" && exit 1 ;; 86 esac 87 88 # use dash as sh 89 pacman -Sy dash zsh --noconfirm 90 ln -sfT dash /usr/bin/sh 91 mkdir -p /etc/pacman.d/hooks 92 cat <<EOL >> /etc/pacman.d/hooks/bash.hook 93 [Trigger] 94 Type = Package 95 Operation = Install 96 Operation = Upgrade 97 Target = bash 98 99 [Action] 100 Description = Re-pointing /bin/sh symlink to dash... 101 When = PostTransaction 102 Exec = /usr/bin/ln -sfT dash /usr/bin/sh 103 Depends = dash 104 EOL 105 106 useradd -m -g wheel -s /bin/zsh "$username" 107 108 echo "root:$rootpass" | chpasswd 109 echo "$username:$userpass" | chpasswd 110 111 cat <<EOL >> /etc/hosts 112 127.0.0.1 localhost 113 ::1 localhost 114 127.0.1.1 $hostname.localdomain $hostname 115 EOL 116 117 # enable arch repos 118 pacman -Sy --noconfirm 119 pacman -S artix-archlinux-support --noconfirm 120 echo "[extra]" >> /etc/pacman.conf 121 echo "Include = /etc/pacman.d/mirrorlist-arch" >> /etc/pacman.conf 122 curl -s "https://archlinux.org/mirrorlist/?country=RU&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' > /etc/pacman.d/mirrorlist-arch 123 pacman -Sy --noconfirm 124 125 pacman -S doas --noconfirm 126 cat <<EOL >> /etc/doas.conf 127 permit nopass root 128 permit :wheel 129 permit persist :wheel 130 permit nopass :wheel cmd pacman args -Syu 131 permit nopass :wheel cmd pacman args -Syyu 132 permit nopass :wheel cmd pacman args -Syyu --noconfirm 133 permit nopass :wheel cmd pacman args -Syyuw --noconfirm 134 permit nopass :wheel cmd pacman args --sync -y -- 135 permit nopass :wheel cmd pacman args --sync -y -u -- 136 permit nopass :wheel cmd shutdown 137 permit nopass :wheel cmd reboot 138 permit nopass :wheel cmd wifi-menu 139 permit nopass :wheel cmd mount 140 permit nopass :wheel cmd umount 141 EOL 142 143 144 pacman -S dhcpcd dhcpcd-dinit dbus-dinit --noconfirm 145 ln -sf /etc/dinit.d/dhcpcd /etc/dinit.d/boot.d/ 146 ln -sf /etc/dinit.d/dbus /etc/dinit.d/boot.d/ 147 ln -sf /etc/dinit.d/seatd /etc/dinit.d/boot.d/ 148 149 pacman -S nvidia-open-dkms nvidia-utils --noconfirm 150 pacman -S libva-nvidia-driver --noconfirm 151 152 rm -rf /home/"$username"/.bash* 153 154 rm /post_chroot.sh