Files
linux-scripts/setup-linux.sh

233 lines
11 KiB
Bash
Executable File

#!/bin/bash
# global var
DISTRO=""
function get_distribution() {
if [[ -e /etc/debian_version ]]; then
source /etc/os-release
if [[ $ID == "debian" || $ID == "raspbian" ]]; then
DISTRO="debian"
elif [[ $ID == "ubuntu" ]]; then
DISTRO="ubuntu"
fi
elif [[ -e /etc/system-release ]]; then
DISTRO="fedora"
elif [[ -e /etc/arch-release ]]; then
DISTRO="arch"
else
whiptail --title "Error" --msgbox "Incompatible Linux Distribution." 8 78
exit 1
fi
echo "Detected distribution $DISTRO"
}
function update_system() {
if (whiptail --title "System Update" --yesno "Should we update the system?" 8 78); then
echo "Updating system..."
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt update && sudo apt upgrade -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf up -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -Syu --noconfirm
fi
whiptail --title "Success" --msgbox "Update done!" 8 78
fi
}
function install_general_tools() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install sudo nano git curl wget htop btop scrcpy vlc geary -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in sudo nano git curl wget htop btop scrcpy vlc geary -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed sudo nano git curl wget htop btop scrcpy vlc geary --noconfirm
fi
}
function setup_repo() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install ca-certificates software-properties-gtk -y
sudo curl https://repo.waydro.id | sudo bash
sudo add-apt-repository ppa:o2sh/onefetch
sudo add-apt-repository ppa:oguzhaninan/stacer
sudo add-apt-repository ppa:serge-rider/dbeaver-ce
sudo echo 'deb http://download.opensuse.org/repositories/hardware:/razer/Debian_12/ /' | sudo tee /etc/apt/sources.list.d/hardware:razer.list
sudo curl -fsSL https://download.opensuse.org/repositories/hardware:razer/Debian_12/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/hardware_razer.gpg > /dev/null
sudo apt update
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf copr enable varlad/onefetch -y
sudo dnf copr enable atim/heroic-games-launcher -y
sudo dnf copr enable atim/starship -y
sudo dnf copr enable zeno/scrcpy -y
sudo dnf config-manager --add-repo "https://download.opensuse.org/repositories/hardware:razer/Fedora_$(rpm -E %fedora)/hardware:razer.repo"
sudo dnf config-manager --add-repo 'https://download.opensuse.org/repositories/home:/Maroxy:/AAT-Apps/Fedora_Rawhide/home:Maroxy:AAT-Apps.repo'
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
if [ ! -e /etc/yum.repos.d/vscode.repo ]; then
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
fi
elif [[ $DISTRO == "arch" ]]; then
if ! grep -q "chaotic-aur" /etc/pacman.conf; then
yes | sudo pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com
yes | sudo pacman-key --lsign-key 3056513887B78AEB
sudo pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' --noconfirm
echo -e '[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist' | sudo tee -a /etc/pacman.conf
else
echo Chaotic-AUR already setup
fi
if ! grep -q "blackarch" /etc/pacman.conf; then
curl -sSL https://blackarch.org/strap.sh | sudo bash
else
echo BlackArch already setup
fi
sudo pacman -S --needed yay --noconfirm
fi
}
function install_browser() {
if (whiptail --title "System Update" --yesno "Should we install web browsers?" 8 78); then
echo "Installing browsers..."
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install firefox chromium torbrowser-launcher -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in firefox chromium tor torbrowser-launcher -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed firefox chromium tor tor-browser --noconfirm
fi
fi
}
function install_distro_specific_packages() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install stacer qbittorrent -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in kernel-devel starship stacer qbittorrent -y
flatpak install flathub com.moonlight_stream.Moonlight -y --noninteractive --system
flatpak install flathub io.github.thaunknown.miru -y --noninteractive --system
flatpak install flathub com.stremio.Stremio -y --noninteractive --system
elif [[ $DISTRO == "arch" ]]; then
# Base and utility packages
sudo pacman -S --needed --noconfirm linux-headers dkms base-devel jshon expac acpid avahi net-tools xdg-user-dirs p7zip unrar unzip unace xz rsync nfs-utils cifs-utils ntfs-3g exfat-utils gvfs udisks2 starship macchanger plymouth plymouth-kcm breeze-plymouth
# Hardware packages
sudo pacman -S --needed --noconfirm mkinitcpio-firmware mesa lib32-mesa vulkan-icd-loader lib32-vulkan-icd-loader xf86-video-amdgpu nvidia-utils lib32-nvidia-utils libvdpau lib32-libvdpau libva-mesa-driver lib32-libva-mesa-driver mesa-vdpau lib32-mesa-vdpau libva-vdpau-driver lib32-libva-vdpau-driver vulkan-radeon lib32-vulkan-radeon xf86-input-synaptics xf86-input-libinput xf86-input-evdev supergfxctl
# Printer
sudo pacman -S --needed --noconfirm system-config-printer foomatic-db foomatic-db-engine gutenprint gsfonts cups cups-pdf cups-filters sane skanlite hplip
# Network
sudo pacman -S --needed --noconfirm networkmanager networkmanager-openvpn networkmanager-pptp networkmanager-vpnc wireless_tools wpa_supplicant ifplugd dialog bluez bluez-utils
# Sound
sudo pacman -S --needed --noconfirm alsa-utils pipewire pipewire-pulse pipewire-jack wireplumber pavucontrol-qt
# Apps
sudo pacman -S --needed --noconfirm moonlight-qt stremio onlyoffice-bin qbittorrent stacer
yay -S --needed --noconfirm miru-bin
sudo systemctl enable acpid avahi-daemon systemd-timesyncd fstrim.timer cups.service saned.socket NetworkManager bluetooth
sudo gpasswd -a "$USER" adbusers
sudo plymouth-set-default-theme -R spinner
fi
}
function install_gaming() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install steam gamescope gamemode mangohud lutris discord -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in steam gamescope gamemode mangohud lutris discord protonup-qt heroic-games-launcher-bin an-anime-game-launcher honkers-launcher the-honkers-railway-launcher -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed steam gamescope gamemode mangohud lutris discord protonup-qt heroic-games-launcher-bin an-anime-game-launcher-bin --noconfirm
yay -S --needed honkers-launcher-bin the-honkers-railway-launcher-bin --noconfirm
fi
}
function install_virt() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install qemu-system libvirt-daemon-system virt-manager distrobox podman waydroid -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in libvirt lxc libvirt-daemon-lxc virt-manager distrobox podman waydroid -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed libvirt libvirt-storage-gluster libvirt-storage-iscsi-direct virt-firmware virt-viewer virt-manager lxc lxcfs distrobox podman waydroid --noconfirm
fi
sudo systemctl enable libvirtd waydroid-container
}
function install_remote() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install remmina -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in remmina remmina-gnome-session remmina-plugins-exec remmina-plugins-rdp remmina-plugins-spice remmina-plugins-vnc remmina-plugins-www remmina-plugins-x2go parsec -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed remmina remmina-plugin-rustdesk remmina-plugin-teamviewer parsec-bin --noconfirm
fi
}
function install_u2f() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install yubikey-manager yubikey-personalization yubioath-desktop -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in fedora-packager-yubikey libyubikey pam_yubico yubico-piv-tool yubikey-manager yubikey-personalization-gui -y
flatpak install flathub com.yubico.yubioath -y --noninteractive --system
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed yubico-pam yubikey-full-disk-encryption yubikey-manager-qt yubikey-personalization yubikey-personalization-gui yubikey-touch-detector yubioath-desktop --noconfirm
fi
}
function install_fetch() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install fastfetch onefetch -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in fastfetch onefetch -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed fastfetch onefetch --noconfirm
fi
}
function install_terminal() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install alacritty kitty zsh -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in alacritty kitty kitty-bash-integration zsh autojump-zsh zsh-autosuggestions zsh-syntax-highlighting -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed alacritty kitty kitty-shell-integration kitty-terminfo zsh zsh-autosuggestions zsh-completions zsh-history-substring-search zsh-lovers zsh-syntax-highlighting --noconfirm
sudo chsh -s /usr/bin/zsh "$USER"
fi
}
function install_dev() {
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install mariadb-server dbeaver-ce -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in mariadb-server https://dbeaver.io/files/dbeaver-ce-latest-stable.x86_64.rpm code android-tools -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed mariadb dbeaver dbeaver-plugin-office dbeaver-plugin-svg-format dbeaver-plugin-apache-poi visual-studio-code-bin android-tools android-udev --noconfirm
fi
}
function install_openrazer() {
if (whiptail --title "System Update" --yesno "Should we install web browsers?" 8 78); then
if [[ $DISTRO =~ (debian|ubuntu) ]]; then
sudo apt install openrazer-meta -y
elif [[ $DISTRO == "fedora" ]]; then
sudo dnf in openrazer-meta -y
sudo rpm -e gpg-pubkey-d6d11ce4-5418547d
sudo dnf in --nogpgcheck polychromatic -y
elif [[ $DISTRO == "arch" ]]; then
sudo pacman -S --needed polychromatic openrazer-meta --noconfirm
fi
sudo gpasswd -a "$USER" plugdev
fi
}
get_distribution
update_system
install_general_tools
setup_repo
install_browser
install_distro_specific_packages
install_gaming
install_virt
install_remote
install_u2f
install_fetch
install_terminal
install_dev
install_openrazer