Files
linux-scripts/debian-setup.sh
2025-03-25 13:56:43 +01:00

351 lines
10 KiB
Bash
Executable File

#!/bin/bash
# Function name: Install packages
# Description: Install packages from an array
# Arguments:
# $1: Package list (array)
install_packages() {
local packages=("${!1}")
for package in "${packages[@]}"; do
sudo apt-get install -y "$package"
done
}
# Function name: Install package
# Description: Install a package
# Arguments:
# $1: Package name
install_package() {
sudo apt-get install -y "$1"
}
# Function name: Add repositories
# Description: Add repositories from an array
# Arguments:
# $1: Repository list (array)
add_repositories() {
options=(
"debian" "Debian official repository" ON
"brave" "Brave official repository" OFF
"chrome" "Google Chrome official repository" OFF
"edge" "Microsoft Edge official repository" OFF
"librewolf" "Librewolf official repository" OFF
"mullvad" "Mullvad official repository" OFF
"waydroid" "Waydroid official repository" OFF
)
selected_repositories=$(whiptail --title "Add Repositories" --checklist \
"Choose the repositories you want to add:" 20 78 7 \
"${options[@]}" 3>&1 1>&2 2>&3)
for repository in $selected_repositories; do
case $repository in
"debian")
sudo add-apt-repository main
;;
"brave")
sudo apt install apt-transport-https curl -y
sudo curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add -
echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list
;;
"chrome")
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
;;
"edge")
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge.list'
;;
"librewolf")
sudo apt install extrepo -y
sudo extrepo enable librewolf
;;
"mullvad")
sudo curl -fsSLo /usr/share/keyrings/mullvad-keyring.asc https://repository.mullvad.net/deb/mullvad-keyring.asc
echo "deb [signed-by=/usr/share/keyrings/mullvad-keyring.asc arch=$( dpkg --print-architecture )] https://repository.mullvad.net/deb/stable $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/mullvad.list
;;
"waydroid")
sudo apt install curl ca-certificates -y
curl -s https://repo.waydro.id | sudo bash
;;
esac
done
}
# Function name: Update system
# Description: Update the system
update_system() {
sudo apt-get update
sudo apt-get upgrade -y
}
# Function name: Setup plymouth
# Description: Setup plymouth
setup_plymouth() {
install_package plymouth
install_package plymouth-themes
sudo plymouth-set-default-theme -R spinner
}
# Packages group definitions
zsh_packages=(
zsh
zsh-autosuggestions
zsh-syntax-highlighting
)
games_packages=(
steam-installer
)
pipewire_packages=(
pipewire
pipewire-audio-client-libraries
pipewire-pulse
pipewire-jack
pipewire-alsa
wireplumber
)
cups_packages=(
cups
cups-filters
system-config-printer
)
networkmanager_packages=(
network-manager
network-manager-openvpn
network-manager-pptp
network-manager-vpnc
network-manager-strongswan
network-manager-l2tp
wpasupplicant
)
bluetooth_packages=(
bluez
bluez-tools
blueman
)
virtualization_packages=(
qemu-kvm
libvirt-daemon-system
libvirt-clients
virt-manager
virt-viewer
swtpm
)
containers_packages=(
podman
distrobox
waydroid
lxc
)
thunderbird_packages=(
thunderbird
thunderbird-l10n-all
)
# Function name: Setup browser
# Description: Setup browser
setup_browser() {
options=(
"Firefox" "Install Firefox" ON
"Chromium" "Install Chromium" OFF
"Brave" "Install Brave" OFF
"Google Chrome" "Install Google Chrome" OFF
"Tor Browser" "Install Tor Browser" OFF
"Mullvad Browser" "Install Mullvad Browser" OFF
"Edge Stable" "Install Edge Stable" OFF
"LibreWolf" "Install LibreWolf" OFF
"Links" "Install Links" OFF
)
selected_browsers=$(whiptail --title "Setup Browser" --checklist \
"Choose the browsers you want to install:" 20 78 9 \
"${options[@]}" 3>&1 1>&2 2>&3)
for browser in $selected_browsers; do
case $browser in
"\"Firefox\"")
install_package firefox-esr
;;
"\"Chromium\"")
install_package chromium
;;
"\"Brave\"")
install_package brave-browser
;;
"\"Google Chrome\"")
install_package google-chrome-stable
;;
"\"Tor Browser\"")
install_package torbrowser-launcher
;;
"\"Mullvad Browser\"")
install_package mullvad-browser
;;
"\"Edge Stable\"")
install_package microsoft-edge-stable
;;
"\"LibreWolf\"")
install_package librewolf
;;
"\"Links\"")
install_package links
;;
esac
done
}
# Function name: Setup U2F
# Description: Setup U2F
setup_u2f() {
install_package pamu2fcfg
install_package libpam-u2f
mkdir -p ~/.config/Yubico
pamu2fcfg > ~/.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
echo "auth sufficient pam_u2f.so cue origin=pam://$HOST appid=pam://$HOST" | sudo tee -a /etc/pam.d/u2f-sufficient
sudo sed -i '/^password\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/su
sudo sed -i '/^auth\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/sudo
sudo sed -i '/^auth\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/passwd
sudo sed -i '/^auth\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/system-login
sudo cp /usr/lib/pam.d/polkit-1 /etc/pam.d/polkit-1
sudo sed -i '/^auth\s*include\s*system-auth/i auth include u2f-sufficient' /etc/pam.d/polkit-1
}
# Function name: Setup OpenRGB
# Description: Setup OpenRGB
setup_openrgb() {
install_package openrgb
sudo gpasswd -a "$USER" plugdev
sudo systemctl enable --now openrgb
}
# Function name: Install packages group
# Description: Install packages group by asking with a selection menu which group would you like to install
install_packages_group() {
options=(
"Zsh" "Install Zsh packages" OFF
"Theme" "Install Theme packages" OFF
"Games" "Install Games packages" OFF
"Pipewire" "Install Pipewire packages" OFF
"Cups" "Install Cups packages" OFF
"NetworkManager" "Install NetworkManager packages" OFF
"Bluetooth" "Install Bluetooth packages" OFF
"Virtualization" "Install Virtualization packages" OFF
"Containers" "Install Containers packages" OFF
"U2F" "Setup U2F" OFF
"OpenRGB" "Setup OpenRGB" OFF
"Thunderbird" "Install Thunderbird" OFF
)
selected_groups=$(whiptail --title "Install Packages Group" --checklist \
"Choose the packages group you want to install:" 20 78 10 \
"${options[@]}" 3>&1 1>&2 2>&3)
for group in $selected_groups; do
case $group in
"\"Zsh\"")
install_packages zsh_packages[@]
;;
"\"Theme\"")
install_packages theme_packages[@]
;;
"\"Games\"")
install_packages games_packages[@]
;;
"\"Pipewire\"")
install_packages pipewire_packages[@]
;;
"\"Cups\"")
install_packages cups_packages[@]
;;
"\"NetworkManager\"")
install_packages networkmanager_packages[@]
;;
"\"Bluetooth\"")
install_packages bluetooth_packages[@]
;;
"\"Virtualization\"")
install_packages virtualization_packages[@]
;;
"\"Containers\"")
install_packages containers_packages[@]
;;
"\"U2F\"")
setup_u2f
;;
"\"OpenRGB\"")
setup_openrgb
;;
"\"Thunderbird\"")
install_packages thunderbird_packages[@]
;;
esac
done
}
# Function name: Setup flatpak
# Description: Setup flatpak
setup_flatpak() {
if whiptail --title "Setup Flatpak" --yesno "Would you like to setup Flatpak?" 10 60; then
install_package flatpak
flatpak remote-add --if-not-exists --system flathub https://flathub.org/repo/flathub.flatpakrepo
fi
}
# function name : setup_kdeconnect
# Description: setup kdeconnect
setup_kdeconnect() {
if whiptail --title "Setup KDE Connect" --yesno "Would you like to setup KDE Connect?" 10 60; then
options=(
"kdeconnect" "Install KDE Connect" OFF
"gsconnect" "Install GSConnect" OFF
)
selected_option=$(whiptail --title "Setup KDE Connect" --radiolist "Choose the package you want to install:" 20 78 2 "${options[@]}" 3>&1 1>&2 2>&3)
case $selected_option in
"\"kdeconnect\"")
install_package kdeconnect
;;
"\"gsconnect\"")
install_package gnome-shell-extension-gsconnect
;;
esac
fi
}
# function name : setup_office_suite
# Description: setup office suite
setup_office_suite() {
options=(
"LibreOffice" "Install LibreOffice" OFF
"OnlyOffice" "Install OnlyOffice" OFF
"WPS Office" "Install WPS Office" OFF
"FreeOffice" "Install FreeOffice" OFF
)
selected_option=$(whiptail --title "Setup Office Suite" --radiolist "Choose the office suite you want to install:" 20 78 4 "${options[@]}" 3>&1 1>&2 2>&3)
case $selected_option in
"\"LibreOffice\"")
install_package libreoffice-fresh
;;
"\"OnlyOffice\"")
install_package onlyoffice-bin
;;
"\"WPS Office\"")
install_package wps-office
;;
"\"FreeOffice\"")
install_package freeoffice
;;
esac
}
# Main script
update_system
setup_plymouth
setup_browser
install_packages_group
setup_flatpak
setup_kdeconnect
setup_office_suite