artix

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

post_chroot.sh (5390B)


      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 make diffutils clang flex bison python3 llvm lld rsync --noconfirm
     82   export CC=clang HOSTCC=clang LLVM=1 LLVM_IAS="1" CFLAGS="-O3 -march=native -pipe" KCFLAGS="-O3 -march=native -pipe"
     83   make olddefconfig
     84   make menuconfig
     85   make -j"$(nproc)"
     86   make modules
     87   make modules_install
     88   make headers
     89   make headers_install
     90   mkdir -p /boot/EFI/BOOT
     91   cp arch/x86/boot/bzImage /boot/EFI/BOOT/BOOTX64.EFI
     92   efibootmgr -c -d /dev/"$diskdrive" -p "${partitions%% *}"  -L "linux" -l '\EFI\BOOT\BOOTX64.EFI'
     93 }
     94 
     95 case $kerneltype in
     96   1 | 2) binkernel ;;
     97   3) customkernel ;;
     98   *) printf "Invalid kernel" && exit 1 ;;
     99 esac
    100 
    101 # use dash as sh
    102 pacman -Sy dash zsh --noconfirm
    103 ln -sfT dash /usr/bin/sh
    104 mkdir -p /etc/pacman.d/hooks
    105 cat <<EOL >> /etc/pacman.d/hooks/bash.hook
    106 [Trigger]
    107 Type = Package
    108 Operation = Install
    109 Operation = Upgrade
    110 Target = bash
    111 
    112 [Action]
    113 Description = Re-pointing /bin/sh symlink to dash...
    114 When = PostTransaction
    115 Exec = /usr/bin/ln -sfT dash /usr/bin/sh
    116 Depends = dash
    117 EOL
    118 
    119 useradd -m -g wheel -s /bin/zsh "$username"
    120 
    121 echo "root:$rootpass" | chpasswd
    122 echo "$username:$userpass" | chpasswd
    123 
    124 cat <<EOL >> /etc/hosts
    125 127.0.0.1	localhost
    126 ::1		localhost
    127 127.0.1.1 	$hostname.localdomain $hostname
    128 EOL
    129 
    130 # enable arch repos
    131 pacman -Sy --noconfirm
    132 pacman -S artix-archlinux-support --noconfirm
    133 echo "[extra]" >> /etc/pacman.conf
    134 echo "Include = /etc/pacman.d/mirrorlist-arch" >> /etc/pacman.conf
    135 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
    136 pacman -Sy --noconfirm
    137 
    138 pacman -S doas --noconfirm
    139 cat <<EOL >> /etc/doas.conf
    140 permit nopass root
    141 permit :wheel
    142 permit persist :wheel
    143 permit nopass :wheel cmd pacman args -Syu
    144 permit nopass :wheel cmd pacman args -Syyu
    145 permit nopass :wheel cmd pacman args -Syyu --noconfirm
    146 permit nopass :wheel cmd pacman args -Syyuw --noconfirm
    147 permit nopass :wheel cmd pacman args --sync -y --
    148 permit nopass :wheel cmd pacman args --sync -y -u --
    149 permit nopass :wheel cmd shutdown
    150 permit nopass :wheel cmd reboot
    151 permit nopass :wheel cmd wifi-menu
    152 permit nopass :wheel cmd mount
    153 permit nopass :wheel cmd umount
    154 permit nopass :wheel cmd lsblk args -rpo "uuid,name,type,size,label,mountpoint,fstype"
    155 EOL
    156 
    157 
    158 pacman -S dhcpcd dhcpcd-dinit dbus-dinit --noconfirm
    159 ln -sf /etc/dinit.d/dhcpcd /etc/dinit.d/boot.d/
    160 ln -sf /etc/dinit.d/dbus /etc/dinit.d/boot.d/
    161 ln -sf /etc/dinit.d/seatd /etc/dinit.d/boot.d/
    162 
    163 pacman -S nvidia-open-dkms nvidia-utils --noconfirm
    164 pacman -S libva-nvidia-driver --noconfirm
    165 
    166 sed -i 's|ACTIVE_CONSOLES="/dev/tty\[1-6\]"|ACTIVE_CONSOLES="/dev/tty[1-2]"|' /etc/dinit.d/config/console.conf
    167 
    168 rm -rf /home/"$username"/.bash*
    169 
    170 rm /post_chroot.sh