post_chroot.sh (5054B)
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 35 case $kerneltype in 36 1) 37 cat <<EOL > /etc/mkinitcpio.d/linux.preset 38 ALL_kver="/boot/vmlinuz-linux" 39 PRESETS=('default') 40 default_uki="/boot/EFI/BOOT/BOOTX64.efi" 41 EOL 42 ;; 43 2) 44 cat <<EOL > /etc/mkinitcpio.d/linux-zen.preset 45 ALL_kver="/boot/vmlinuz-linux-zen" 46 PRESETS=('default') 47 default_uki="/boot/EFI/BOOT/BOOTX64.efi" 48 EOL 49 ;; 50 *) printf "Invalid kernel" && exit 1 ;; 51 esac 52 53 if [ "$encryption" = 1 ]; then 54 echo "cryptdevice=UUID=$UUID_ROOT:cryptlvm root=UUID=$UUID_CRYPTROOT rw" > /etc/kernel/cmdline 55 sed -i "s#HOOKS=.*#HOOKS=(base udev microcode modconf keyboard keymap consolefont block encrypt lvm2 filesystems fsck)#g" /etc/mkinitcpio.conf 56 else 57 echo "root=UUID=$UUID_ROOT rw" > /etc/kernel/cmdline 58 sed -i "s#HOOKS=.*#HOOKS=(base udev autodetect microcode modconf keyboard keymap consolefont block filesystems fsck)#g" /etc/mkinitcpio.conf 59 fi 60 case $kerneltype in 61 1) pacman -S linux-headers --noconfirm ;; 62 2) pacman -S linux-zen-headers --noconfirm ;; 63 *) printf "Invalid kernel" && exit 1 ;; 64 esac 65 efibootmgr -c -d /dev/"$diskdrive" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI' 66 } 67 68 customkernel() 69 { 70 latestkernel=$(curl -s https://www.kernel.org/ | grep -A 1 'latest_link' | grep -oP '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1) 71 majorversion=$(echo "$latestkernel" | cut -d'.' -f1) 72 pacman -S efibootmgr --noconfirm 73 cd /usr/src/ 74 curl -Lo /usr/src/linux.tar.xz "https://cdn.kernel.org/pub/linux/kernel/v$majorversion.x/linux-$latestkernel.tar.xz" 75 tar -xf "linux.tar.xz" 76 rm -f "linux.tar.xz" 77 mv "linux-$latestkernel" "linux" 78 cd "linux" 79 mv /usr/src/.config .config 80 sed -i -e '/^CONFIG_CMDLINE="root=.*/c\' -e "CONFIG_CMDLINE=\"root=UUID=$UUID_ROOT init=/sbin/dinit-init\"" .config 81 pacman -S bc perl bison make diffutils gcc flex rsync --noconfirm 82 make olddefconfig 83 make menuconfig 84 make -j"$(nproc)" 85 make modules 86 make modules_install 87 make headers 88 make headers_install 89 mkdir -p /boot/EFI/BOOT 90 cp arch/x86/boot/bzImage /boot/EFI/BOOT/BOOTX64.EFI 91 efibootmgr -c -d /dev/"$diskdrive" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI' 92 } 93 94 case $kerneltype in 95 1 | 2) binkernel ;; 96 3) customkernel ;; 97 *) printf "Invalid kernel" && exit 1 ;; 98 esac 99 100 # use dash as sh 101 pacman -Sy dash zsh --noconfirm 102 ln -sfT dash /usr/bin/sh 103 mkdir -p /etc/pacman.d/hooks 104 cat <<EOL >> /etc/pacman.d/hooks/bash.hook 105 [Trigger] 106 Type = Package 107 Operation = Install 108 Operation = Upgrade 109 Target = bash 110 111 [Action] 112 Description = Re-pointing /bin/sh symlink to dash... 113 When = PostTransaction 114 Exec = /usr/bin/ln -sfT dash /usr/bin/sh 115 Depends = dash 116 EOL 117 118 useradd -m -g wheel -s /bin/zsh "$username" 119 120 echo "root:$rootpass" | chpasswd 121 echo "$username:$userpass" | chpasswd 122 123 cat <<EOL >> /etc/hosts 124 127.0.0.1 localhost 125 ::1 localhost 126 127.0.1.1 $hostname.localdomain $hostname 127 EOL 128 129 # enable arch repos 130 pacman -Sy --noconfirm 131 pacman -S artix-archlinux-support --noconfirm 132 echo "[extra]" >> /etc/pacman.conf 133 echo "Include = /etc/pacman.d/mirrorlist-arch" >> /etc/pacman.conf 134 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 135 pacman -Sy --noconfirm 136 137 pacman -S doas --noconfirm 138 cat <<EOL >> /etc/doas.conf 139 permit nopass root 140 permit :wheel 141 permit persist :wheel 142 permit nopass :wheel cmd pacman args -Syu 143 permit nopass :wheel cmd pacman args -Syyu 144 permit nopass :wheel cmd pacman args -Syyu --noconfirm 145 permit nopass :wheel cmd pacman args -Syyuw --noconfirm 146 permit nopass :wheel cmd pacman args --sync -y -- 147 permit nopass :wheel cmd pacman args --sync -y -u -- 148 permit nopass :wheel cmd shutdown 149 permit nopass :wheel cmd reboot 150 permit nopass :wheel cmd wifi-menu 151 permit nopass :wheel cmd mount 152 permit nopass :wheel cmd umount 153 EOL 154 155 156 pacman -S dhcpcd dhcpcd-dinit dbus-dinit --noconfirm 157 ln -sf /etc/dinit.d/dhcpcd /etc/dinit.d/boot.d/ 158 ln -sf /etc/dinit.d/dbus /etc/dinit.d/boot.d/ 159 ln -sf /etc/dinit.d/seatd /etc/dinit.d/boot.d/ 160 161 pacman -S nvidia-open-dkms nvidia-utils --noconfirm 162 pacman -S libva-nvidia-driver --noconfirm 163 164 rm -rf /home/"$username"/.bash* 165 166 rm /post_chroot.sh