#!/usr/bin/env bash # shellcheck disable=SC1091 # shellcheck source=./setup.conf SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" CONFIG_FILE="$SCRIPT_DIR"/setup.conf if [[ -f "$CONFIG_FILE" ]]; then source "$CONFIG_FILE" else echo "ERROR! Missing file: setup.conf" exit 0 fi logo echo "basic installations" install_pkg networkmanager dhclient reflector \ rsync arch-install-scripts \ git pacman-contrib curl efibootmgr install_xorg() { install_pkg xorg xorg-server xorg-xinit } install_services() { install_pkg cups bluez bluez-utils cronie ntp dhcpcd } TOTALMEM="$(grep -i "memtotal" "/proc/meminfo" | grep -o '[[:digit:]]*')" CPU="$(grep -c ^processor /proc/cpuinfo)" if [[ $TOTALMEM -gt 8000000 ]]; then echo -ne " ------------------------------------------------------------------------- You have \"$CPU\" cores. And changing the makeflags for \"$CPU\" cores. As well as changing the compression settings. ------------------------------------------------------------------------- " sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$CPU\"/g" /etc/makepkg.conf sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $CPU -z -)/g" /etc/makepkg.conf fi echo "Setup Language and set locale" # sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen echo "$LOCALE" | sed -i "s/\"//g" >>/etc/locale.gen locale-gen timedatectl --no-ask-password set-timezone "$TIMEZONE" timedatectl --no-ask-password set-ntp 1 localectl --no-ask-password set-locale LANG="$LOCALE" LC_TIME="$LOCALE" localectl --no-ask-password set-keymap --no-convert "$KEYMAP" # Add sudo no password rights sed -i 's/^# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers #Add parallel downloading sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf #Enable multilib sed -i "/\[multilib\]/,/Include/"'s/^#//' /etc/pacman.conf # pacman -Sy --noconfirm refresh_pacman echo "Installing $DESKTOP" case "$DESKTOP" in "default") while IFS= read -r LINE; do echo "INSTALLING: $LINE" install_pkg "$LINE" done /boot/loader/entries/arch.conf elif [[ $LVM -eq 1 ]]; then echo -e "title\tArchTitus\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\ninitrd\t/$IMG\noptions\troot=/dev/$LVM_VG/${LVM_NAMES[0]} rw" >/boot/loader/entries/arch.conf else echo -e "title\tArchTitus\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\ninitrd\t/$IMG\noptions\troot=PARTUUID=$PART_UUID rw" >/boot/loader/entries/arch.conf fi echo -e "default arch\ntimeout\t5" >/boot/loader/loader.conf else echo "ERROR! Systemd-boot is not supported for BIOS systems" exit 0 fi ;; uefi) if [[ "$UEFI" -eq 1 ]]; then echo "Installing efistub" install_pkg efibootmgr if [[ "$LUKS" -eq 1 ]]; then efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "cryptdevice=PARTUUID=$PART_UUID:luks:allow-discards root=/dev/$LVM_VG/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux-fallback.img" efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "cryptdevice=PARTUUID=$PART_UUID:luks:allow-discards root=/dev/$LVM_VG/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux.img" elif [[ "$LVM" -eq 1 ]]; then efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "root=/dev/$LVM_VG/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux-fallback.img" efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "root=/dev/$LVM_VG/${LVM_NAMES[0]} rw initrd=\\$IMG initrd=\initramfs-linux.img" else efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus-Fallback" --loader "/vmlinuz-linux" --unicode "root=PARTUUID=$PART_UUID rw initrd=\\$IMG initrd=\initramfs-linux-fallback.img" efibootmgr --disk "$DISK" --part 1 --create --label "ArchTitus" --loader "/vmlinuz-linux" --unicode "root=PARTUUID=$PART_UUID rw initrd=\\$IMG initrd=\initramfs-linux.img" fi else echo "ERROR! efistub is not supported for BIOS systems" exit 0 fi ;; none) echo "Skipping bootloader installation" ;; *) something_failed ;; esac echo "Adding User and hostname" if [ "$(id -u)" -eq "0" ]; then if [[ "$LAYOUT" -eq 1 ]]; then groupadd libvirt useradd -m -G wheel,libvirt -s /bin/bash "$USERNAME" else useradd -m -G wheel -s /bin/bash "$USERNAME" fi echo "$USERNAME:$PASSWORD" | chpasswd cp -R /root/ArchTitus /home/"$USERNAME"/ chown -R "$USERNAME": /home/"$USERNAME"/ArchTitus echo "$HOSTNAME" >>/etc/hostname else echo "You are already a user proceed with aur installs" fi # Making sure to edit mkinitcpio conf if luks is selected # add encrypt in mkinitcpio.conf before filesystems in hooks if [[ "$LVM" -eq 1 ]]; then echo "LVM hooks added" sed -i "/^HOOK/s/filesystems/${HOOKS[*]}/" /etc/mkinitcpio.conf elif [[ "$LUKS" -eq 1 ]]; then echo "LUKS hooks added" sed -i "s/^HOOK.*/HOOKS=(${HOOKS[*]})/" /etc/mkinitcpio.conf elif [[ "$LAYOUT" -eq 1 ]]; then echo "Btrfs module added" sed -i '/^MODULES=/s/(/(btrfs/' /etc/mkinitcpio.conf fi if [[ -f "/etc/mkinitcpio.conf" ]]; then # making mkinitcpio with linux kernel echo "Building initramfs" mkinitcpio -p linux fi title "System ready for 2-user.sh"