artix

posix artix installation script
git clone https://git.awy.one/artix.git
Log | Files | Refs | README | LICENSE

post_chroot.sh (4281B)


      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 PARTUUID_ROOT=$(blkid -s PARTUUID -o value /dev/"$rootdrive")
     24 
     25 binkernel()
     26 {
     27   echo "options hid_apple fnmode=0" > /etc/modprobe.d/hid_apple.conf
     28   pacman -S grub os-prober efibootmgr --noconfirm
     29   grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub
     30   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
     31   sed -i -e 's/MODULES=()/MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)/g' /etc/mkinitcpio.conf
     32   case $kerneltype in
     33     1) pacman -S linux-headers --noconfirm ;;
     34     2) pacman -S linux-zen-headers --noconfirm ;;
     35     *) printf "Invalid kernel" && exit 1 ;;
     36   esac
     37 }
     38 
     39 customkernel()
     40 {
     41   latestkernel=$(curl -s https://www.kernel.org/ | grep -A 1 'latest_link' | grep -oP '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n 1)
     42   majorversion=$(echo "$latestkernel" | cut -d'.' -f1)
     43   pacman -S efibootmgr --noconfirm
     44   cd /usr/src/
     45   curl -Lo /usr/src/linux.tar.xz "https://cdn.kernel.org/pub/linux/kernel/v$majorversion.x/linux-$latestkernel.tar.xz"
     46   tar -xf "linux.tar.xz"
     47   rm -f "linux.tar.xz"
     48   mv "linux-$latestkernel" "linux"
     49   cd "linux"
     50   mv /usr/src/.config .config
     51   sed -i -e '/^CONFIG_CMDLINE="root=PARTUUID=.*/c\' -e "CONFIG_CMDLINE=\"root=PARTUUID=$PARTUUID_ROOT init=/sbin/dinit-init nvidia_drm.modeset=1 nvidia_drm.fbdev=1\"" .config
     52   pacman -S bc perl bison make diffutils gcc flex rsync --noconfirm
     53   make olddefconfig
     54   make menuconfig
     55   make -j"$(nproc)"
     56   make modules
     57   make modules_install
     58   make headers
     59   make headers_install
     60   mkdir -p /boot/EFI/BOOT
     61   cp arch/x86/boot/bzImage /boot/EFI/BOOT/BOOTX64.EFI
     62   _diskdrivewop="${diskdrive%p}"
     63   efibootmgr -c -d /dev/"$_diskdrivewop" -p "${partitions%% *}"  -L "linux" -l '\EFI\BOOT\BOOTX64.EFI'
     64 }
     65 
     66 case $kerneltype in
     67   1 | 2) binkernel && grub-mkconfig -o /boot/grub/grub.cfg ;;
     68   3) customkernel ;;
     69   *) printf "Invalid kernel" && exit 1 ;;
     70 esac
     71 
     72 # use dash as sh
     73 pacman -Sy dash zsh --noconfirm
     74 ln -sfT dash /usr/bin/sh
     75 mkdir -p /etc/pacman.d/hooks
     76 cat <<EOL >> /etc/pacman.d/hooks/bash.hook
     77 [Trigger]
     78 Type = Package
     79 Operation = Install
     80 Operation = Upgrade
     81 Target = bash
     82 
     83 [Action]
     84 Description = Re-pointing /bin/sh symlink to dash...
     85 When = PostTransaction
     86 Exec = /usr/bin/ln -sfT dash /usr/bin/sh
     87 Depends = dash
     88 EOL
     89 
     90 useradd -m -g wheel -s /bin/zsh "$username"
     91 
     92 echo "root:$rootpass" | chpasswd
     93 echo "$username:$userpass" | chpasswd
     94 
     95 cat <<EOL >> /etc/hosts
     96 127.0.0.1	localhost
     97 ::1		localhost
     98 127.0.1.1 	$hostname.localdomain $hostname
     99 EOL
    100 
    101 # enable arch repos
    102 pacman -Sy --noconfirm
    103 pacman -S artix-archlinux-support --noconfirm
    104 echo "[extra]" >> /etc/pacman.conf
    105 echo "Include = /etc/pacman.d/mirrorlist-arch" >> /etc/pacman.conf
    106 pacman -Sy --noconfirm
    107 
    108 pacman -S sudo --noconfirm
    109 echo "%wheel ALL=(ALL:ALL) ALL" >/etc/sudoers.d/00-wheel-can-sudo
    110 echo "%wheel ALL=(ALL:ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/pacman -Syu,/usr/bin/pacman -Syyu,/usr/bin/pacman -Syyu --noconfirm,/usr/bin/loadkeys,/usr/bin/pacman -Syyuw --noconfirm,/usr/bin/pacman -S -y --config /etc/pacman.conf --,/usr/bin/pacman -S -y -u --config /etc/pacman.conf --" >/etc/sudoers.d/01-cmds-without-password
    111 echo "Defaults editor=/usr/bin/nvim" >/etc/sudoers.d/02-visudo-editor
    112 
    113 pacman -S dhcpcd dhcpcd-dinit dbus-dinit --noconfirm
    114 ln -sf /etc/dinit.d/dhcpcd /etc/dinit.d/boot.d/
    115 ln -sf /etc/dinit.d/dbus /etc/dinit.d/boot.d/
    116 
    117 pacman -S nvidia-open-dkms nvidia-utils --noconfirm
    118 pacman -S libva-nvidia-driver --noconfirm
    119 
    120 rm -rf /home/"$username"/.bash*
    121 
    122 rm /post_chroot.sh