First step in cleaning the script

This commit is contained in:
2025-09-17 22:38:28 +02:00
parent a2cef0fed9
commit 39f6c06f69

View File

@@ -62,16 +62,19 @@ setup_repositories() {
case $repo in
"\"CachyOS\"")
if ! grep -q "\[cachyos\]" /etc/pacman.conf; then
echo "== Adding CachyOS repository =="
curl https://mirror.cachyos.org/cachyos-repo.tar.xz -o /tmp/cachyos-repo.tar.xz
tar xvf /tmp/cachyos-repo.tar.xz -C /tmp
cd /tmp/cachyos-repo || exit
sudo ./cachyos-repo.sh
echo "CachyOS repository added successfully."
else
echo "CachyOS repository is already installed."
fi
;;
"\"Chromatic\"")
if ! grep -q "\[chromatic\]" /etc/pacman.conf; then
echo "== Adding Chromatic repository =="
sudo pacman-key --recv-key 6EFB412EBDDD1853DF71F4B625AE803AA8C39062
sudo pacman-key --lsign-key 6EFB412EBDDD1853DF71F4B625AE803AA8C39062
sudo pacman -U --noconfirm 'https://mirror.trap.moe/chromatic/x86_64/chromatic-keyring-1.0-1-any.pkg.tar.zst'
@@ -79,29 +82,35 @@ setup_repositories() {
echo '[chromatic]' | sudo tee -a /etc/pacman.conf
echo 'Include = /etc/pacman.d/chromatic-mirrorlist' | sudo tee -a /etc/pacman.conf
sudo pacman -Sy --noconfirm chromatic-keyring chromatic-mirrorlist
echo "Chromatic repository added successfully."
else
echo "Chromatic repository is already installed."
fi
;;
"\"BlackArch\"")
if ! grep -q "\[blackarch\]" /etc/pacman.conf; then
echo "== Adding BlackArch repository =="
curl -O https://blackarch.org/strap.sh
chmod +x strap.sh
sudo sed -i 's/msg '\''installing blackarch-officials meta-package...'\''/#msg '\''installing blackarch-officials meta-package...'\''/' strap.sh
sudo sed -i 's/pacman -S --noconfirm --needed blackarch-officials/#pacman -S --noconfirm --needed blackarch-officials/' strap.sh
sudo ./strap.sh
echo "BlackArch repository added successfully."
else
echo "BlackArch repository is already installed."
fi
;;
"\"Chaotic.cx\"")
if ! grep -q "\[chaotic-aur\]" /etc/pacman.conf; then
echo "== Adding Chaotic.cx repository =="
sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
sudo pacman-key --lsign-key 3056513887B78AEB
sudo pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst'
sudo pacman -U --noconfirm 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
echo '[chaotic-aur]' | sudo tee -a /etc/pacman.conf
echo 'Include = /etc/pacman.d/chaotic-mirrorlist' | sudo tee -a /etc/pacman.conf
sudo pacman -Sy --noconfirm chaotic-keyring chaotic-mirrorlist
echo "Chaotic.cx repository added successfully."
else
echo "Chaotic.cx repository is already installed."
fi
@@ -114,6 +123,7 @@ setup_repositories() {
# Function name: Setup Pacman configuration
# Description: Setup Pacman configuration
setup_pacman() {
echo "== Setting up Pacman configuration =="
sudo sed -i 's/#Color/Color/' /etc/pacman.conf
sudo sed -i 's/#ILoveCandy/ILoveCandy/' /etc/pacman.conf
sudo sed -i 's/#VerbosePkgLists/VerbosePkgLists/' /etc/pacman.conf
@@ -121,10 +131,11 @@ setup_pacman() {
sudo sed -i 's/#PrettyProgressBar/PrettyProgressBar/' /etc/pacman.conf
sudo sed -i 's/#ParallelDownloads = 5/ParallelDownloads = 10/' /etc/pacman.conf
sudo sed -i 's/#DisableDownloadTimeout/DisableDownloadTimeout/' /etc/pacman.conf
echo "Pacman configuration set up successfully."
}
# Function name: Setup shell
# Description: Install selected shell and recommendations
# Description: Install selected shell and recommended packages
setup_shell() {
options=(
"Zsh" "Install Zsh and recommended packages" ON
@@ -138,18 +149,23 @@ setup_shell() {
case $selected_shell in
"\"Zsh\"")
echo "== Installing Zsh and recommended packages =="
install_package zsh zsh-autosuggestions zsh-completions zsh-history-substring-search zsh-syntax-highlighting grml-zsh-config oh-my-zsh-git
if (whiptail --title "Change default shell to Zsh" --yesno "Would you like to change the default shell to Zsh?" 10 60); then
chsh -s /bin/zsh
fi
echo "Zsh and recommended packages installed successfully."
;;
"\"Fish\"")
echo "== Installing Fish shell and recommended packages =="
install_package fish
if (whiptail --title "Change default shell to Fish" --yesno "Would you like to change the default shell to Fish?" 10 60); then
chsh -s /usr/bin/fish
fi
echo "Fish shell and recommended packages installed successfully."
;;
"\"Bash\"")
echo "== Installing Bash and recommended packages =="
install_package bash
install_dependencies bash-completion
if pacman -Qs bash-completion > /dev/null; then
@@ -158,6 +174,7 @@ setup_shell() {
if (whiptail --title "Change default shell to Bash" --yesno "Would you like to change the default shell to Bash?" 10 60); then
chsh -s /bin/bash
fi
echo "Bash and recommended packages installed successfully."
;;
esac
}
@@ -166,7 +183,9 @@ setup_shell() {
# Description: Install pipewire and its dependencies
setup_audio_server() {
if whiptail --title "Setup Audio Server" --yesno "Would you like to setup Pipewire?" 10 60; then
echo "== Installing Pipewire and its dependencies =="
install_dependencies pipewire pipewire-pulse pipewire-alsa pipewire-jack wireplumber
echo "Pipewire and its dependencies installed successfully."
fi
}
@@ -177,6 +196,7 @@ setup_gpu() {
detected_gpu=$(lspci | grep -Ei "vga|3d|display")
case "$detected_gpu" in
*NVIDIA*)
echo "== Detected NVIDIA GPU =="
options=(
"nvidia" "Official NVIDIA Drivers" ON
"nouveau" "Open Source nouveau drivers" OFF
@@ -185,6 +205,7 @@ setup_gpu() {
"Choose the NVIDIA driver you want to install:" 15 60 2 \
"${options[@]}" 3>&1 1>&2 2>&3)
echo "== Removing existing incorrect NVIDIA drivers if any =="
if pacman -Qs nvidia > /dev/null; then
sudo pacman -R --noconfirm nvidia
elif pacman -Qs nvidia-dkms > /dev/null; then
@@ -196,39 +217,50 @@ setup_gpu() {
case $selected_driver in
"\"nvidia\"")
if pacman -Qs linux > /dev/null; then
echo "=== Installing nvidia open for linux ==="
install_package nvidia-open
install_dependencies libvdpau
fi
if pacman -Qs linux-lts > /dev/null; then
echo "=== Installing nvidia open for linux-lts ==="
install_package nvidia-open-lts
install_dependencies libvdpau
fi
if pacman -Qs linux-cachyos > /dev/null; then
echo "=== Installing nvidia open for linux-cachyos ==="
install_package linux-cachyos-nvidia-open
install_dependencies libvdpau
fi
if pacman -Qs linux-zen > /dev/null || pacman -Qs linux-hardened > /dev/null; then
echo "=== Installing nvidia open dkms for other kernels ==="
install_package nvidia-open-dkms
install_dependencies libvdpau
fi
if ! lspci | grep -Ei "amd|intel" > /dev/null; then
echo "=== Installing libva-nvidia-driver for NVIDIA only systems ==="
install_dependencies libva-nvidia-driver
fi
if (whiptail --title "Install Cuda" --yesno "Would you like to install Cuda?" 10 60); then
echo "=== Installing Cuda ==="
install_dependencies cuda
fi
;;
"\"nouveau\"")
echo "=== Installing nouveau drivers ==="
install_dependencies mesa vulkan-nouveau
;;
esac
;;
*AMD*)
echo "== Detected AMD GPU =="
echo "=== Installing AMD drivers ==="
install_dependencies mesa vulkan-radeon
;;
*Intel*)
echo "== Detected Intel GPU =="
echo "=== Installing Intel drivers ==="
install_dependencies intel-media-driver vulkan-intel
;;
esac
@@ -239,14 +271,20 @@ setup_gpu() {
# Description: Install and setup Plymouth for boot splash
setup_plymouth() {
if whiptail --title "Setup Plymouth" --yesno "Would you like to setup Plymouth?" 10 60; then
echo "quiet splash" | sudo tee -a /etc/kernel/cmdline
sudo sed -i 's/^HOOKS=(base udev autodetect microcode/HOOKS=(base udev autodetect microcode plymouth /' /etc/mkinitcpio.conf
echo "== Setting up Plymouth =="
if ! grep -q "splash" /etc/kernel/cmdline; then
echo "quiet splash" | sudo tee -a /etc/kernel/cmdline
fi
if ! grep -q "plymouth" /etc/mkinitcpio.conf; then
sudo sed -i 's/^HOOKS=(base udev autodetect microcode/HOOKS=(base udev autodetect microcode plymouth /' /etc/mkinitcpio.conf
fi
install_package plymouth
if pacman -Qs plymouth-theme-catppuccin-mocha-git > /dev/null; then
sudo plymouth-set-default-theme -R catppuccin-mocha
else
sudo plymouth-set-default-theme -R spinner
fi
echo "Plymouth setup completed."
fi
}
@@ -264,7 +302,8 @@ setup_network() {
# Description: Install and setup Bluetooth and its dependencies
setup_bluetooth() {
if whiptail --title "Setup Bluetooth" --yesno "Would you like to setup Bluetooth?" 10 60; then
install_dependencies bluedevil bluez bluez-utils
echo "== Installing Bluetooth and its dependencies =="
install_dependencies bluedevil bluez
sudo systemctl enable --now bluetooth
fi
}
@@ -275,8 +314,6 @@ setup_u2f() {
if whiptail --title "Setup U2F" --yesno "Would you like to setup U2F (Yubikey) authentication?" 10 60; then
install_package pam-u2f
mkdir -p ~/.config/Yubico
echo "Registering U2F device..."
pamu2fcfg -o "pam://$HOST" -i "pam://$HOST" > ~/.config/Yubico/u2f_keys
sudo touch /etc/pam.d/u2f-required
sudo touch /etc/pam.d/u2f-sufficient
echo "auth required pam_u2f.so cue origin=pam://$HOST appid=pam://$HOST" | sudo tee -a /etc/pam.d/u2f-required
@@ -290,6 +327,11 @@ setup_u2f() {
sudo cp /usr/lib/pam.d/polkit-1 /etc/pam.d/polkit-1
fi
sudo sed -i '/^auth\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/polkit-1
if whiptail --title "Enroll U2F Device" --yesno "Would you like to enroll your U2F device now?" 10 60; then
echo "Enrolling U2F device..."
pamu2fcfg -o "pam://$HOST" -i "pam://$HOST" > ~/.config/Yubico/u2f_keys
whiptail --title "U2F Enrollment" --msgbox "U2F device enrolled successfully. You can add more devices by running 'pamu2fcfg -o \"pam://$HOST\" -i \"pam://$HOST\" >> ~/.config/Yubico/u2f_keys'." 10 60
fi
fi
}
@@ -297,6 +339,7 @@ setup_u2f() {
# Description: setup fprint for login using fingerprint reader
setup_fprint() {
if whiptail --title "Setup Fprint" --yesno "Would you like to setup fingerprint authentication (fprintd)?" 10 60; then
echo "== Installing fprintd and its dependencies =="
install_package fprintd
install_dependencies imagemagick
sudo systemctl enable --now fprintd
@@ -306,17 +349,23 @@ setup_fprint() {
sudo cp /usr/lib/pam.d/polkit-1 /etc/pam.d/polkit-1
fi
sudo sed -i '/^auth\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/polkit-1
fprintd-enroll
if whiptail --title "Enroll Fingerprint" --yesno "Would you like to enroll your fingerprint now?" 10 60; then
echo "Enrolling fingerprint..."
fprintd-enroll
fi
echo "Fprintd setup completed."
fi
}
# function name : setup SmartCard [WIP]
# Description: setup pcscd for login using smartcard reader
# Description: setup opensc for login using smartcard reader
setup_smartcard() {
if whiptail --title "Setup SmartCard" --yesno "Would you like to setup SmartCard (pcscd) authentication?" 10 60; then
if whiptail --title "Setup SmartCard" --yesno "Would you like to setup SmartCard (opensc) authentication?" 10 60; then
echo "== Installing opensc =="
install_package opensc
sudo systemctl enable --now pcscd
sudo systemctl enable --now pcscd.socket
echo "SmartCard (opensc) setup completed."
fi
}
@@ -326,30 +375,26 @@ setup_firewall() {
options=(
"ufw" "Install UFW" ON
"firewalld" "Install Firewalld" OFF
"iptables" "Install Iptables" ON
"nftables" "Install Nftables" OFF
)
selected_groups=$(whiptail --title "Setup Firewall" --checklist "Choose the firewall you want to install:" 20 78 4 "${options[@]}")
selected_groups=$(whiptail --title "Setup Firewall" --checklist "Choose the firewall you want to install:" 20 78 2 "${options[@]}" 3>&1 1>&2 2>&3)
case $selected_groups in
"ufw")
install_package ufw
install_dependencies ufw-extras
sudo systemctl enable --now ufw
sudo ufw enable
;;
"firewalld")
install_package firewalld
sudo systemctl enable --now firewalld
;;
"iptables")
install_package iptables
;;
"nftables")
install_package nftables
install_package iptables-nft
;;
esac
for group in $selected_groups; do
case $group in
"\"ufw\"")
echo "== Installing UFW =="
install_package ufw
sudo systemctl enable --now ufw
sudo ufw enable
echo "UFW installed and started."
;;
"\"firewalld\"")
echo "== Installing Firewalld =="
install_package firewalld
sudo systemctl enable --now firewalld
echo "Firewalld installed and started."
;;
esac
done
}
# function name : Setup NTP
@@ -364,18 +409,22 @@ setup_ntp() {
selected_ntp=$(whiptail --title "Setup NTP" --radiolist "Choose the NTP client you want to install:" 20 78 4 "${options[@]}" 3>&1 1>&2 2>&3)
case $selected_ntp in
"\"ntpd-rs\"")
echo "== Installing ntpd-rs =="
install_package ntpd-rs
sudo systemctl enable --now ntpd-rs
;;
"\"chrony\"")
echo "== Installing chrony =="
install_package chrony
sudo systemctl enable --now chronyd
;;
"\"openntpd\"")
echo "== Installing openntpd =="
install_package openntpd
sudo systemctl enable --now openntpd
;;
"\"ntp\"")
echo "== Installing ntp =="
install_package ntp
sudo systemctl enable --now ntpd
;;
@@ -395,17 +444,16 @@ setup_flatpak() {
# Description: setup fwupd
setup_fwupd() {
if whiptail --title "Setup fwupd" --yesno "Would you like to setup fwupd?" 10 60; then
install_package fwupd
install_dependencies fwupd-efi
sudo systemctl enable --now fwupd
sudo systemctl enable --now fwupd-refresh
echo "== Installing fwupd =="
install_package fwupd
fi
}
# function name : setup OpenRGB
# Description: Install OpenRGB for RGB devices control
setup_openrgb() {
if whiptail --title "Setup fwupd" --yesno "Would you like to setup OpenRGB?" 10 60; then
if whiptail --title "Setup OpenRGB" --yesno "Would you like to setup OpenRGB?" 10 60; then
echo "== Installing OpenRGB =="
install_package openrgb
sudo gpasswd -a "$USER" plugdev
sudo systemctl enable --now openrgb
@@ -541,12 +589,14 @@ setup_mail_client() {
# Description: Install virtualization packages and enable libvirtd service
setup_virtualization() {
if whiptail --title "Setup Virtualization" --yesno "Would you like to setup virtualization?" 10 60; then
echo "=== Installing virtualization packages ==="
install_package virt-manager qemu-full virt-viewer
install_dependencies swtpm dnsmasq openbsd-netcat
if pacman -Qs libvirt > /dev/null; then
sudo systemctl enable --now libvirtd
sudo usermod -aG libvirt "$USER"
fi
echo "Virtualization setup completed."
fi
}