diff --git a/src/commands/system-setup/arch/server-setup.sh b/src/commands/system-setup/arch/server-setup.sh new file mode 100644 index 00000000..f0c31a35 --- /dev/null +++ b/src/commands/system-setup/arch/server-setup.sh @@ -0,0 +1,760 @@ +#!/bin/bash + +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer +------------------------------------------------------------------------- + +Verifying Arch Linux ISO is Booted + +" +if [ ! -f /usr/bin/pacstrap ]; then + echo "This script must be run from an Arch Linux ISO environment." + exit 1 +fi + +set_password() { + read -rs -p "Please enter password: " PASSWORD1 + echo -ne "\n" + read -rs -p "Please re-enter password: " PASSWORD2 + echo -ne "\n" + if [[ "$PASSWORD1" == "$PASSWORD2" ]]; then + set_option "$1" "$PASSWORD1" + else + echo -ne "ERROR! Passwords do not match. \n" + set_password + fi +} + +root_check() { + if [[ "$(id -u)" != "0" ]]; then + echo -ne "ERROR! This script must be run under the 'root' user!\n" + exit 0 + fi +} + +docker_check() { + if awk -F/ '$2 == "docker"' /proc/self/cgroup | read -r; then + echo -ne "ERROR! Docker container is not supported (at the moment)\n" + exit 0 + elif [[ -f /.dockerenv ]]; then + echo -ne "ERROR! Docker container is not supported (at the moment)\n" + exit 0 + fi +} + +arch_check() { + if [[ ! -e /etc/arch-release ]]; then + echo -ne "ERROR! This script must be run in Arch Linux!\n" + exit 0 + fi +} + +pacman_check() { + if [[ -f /var/lib/pacman/db.lck ]]; then + echo "ERROR! Pacman is blocked." + echo -ne "If not running remove /var/lib/pacman/db.lck.\n" + exit 0 + fi +} + +background_checks() { + root_check + arch_check + pacman_check + docker_check +} + +# Renders a text based list of options that can be selected by the +# user using up, down and enter keys and returns the chosen option. +# +# Arguments : list of options, maximum of 256 +# "opt1" "opt2" ... +# Return value: selected index (0 for opt1, 1 for opt2 ...) +select_option() { + + # little helpers for terminal print control and key input + ESC=$( printf "\033") + cursor_blink_on() { printf "$ESC[?25h"; } + cursor_blink_off() { printf "$ESC[?25l"; } + cursor_to() { printf "$ESC[$1;${2:-1}H"; } + print_option() { printf "$2 $1 "; } + print_selected() { printf "$2 $ESC[7m $1 $ESC[27m"; } + get_cursor_row() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${ROW#*[}; } + get_cursor_col() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${COL#*[}; } + key_input() { + local key + IFS= read -rsn1 key 2>/dev/null >&2 + if [[ $key = "" ]]; then echo enter; fi; + if [[ $key = $'\x20' ]]; then echo space; fi; + if [[ $key = "k" ]]; then echo up; fi; + if [[ $key = "j" ]]; then echo down; fi; + if [[ $key = "h" ]]; then echo left; fi; + if [[ $key = "l" ]]; then echo right; fi; + if [[ $key = "a" ]]; then echo all; fi; + if [[ $key = "n" ]]; then echo none; fi; + if [[ $key = $'\x1b' ]]; then + read -rsn2 key + if [[ $key = [A || $key = k ]]; then echo up; fi; + if [[ $key = [B || $key = j ]]; then echo down; fi; + if [[ $key = [C || $key = l ]]; then echo right; fi; + if [[ $key = [D || $key = h ]]; then echo left; fi; + fi + } + print_options_multicol() { + # print options by overwriting the last lines + local curr_col=$1 + local curr_row=$2 + local curr_idx=0 + + local idx=0 + local row=0 + local col=0 + + curr_idx=$(( $curr_col + $curr_row * $colmax )) + + for option in "${options[@]}"; do + + row=$(( $idx/$colmax )) + col=$(( $idx - $row * $colmax )) + + cursor_to $(( $startrow + $row + 1)) $(( $offset * $col + 1)) + if [ $idx -eq $curr_idx ]; then + print_selected "$option" + else + print_option "$option" + fi + ((idx++)) + done + } + + # initially print empty new lines (scroll down if at bottom of screen) + for opt; do printf "\n"; done + + # determine current screen position for overwriting the options + local return_value=$1 + local lastrow=`get_cursor_row` + local lastcol=`get_cursor_col` + local startrow=$(($lastrow - $#)) + local startcol=1 + local lines=$( tput lines ) + local cols=$( tput cols ) + local colmax=$2 + local offset=$(( $cols / $colmax )) + + local size=$4 + shift 4 + + # ensure cursor and input echoing back on upon a ctrl+c during read -s + trap "cursor_blink_on; stty echo; printf '\n'; exit" 2 + cursor_blink_off + + local active_row=0 + local active_col=0 + while true; do + print_options_multicol $active_col $active_row + # user key control + case `key_input` in + enter) break;; + up) ((active_row--)); + if [ $active_row -lt 0 ]; then active_row=0; fi;; + down) ((active_row++)); + if [ $active_row -ge $(( ${#options[@]} / $colmax )) ]; then active_row=$(( ${#options[@]} / $colmax )); fi;; + left) ((active_col=$active_col - 1)); + if [ $active_col -lt 0 ]; then active_col=0; fi;; + right) ((active_col=$active_col + 1)); + if [ $active_col -ge $colmax ]; then active_col=$(( $colmax - 1 )) ; fi;; + esac + done + + # cursor position back to normal + cursor_to $lastrow + printf "\n" + cursor_blink_on + + return $(( $active_col + $active_row * $colmax )) +} +# @description Displays ArchTitus logo +# @noargs +logo () { +# This will be shown on every set as user is progressing +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ +██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ +███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ +██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ +██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ +╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------ + Please select presetup settings for your system +------------------------------------------------------------------------ +" +} +# @description This function will handle file systems. At this movement we are handling only +# btrfs and ext4. Others will be added in future. +filesystem () { +echo -ne " +Please Select your file system for both boot and root +" +options=("btrfs" "ext4" "luks" "exit") +select_option $? 1 "${options[@]}" + +case $? in +0) set_option FS btrfs;; +1) set_option FS ext4;; +2) + set_password "LUKS_PASSWORD" + set_option FS luks + ;; +3) exit ;; +*) echo "Wrong option please select again"; filesystem;; +esac +} +# @description Detects and sets timezone. +timezone () { +# Added this from arch wiki https://wiki.archlinux.org/title/System_time +time_zone="$(curl --fail https://ipapi.co/timezone)" +echo -ne " +System detected your timezone to be '$time_zone' \n" +echo -ne "Is this correct? +" +options=("Yes" "No") +select_option $? 1 "${options[@]}" + +case ${options[$?]} in + y|Y|yes|Yes|YES) + echo "${time_zone} set as timezone" + set_option TIMEZONE $time_zone;; + n|N|no|NO|No) + echo "Please enter your desired timezone e.g. Europe/London :" + read new_timezone + echo "${new_timezone} set as timezone" + set_option TIMEZONE $new_timezone;; + *) echo "Wrong option. Try again";timezone;; +esac +} +# @description Set user's keyboard mapping. +keymap () { +echo -ne " +Please select key board layout from this list" +# These are default key maps as presented in official arch repo archinstall +options=(us by ca cf cz de dk es et fa fi fr gr hu il it lt lv mk nl no pl ro ru sg ua uk) + +select_option $? 4 "${options[@]}" +keymap=${options[$?]} + +echo -ne "Your key boards layout: ${keymap} \n" +set_option KEYMAP $keymap +} + +# @description Choose whether drive is SSD or not. +drivessd () { +echo -ne " +Is this an ssd? yes/no: +" + +options=("Yes" "No") +select_option $? 1 "${options[@]}" + +case ${options[$?]} in + y|Y|yes|Yes|YES) + set_option MOUNT_OPTIONS "noatime,compress=zstd,ssd,commit=120";; + n|N|no|NO|No) + set_option MOUNT_OPTIONS "noatime,compress=zstd,commit=120";; + *) echo "Wrong option. Try again";drivessd;; +esac +} + +# @description Disk selection for drive to be used with installation. +diskpart () { +echo -ne " +------------------------------------------------------------------------ + THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK + Please make sure you know what you are doing because + after formating your disk there is no way to get data back + *****BACKUP YOUR DATA BEFORE CONTINUING***** + ***I AM NOT RESPONSIBLE FOR ANY DATA LOSS*** +------------------------------------------------------------------------ + +" + +PS3=' +Select the disk to install on: ' +options=($(lsblk -n --output TYPE,KNAME,SIZE | awk '$1=="disk"{print "/dev/"$2"|"$3}')) + +select_option $? 1 "${options[@]}" +disk=${options[$?]%|*} + +echo -e "\n${disk%|*} selected \n" + set_option DISK ${disk%|*} + +drivessd +} + +# @description Gather username and password to be used for installation. +userinfo () { +read -p "Please enter your username: " username +set_option USERNAME ${username,,} # convert to lower case as in issue #109 +set_password "PASSWORD" +read -rep "Please enter your hostname: " nameofmachine +set_option NAME_OF_MACHINE $nameofmachine +} + +# Starting functions +background_checks +clear +logo +userinfo +clear +logo +diskpart +clear +logo +filesystem +clear +logo +timezone +clear +logo +keymap + +echo "Setting up mirrors for optimal download" +iso=$(curl -4 ifconfig.co/country-iso) +timedatectl set-ntp true +pacman -S --noconfirm archlinux-keyring #update keyrings to latest to prevent packages failing to install +pacman -S --noconfirm --needed pacman-contrib terminus-font +setfont ter-v22b +sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf +pacman -S --noconfirm --needed reflector rsync grub +cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.backup +echo -ne " +------------------------------------------------------------------------- + Setting up $iso mirrors for faster downloads +------------------------------------------------------------------------- +" +reflector -a 48 -c $iso -f 5 -l 20 --sort rate --save /etc/pacman.d/mirrorlist +mkdir /mnt &>/dev/null # Hiding error message if any +echo -ne " +------------------------------------------------------------------------- + Installing Prerequisites +------------------------------------------------------------------------- +" +pacman -S --noconfirm --needed gptfdisk btrfs-progs glibc +echo -ne " +------------------------------------------------------------------------- + Formating Disk +------------------------------------------------------------------------- +" +umount -A --recursive /mnt # make sure everything is unmounted before we start +# disk prep +sgdisk -Z ${DISK} # zap all on disk +sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment + +# create partitions +sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition) +sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition) +sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining +if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system + sgdisk -A 1:set:2 ${DISK} +fi +partprobe ${DISK} # reread partition table to ensure it is correct + +# make filesystems +echo -ne " +------------------------------------------------------------------------- + Creating Filesystems +------------------------------------------------------------------------- +" +# @description Creates the btrfs subvolumes. +createsubvolumes () { + btrfs subvolume create /mnt/@ + btrfs subvolume create /mnt/@home + btrfs subvolume create /mnt/@var + btrfs subvolume create /mnt/@tmp + btrfs subvolume create /mnt/@.snapshots +} + +# @description Mount all btrfs subvolumes after root has been mounted. +mountallsubvol () { + mount -o ${MOUNT_OPTIONS},subvol=@home ${partition3} /mnt/home + mount -o ${MOUNT_OPTIONS},subvol=@tmp ${partition3} /mnt/tmp + mount -o ${MOUNT_OPTIONS},subvol=@var ${partition3} /mnt/var + mount -o ${MOUNT_OPTIONS},subvol=@.snapshots ${partition3} /mnt/.snapshots +} + +# @description BTRFS subvolulme creation and mounting. +subvolumesetup () { +# create nonroot subvolumes + createsubvolumes +# unmount root to remount with subvolume + umount /mnt +# mount @ subvolume + mount -o ${MOUNT_OPTIONS},subvol=@ ${partition3} /mnt +# make directories home, .snapshots, var, tmp + mkdir -p /mnt/{home,var,tmp,.snapshots} +# mount subvolumes + mountallsubvol +} + +if [[ "${DISK}" =~ "nvme" ]]; then + partition2=${DISK}p2 + partition3=${DISK}p3 +else + partition2=${DISK}2 + partition3=${DISK}3 +fi + +if [[ "${FS}" == "btrfs" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${partition2} + mkfs.btrfs -L ROOT ${partition3} -f + mount -t btrfs ${partition3} /mnt + subvolumesetup +elif [[ "${FS}" == "ext4" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${partition2} + mkfs.ext4 -L ROOT ${partition3} + mount -t ext4 ${partition3} /mnt +elif [[ "${FS}" == "luks" ]]; then + mkfs.vfat -F32 -n "EFIBOOT" ${partition2} +# enter luks password to cryptsetup and format root partition + echo -n "${LUKS_PASSWORD}" | cryptsetup -y -v luksFormat ${partition3} - +# open luks container and ROOT will be place holder + echo -n "${LUKS_PASSWORD}" | cryptsetup open ${partition3} ROOT - +# now format that container + mkfs.btrfs -L ROOT ${partition3} +# create subvolumes for btrfs + mount -t btrfs ${partition3} /mnt + subvolumesetup +fi + +# mount target +mkdir -p /mnt/boot/efi +mount -t vfat -L EFIBOOT /mnt/boot/ + +if ! grep -qs '/mnt' /proc/mounts; then + echo "Drive is not mounted can not continue" + echo "Rebooting in 3 Seconds ..." && sleep 1 + echo "Rebooting in 2 Seconds ..." && sleep 1 + echo "Rebooting in 1 Second ..." && sleep 1 + reboot now +fi +echo -ne " +------------------------------------------------------------------------- + Arch Install on Main Drive +------------------------------------------------------------------------- +" +pacstrap /mnt base base-devel linux-lts linux-lts-firmware vim nano sudo archlinux-keyring wget libnewt --noconfirm --needed +echo "keyserver hkp://keyserver.ubuntu.com" >> /mnt/etc/pacman.d/gnupg/gpg.conf +cp -R ${SCRIPT_DIR} /mnt/root/ArchTitus +cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist + +genfstab -L /mnt >> /mnt/etc/fstab +echo " + Generated /etc/fstab: +" +cat /mnt/etc/fstab +echo -ne " +------------------------------------------------------------------------- + GRUB BIOS Bootloader Install & Check +------------------------------------------------------------------------- +" +if [[ ! -d "/sys/firmware/efi" ]]; then + grub-install --boot-directory=/mnt/boot ${DISK} +else + pacstrap /mnt efibootmgr --noconfirm --needed +fi +echo -ne " +------------------------------------------------------------------------- + Checking for low memory systems <8G +------------------------------------------------------------------------- +" +TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') +if [[ $TOTAL_MEM -lt 8000000 ]]; then + # Put swap into the actual system, not into RAM disk, otherwise there is no point in it, it'll cache RAM into RAM. So, /mnt/ everything. + mkdir -p /mnt/opt/swap # make a dir that we can apply NOCOW to to make it btrfs-friendly. + if findmnt -n -o FSTYPE /mnt | grep -q btrfs; then + chattr +C /mnt/opt/swap # apply NOCOW, btrfs needs that. + fi + dd if=/dev/zero of=/mnt/opt/swap/swapfile bs=1M count=2048 status=progress + chmod 600 /mnt/opt/swap/swapfile # set permissions. + chown root /mnt/opt/swap/swapfile + mkswap /mnt/opt/swap/swapfile + swapon /mnt/opt/swap/swapfile + # The line below is written to /mnt/ but doesn't contain /mnt/, since it's just / for the system itself. + echo "/opt/swap/swapfile none swap sw 0 0" >> /mnt/etc/fstab # Add swap to fstab, so it KEEPS working after installation. +fi + +echo -ne " +------------------------------------------------------------------------- + Network Setup +------------------------------------------------------------------------- +" +pacman -S --noconfirm --needed networkmanager dhclient +systemctl enable --now NetworkManager +echo -ne " +------------------------------------------------------------------------- + Setting up mirrors for optimal download +------------------------------------------------------------------------- +" +pacman -S --noconfirm --needed pacman-contrib curl +pacman -S --noconfirm --needed reflector rsync grub arch-install-scripts git +cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + +nc=$(grep -c ^processor /proc/cpuinfo) +echo -ne " +------------------------------------------------------------------------- + You have " $nc" cores. And + changing the makeflags for "$nc" cores. Aswell as + changing the compression settings. +------------------------------------------------------------------------- +" +TOTAL_MEM=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*') +if [[ $TOTAL_MEM -gt 8000000 ]]; then +sed -i "s/#MAKEFLAGS=\"-j2\"/MAKEFLAGS=\"-j$nc\"/g" /etc/makepkg.conf +sed -i "s/COMPRESSXZ=(xz -c -z -)/COMPRESSXZ=(xz -c -T $nc -z -)/g" /etc/makepkg.conf +fi +echo -ne " +------------------------------------------------------------------------- + Setup Language to US and set locale +------------------------------------------------------------------------- +" +sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /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="en_US.UTF-8" LC_TIME="en_US.UTF-8" +ln -s /usr/share/zoneinfo/${TIMEZONE} /etc/localtime +# Set keymaps +localectl --no-ask-password set-keymap ${KEYMAP} + +# Add sudo no password rights +sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers +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 --needed + +echo -ne " +------------------------------------------------------------------------- + Installing Microcode +------------------------------------------------------------------------- +" +# determine processor type and install microcode +proc_type=$(lscpu) +if grep -E "GenuineIntel" <<< ${proc_type}; then + echo "Installing Intel microcode" + pacman -S --noconfirm --needed intel-ucode + proc_ucode=intel-ucode.img +elif grep -E "AuthenticAMD" <<< ${proc_type}; then + echo "Installing AMD microcode" + pacman -S --noconfirm --needed amd-ucode + proc_ucode=amd-ucode.img +fi + +echo -ne " +------------------------------------------------------------------------- + Installing Graphics Drivers +------------------------------------------------------------------------- +" +# Graphics Drivers find and install +gpu_type=$(lspci) +if grep -E "NVIDIA|GeForce" <<< ${gpu_type}; then + pacman -S --noconfirm --needed nvidia-lts + nvidia-xconfig +elif lspci | grep 'VGA' | grep -E "Radeon|AMD"; then + pacman -S --noconfirm --needed xf86-video-amdgpu +elif grep -E "Integrated Graphics Controller" <<< ${gpu_type}; then + pacman -S --noconfirm --needed libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa +elif grep -E "Intel Corporation UHD" <<< ${gpu_type}; then + pacman -S --needed --noconfirm libva-intel-driver libvdpau-va-gl lib32-vulkan-intel vulkan-intel libva-intel-driver libva-utils lib32-mesa +fi + # Loop through user input until the user gives a valid username + while true + do + read -p "Please enter username:" username + # username regex per response here https://unix.stackexchange.com/questions/157426/what-is-the-regex-to-validate-linux-users + # lowercase the username to test regex + if [[ "${username,,}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]] + then + break + fi + echo "Incorrect username." + done + #Set Password + read -p "Please enter password:" password + + # Loop through user input until the user gives a valid hostname, but allow the user to force save + while true + do + read -p "Please name your machine:" name_of_machine + # hostname regex (!!couldn't find spec for computer name!!) + if [[ "${name_of_machine,,}" =~ ^[a-z][a-z0-9_.-]{0,62}[a-z0-9]$ ]] + then + break + fi + # if validation fails allow the user to force saving of the hostname + read -p "Hostname doesn't seem correct. Do you still want to save it? (y/n)" force + if [[ "${force,,}" = "y" ]] + then + break + fi + done + +echo -ne " +------------------------------------------------------------------------- + Adding User +------------------------------------------------------------------------- +" +if [ $(whoami) = "root" ]; then + groupadd libvirt + useradd -m -G wheel,libvirt -s /bin/bash $USERNAME + echo "$USERNAME created, home directory created, added to wheel and libvirt group, default shell set to /bin/bash" + +# use chpasswd to enter $USERNAME:$password + echo "$USERNAME:$PASSWORD" | chpasswd + echo "$USERNAME password set" + + cp -R $HOME/ArchTitus /home/$USERNAME/ + chown -R $USERNAME: /home/$USERNAME/ArchTitus + echo "ArchTitus copied to home directory" + +# enter $NAME_OF_MACHINE to /etc/hostname + echo $NAME_OF_MACHINE > /etc/hostname +else + echo "You are already a user proceed with aur installs" +fi +if [[ ${FS} == "luks" ]]; then +# Making sure to edit mkinitcpio conf if luks is selected +# add encrypt in mkinitcpio.conf before filesystems in hooks + sed -i 's/filesystems/encrypt filesystems/g' /etc/mkinitcpio.conf +# making mkinitcpio with linux kernel + mkinitcpio -p linux-lts +fi + +export PATH=$PATH:~/.local/bin + +echo -ne " +------------------------------------------------------------------------- + █████╗ ██████╗ ██████╗██╗ ██╗████████╗██╗████████╗██╗ ██╗███████╗ + ██╔══██╗██╔══██╗██╔════╝██║ ██║╚══██╔══╝██║╚══██╔══╝██║ ██║██╔════╝ + ███████║██████╔╝██║ ███████║ ██║ ██║ ██║ ██║ ██║███████╗ + ██╔══██║██╔══██╗██║ ██╔══██║ ██║ ██║ ██║ ██║ ██║╚════██║ + ██║ ██║██║ ██║╚██████╗██║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║ + ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ +------------------------------------------------------------------------- + Automated Arch Linux Installer + SCRIPTHOME: ArchTitus +------------------------------------------------------------------------- + +Final Setup and Configurations +GRUB EFI Bootloader Install & Check +" + +if [[ -d "/sys/firmware/efi" ]]; then + grub-install --efi-directory=/boot ${DISK} +fi + +echo -ne " +------------------------------------------------------------------------- + Creating (and Theming) Grub Boot Menu +------------------------------------------------------------------------- +" +# set kernel parameter for decrypting the drive +if [[ "${FS}" == "luks" ]]; then +sed -i "s%GRUB_CMDLINE_LINUX_DEFAULT=\"%GRUB_CMDLINE_LINUX_DEFAULT=\"cryptdevice=UUID=${ENCRYPTED_PARTITION_UUID}:ROOT root=/dev/mapper/ROOT %g" /etc/default/grub +fi +# set kernel parameter for adding splash screen +sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT="[^"]*/& splash /' /etc/default/grub + +echo -e "Installing CyberRe Grub theme..." +THEME_DIR="/boot/grub/themes" +THEME_NAME=CyberRe +echo -e "Creating the theme directory..." +mkdir -p "${THEME_DIR}/${THEME_NAME}" +echo -e "Copying the theme..." +cd "${HOME}/ArchTitus" || exit +cp -a configs${THEME_DIR}/${THEME_NAME}/* ${THEME_DIR}/${THEME_NAME} +echo -e "Backing up Grub config..." +cp -an /etc/default/grub /etc/default/grub.bak +echo -e "Setting the theme as the default..." +# shellcheck disable=SC2069 +grep "GRUB_THEME=" /etc/default/grub 2>&1 >/dev/null && sed -i '/GRUB_THEME=/d' /etc/default/grub +echo "GRUB_THEME=\"${THEME_DIR}/${THEME_NAME}/theme.txt\"" >> /etc/default/grub +echo -e "Updating grub..." +grub-mkconfig -o /boot/grub/grub.cfg +echo -e "All set!" + +echo -ne " +------------------------------------------------------------------------- + Enabling (and Theming) Login Display Manager +------------------------------------------------------------------------- +" + +systemctl enable sddm.service +echo "[Theme]" >> /etc/sddm.conf +echo "Current=Nordic" >> /etc/sddm.conf + +echo -ne " +------------------------------------------------------------------------- + Enabling Essential Services +------------------------------------------------------------------------- +" +ntpd -qg +systemctl enable ntpd.service +echo " NTP enabled" +systemctl disable dhcpcd.service +echo " DHCP disabled" +systemctl stop dhcpcd.service +echo " DHCP stopped" +systemctl enable NetworkManager.service +echo " NetworkManager enabled" + +echo -ne " +------------------------------------------------------------------------- + Enabling (and Theming) Plymouth Boot Splash +------------------------------------------------------------------------- +" +PLYMOUTH_THEMES_DIR="$HOME/ArchTitus/configs/usr/share/plymouth/themes" +PLYMOUTH_THEME="arch-glow" # can grab from config later if we allow selection +mkdir -p /usr/share/plymouth/themes +echo 'Installing Plymouth theme...' +cp -rf "${PLYMOUTH_THEMES_DIR}"/${PLYMOUTH_THEME} /usr/share/plymouth/themes +if [[ $FS == "luks" ]]; then + sed -i 's/HOOKS=(base udev*/& plymouth/' /etc/mkinitcpio.conf # add plymouth after base udev + sed -i 's/HOOKS=(base udev \(.*block\) /&plymouth-/' /etc/mkinitcpio.conf # create plymouth-encrypt after block hook +else + sed -i 's/HOOKS=(base udev*/& plymouth/' /etc/mkinitcpio.conf # add plymouth after base udev +fi +plymouth-set-default-theme -R arch-glow # sets the theme and runs mkinitcpio +echo 'Plymouth theme installed' + +echo -ne " +------------------------------------------------------------------------- + Cleaning +------------------------------------------------------------------------- +" +# Remove no password sudo rights +sed -i 's/^%wheel ALL=(ALL) NOPASSWD: ALL/# %wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers +sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL/# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers +# Add sudo rights +sed -i 's/^# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers +sed -i 's/^# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers + +rm -r $HOME/ArchTitus +rm -r /home/$USERNAME/ArchTitus + +# Replace in the same state +cd "$(pwd)" || exit + + diff --git a/src/commands/system-setup/tab_data.toml b/src/commands/system-setup/tab_data.toml index 53ec55cd..7551e884 100644 --- a/src/commands/system-setup/tab_data.toml +++ b/src/commands/system-setup/tab_data.toml @@ -9,13 +9,17 @@ data = "command_exists" values = ["pacman"] [[data.entries]] -name = "Yay AUR Helper" -script = "arch/yay-setup.sh" +name = "Arch Server Setup" +script = "arch/server-setup.sh" [[data.entries]] name = "Paru AUR Helper" script = "arch/paru-setup.sh" +[[data.entries]] +name = "Yay AUR Helper" +script = "arch/yay-setup.sh" + [[data]] name = "Full System Update" script = "system-update.sh"