Files
starburst/v2/arch.sh
2025-11-10 09:37:46 +01:00

256 lines
6.9 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
##########################
# Color helpers
##########################
tput_reset() { tput sgr0; }
tput_black() { tput setaf 0; }
tput_red() { tput setaf 1; }
tput_green() { tput setaf 2; }
tput_yellow() { tput setaf 3; }
tput_blue() { tput setaf 4; }
tput_purple() { tput setaf 5; }
tput_cyan() { tput setaf 6; }
tput_gray() { tput setaf 7; }
##########################
# Use exported variables from main detection script
##########################
OS="${DETECTED_OS}"
DDE="${DETECTED_DE}"
DE="${SELECTED_DE:-none}"
TWM="${SELECTED_TWM:-none}"
INSTALL_LEVEL="${INSTALL_LEVEL:-minimal}"
tput_cyan
echo
echo "Starting Arch Linux setup..."
tput_reset
echo
echo "DE: $DE, TWM: $TWM, Install Level: $INSTALL_LEVEL"
##########################
# 0. Ensure base is ready for installation
##########################
# Setting installed_dir to base folder of the git-repository
installed_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Installing chaotic-aur keys and mirrors
pkg_dir="packages"
# Ensure directory exists
if [[ ! -d "$pkg_dir" ]]; then
echo "Directory not found: $pkg_dir"
exit 1
fi
if ! command -v curl >/dev/null 2>&1; then
tput_yellow
echo
echo "curl is not installed. Installing..."
tput_reset
sudo pacman -Sy
sudo sudo pacman -S --noconfirm --needed curl
fi
# Install all local packages using pacman
find "$pkg_dir" -maxdepth 1 -name '*.pkg.tar.zst' -print0 | sudo xargs -0 pacman -U --noconfirm
##########################
# 1. Add repsotirories if missing
##########################
tput_yellow
echo
echo "Checking /etc/apt/sources.list for contrib/non-free..."
tput_reset
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%s)
sudo sed -i -r 's/^(deb\s+\S+\s+\S+)\s+(main)$/\1 main contrib non-free/' /etc/apt/sources.list
tput_green
echo
echo "Updated sources.list to include contrib/non-free where needed."
tput_reset
# personal pacman.conf
if [[ ! -f /etc/pacman.conf.starburst ]]; then
echo
tput setaf 2
echo "################################################################################"
echo "Copying /etc/pacman.conf to /etc/pacman.conf.starburst"
echo "################################################################################"
tput sgr0
echo
sudo cp -v /etc/pacman.conf /etc/pacman.conf.starburst
echo
else
echo
tput setaf 2
echo "################################################################################"
echo "Backup already exists: /etc/pacman.conf.starburst"
echo "################################################################################"
tput sgr0
echo
fi
sudo cp -v $installed_dir/config-files/pacman.conf /etc/pacman.conf
# update the system
echo
tput setaf 2
echo "################################################################################"
echo "Updating the system - sudo pacman -Syyu"
echo "################################################################################"
tput sgr0
echo
sudo pacman -Syyu --noconfirm
# fix missing console font
echo
tput setaf 3
echo "################################################################"
echo "################### fix missing console font"
echo "################################################################"
tput sgr0
echo
if grep -q FONT= /etc/vconsole.conf; then
echo
tput setaf 2
echo "################################################################"
echo "################### FONT is already set in /etc/vconsole.conf"
echo "################################################################"
tput sgr0
echo
else
tput setaf 2
echo "################################################################"
echo "################### FONT added to /etc/vconsole.conf"
echo "################################################################"
tput sgr0
echo 'FONT=gr737c-8x14' | sudo tee -a /etc/vconsole.conf
fi
echo
tput_yellow
echo "################################################################################"
echo "################### Detected OS / Desktop Environmet / Tiling Window Manager"
echo "################################################################################"
tput_reset
echo
echo "Installing OS-specific packages..."
echo "Selected DE: $SELECTED_DE"
echo "Selected TWM: $SELECTED_TWM"
echo "Installation Level: $INSTALL_LEVEL"
if [[ "$SELECTED_DE" == "xfce" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing XFCE4"
echo "################################################################################"
tput_reset
echo
echo "Installing XFCE packages..."
fi
if [[ "$SELECTED_DE" == "plasma" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing KDE Plasma 6"
echo "################################################################################"
tput_reset
echo
echo "Installing Plasma packages..."
fi
if [[ "$SELECTED_DE" == "gnome" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing Gnome 48"
echo "################################################################################"
tput_reset
echo
echo "Installing Gnome packages..."
fi
if [[ "$SELECTED_DE" == "none" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing no Desktop Environment"
echo "################################################################################"
tput_reset
echo
echo "Installing no Desktop Environment packages..."
fi
if [[ "$SELECTED_TWM" == "chadwm" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing Chadwm"
echo "################################################################################"
tput_reset
echo
echo "Installing CHADWM..."
fi
if [[ "$SELECTED_TWM" == "hyprland" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing Hyprland"
echo "################################################################################"
tput_reset
echo
echo "Installing Hyperland..."
fi
if [[ "$SELECTED_TWM" == "none" ]]; then
echo
tput_green
echo "################################################################################"
echo "################### Installing no Tiling Window Manager"
echo "################################################################################"
tput_reset
echo
echo "Installing no Tiling Window Manager packages..."
fi