post_chroot.sh (6072B) - View raw
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188#!/bin/sh set -e ln -sf /usr/share/zoneinfo/Europe/Moscow /etc/localtime hwclock --systohc # nvidia fixes mkdir -p /etc/modprobe.d/ cat <<EOL >>/etc/modprobe.d/nvidia.conf options nvidia NVreg_UsePageAttributeTable=1 options nvidia-drm fbdev=1 options nvidia NVreg_RegistryDwords="PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3" EOL sed -i -e "/^#en_US.UTF-8/s/^#//" /etc/locale.gen locale-gen echo LANG=en_US.UTF-8 >/etc/locale.conf export LANG="en_US.UTF-8" export LC_COLLATE="C" echo "$hostname" >/etc/hostname UUID_ROOT=$(blkid -s UUID -o value /dev/"$rootdrive") if [ "$encryption" = 1 ]; then UUID_CRYPTROOT=$(blkid -s UUID -o value /dev/mapper/cryptlvm) fi binkernel() { pacman -S efibootmgr --noconfirm echo "options hid_apple fnmode=0" >/etc/modprobe.d/hid_apple.conf mkdir -p /etc/kernel mkdir -p /boot/EFI/BOOT case $kerneltype in 1) cat <<EOL >/etc/mkinitcpio.d/linux.preset ALL_kver="/boot/vmlinuz-linux" PRESETS=('default') default_uki="/boot/EFI/BOOT/BOOTX64.efi" EOL ;; 2) cat <<EOL >/etc/mkinitcpio.d/linux-zen.preset ALL_kver="/boot/vmlinuz-linux-zen" PRESETS=('default') default_uki="/boot/EFI/BOOT/BOOTX64.efi" EOL ;; *) printf "Invalid kernel" && exit 1 ;; esac if [ "$encryption" = 1 ]; then echo "cryptdevice=UUID=$UUID_ROOT:cryptlvm root=UUID=$UUID_CRYPTROOT rw" >/etc/kernel/cmdline sed -i "s#HOOKS=.*#HOOKS=(base udev microcode modconf keyboard keymap consolefont block encrypt lvm2 filesystems fsck)#g" /etc/mkinitcpio.conf else echo "root=UUID=$UUID_ROOT rw" >/etc/kernel/cmdline sed -i "s#HOOKS=.*#HOOKS=(base udev autodetect microcode modconf keyboard keymap consolefont block filesystems fsck)#g" /etc/mkinitcpio.conf fi case $kerneltype in 1) pacman -S linux-headers --noconfirm ;; 2) pacman -S linux-zen-headers --noconfirm ;; *) printf "Invalid kernel" && exit 1 ;; esac efibootmgr -c -d /dev/"$diskdrive" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI' } 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 cd /usr/src/ curl -Lo /usr/src/linux.tar.xz "https://cdn.kernel.org/pub/linux/kernel/v$majorversion.x/linux-$latestkernel.tar.xz" tar -xf "linux.tar.xz" rm -f "linux.tar.xz" mv "linux-$latestkernel" "linux" cd "linux" mv /usr/src/.config .config sed -i -e '/^CONFIG_CMDLINE="root=.*/c\' -e "CONFIG_CMDLINE=\"root=UUID=$UUID_ROOT init=/sbin/dinit-init\"" .config pacman -S bc perl make diffutils clang flex bison python3 llvm lld rsync --noconfirm export CC=clang HOSTCC=clang LLVM=1 LLVM_IAS="1" CFLAGS="-O3 -march=native -pipe" KCFLAGS="-O3 -march=native -pipe" make olddefconfig make menuconfig make -j"$(nproc)" make modules make modules_install make headers make headers_install mkdir -p /boot/EFI/BOOT cp arch/x86/boot/bzImage /boot/EFI/BOOT/BOOTX64.EFI efibootmgr -c -d /dev/"$diskdrive" -p "${partitions%% *}" -L "linux" -l '\EFI\BOOT\BOOTX64.EFI' } case $kerneltype in 1 | 2) binkernel ;; 3) customkernel ;; *) printf "Invalid kernel" && exit 1 ;; esac # use dash as sh pacman -S dash zsh --noconfirm ln -sfT dash /usr/bin/sh mkdir -p /etc/pacman.d/hooks cat <<EOL >>/etc/pacman.d/hooks/bash.hook [Trigger] Type = Package Operation = Install Operation = Upgrade Target = bash [Action] Description = Re-pointing /bin/sh symlink to dash... When = PostTransaction Exec = /usr/bin/ln -sfT dash /usr/bin/sh Depends = dash EOL useradd -m -g wheel -s /bin/zsh "$username" echo "root:$rootpass" | chpasswd echo "$username:$userpass" | chpasswd cat <<EOL >>/etc/hosts 127.0.0.1 localhost ::1 localhost 127.0.1.1 $hostname.localdomain $hostname EOL # enable arch repos pacman -Sy --noconfirm pacman -S artix-archlinux-support --noconfirm echo "[extra]" >>/etc/pacman.conf echo "Include = /etc/pacman.d/mirrorlist-arch" >>/etc/pacman.conf # 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 pacman -Sy --noconfirm # enable my custom repo echo "[awy-arch]" >>/etc/pacman.conf echo "Server = https://git.awy.one/\$repo.git/plain/\$arch/" >>/etc/pacman.conf pacman-key --recv-keys B34B86B597BFE8667CE1EC9DB88FFCF0CC468933 pacman-key --lsign-key B34B86B597BFE8667CE1EC9DB88FFCF0CC468933 pacman -Sy --noconfirm pacman -S doas --noconfirm cat <<EOL >>/etc/doas.conf permit nopass root permit :wheel permit persist :wheel permit nopass :wheel cmd pacman args -Syu permit nopass :wheel cmd pacman args -Syyu permit nopass :wheel cmd pacman args -Syyu --noconfirm permit nopass :wheel cmd pacman args -Syyuw --noconfirm permit nopass :wheel cmd pacman args --sync -y -- permit nopass :wheel cmd pacman args --sync -y -u -- permit nopass :wheel cmd pacman args --sync -c -c -- permit nopass :wheel cmd shutdown permit nopass :wheel cmd reboot permit nopass :wheel cmd wifi-menu permit nopass :wheel cmd mount permit nopass :wheel cmd umount permit nopass :wheel cmd lsblk args -rpo "uuid,name,type,size,label,mountpoint,fstype" EOL pacman -S dhcpcd dhcpcd-dinit dbus-dinit --noconfirm ln -sf /etc/dinit.d/dhcpcd /etc/dinit.d/boot.d/ ln -sf /etc/dinit.d/dbus /etc/dinit.d/boot.d/ ln -sf /etc/dinit.d/seatd /etc/dinit.d/boot.d/ pacman -S nvidia-open-dkms nvidia-utils --noconfirm pacman -S libva-nvidia-driver --noconfirm sed -i 's|ACTIVE_CONSOLES="/dev/tty\[1-6\]"|ACTIVE_CONSOLES="/dev/tty[1-2]"|' /etc/dinit.d/config/console.conf interface=$(ip route show default | awk '{print $5}') routerip=$(ip route show default | awk '{print $3}') machineip=$(ip -4 addr show dev "$interface" | awk '/inet/ {print $2}') dnsserver="8.8.8.8" cat <<EOL >>/etc/dhcpcd.conf noarp interface $interface static ip_address=$machineip static routers=$routerip static domain_name_servers=$dnsserver EOL rm -rf /home/"$username"/.bash* rm /post_chroot.sh