From 4e38b591554098bfe75dd903600e071b57cff135 Mon Sep 17 00:00:00 2001 From: Gabe Date: Sun, 11 Oct 2026 22:30:45 +0000 Subject: [PATCH] Update Bash Scripts/Install_Programs.sh --- Bash Scripts/Install_Programs.sh | 458 +++++++++++++------------------ 1 file changed, 188 insertions(+), 270 deletions(-) diff --git a/Bash Scripts/Install_Programs.sh b/Bash Scripts/Install_Programs.sh index c42e3d6..c32ecf0 100644 --- a/Bash Scripts/Install_Programs.sh +++ b/Bash Scripts/Install_Programs.sh @@ -1,341 +1,258 @@ #!/bin/sh +# Install script for Debian-based distros (Debian, Ubuntu, Linux Mint). +# Each prompt is independent; answer N to skip anything. set -e -ask_install () { - PACKAGE="$1" - APT_NAME="$2" +command -v apt >/dev/null 2>&1 || { echo "apt not found, this script is for Debian-based distros"; exit 1; } - printf "Install %s? [y/N]: " "$PACKAGE" - read answer +. /etc/os-release +ARCH=$(dpkg --print-architecture) + +# Debian ships Firefox as firefox-esr; Ubuntu/Mint use "firefox" +# (Mint's is a real deb from its own repo; plain Ubuntu's is a snap shim) +case "$ID" in + debian) FIREFOX_PKG="firefox-esr" ;; + *) FIREFOX_PKG="firefox" ;; +esac + +# Scratch dir for downloads. 755 so apt's _apt user can read .deb files from it. +WORKDIR=$(mktemp -d) +chmod 755 "$WORKDIR" +trap 'rm -rf "$WORKDIR"' EXIT + +# ---------- helpers ---------- + +# Prompts; returns 0 if the user said yes, 1 otherwise. +# Use as: confirm "Name" || return 0 +confirm () { + printf "Install %s? [y/N]: " "$1" + read -r answer || answer="" case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - sudo apt install -y "$APT_NAME" - ;; - *) - echo "Skipping $PACKAGE" - ;; + y|Y|yes|YES) echo "Installing $1..."; return 0 ;; + *) echo "Skipping $1"; echo; return 1 ;; esac +} + +require_amd64 () { + if [ "$ARCH" != "amd64" ]; then + echo "$1 only supports amd64 here (this is $ARCH), skipping" + echo + return 1 + fi +} + +ensure_flathub () { + command -v flatpak >/dev/null 2>&1 || sudo apt install -y flatpak + flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +} + +# Plain apt package. A failure here is reported but doesn't abort the script. +ask_install () { + confirm "$1" || return 0 + sudo apt install -y "$2" || echo "❌ Failed to install $1, continuing" echo } +# ---------- apt packages needing extra steps ---------- + +install_wireshark () { + confirm "Wireshark" || return 0 + # apt asks via debconf whether non-root users may capture packets + sudo apt install -y wireshark + # Only matters if you answered "Yes" to that prompt + sudo usermod -aG wireshark "$USER" + echo "Log out and back in for the wireshark group to take effect." + echo +} + +install_steam () { + confirm "Steam" || return 0 + # 32-bit libraries are required. Package comes from multiverse (Ubuntu/Mint) + # or contrib (Debian); on Debian, enable contrib first if this fails. + sudo dpkg --add-architecture i386 + sudo apt update + sudo apt install -y steam-installer + echo "Launch Steam once to let it download and install itself." + echo +} + +install_tlp () { + confirm "TLP" || return 0 + # power-profiles-daemon (default on GNOME/KDE) fights TLP over the same settings + if systemctl cat power-profiles-daemon.service >/dev/null 2>&1; then + sudo systemctl disable --now power-profiles-daemon.service || true + sudo systemctl mask power-profiles-daemon.service + fi + sudo apt install -y tlp tlp-rdw # tlp-rdw needs NetworkManager; drop it if you don't use that + sudo systemctl enable --now tlp.service + sudo tlp-stat -s # should show "State = enabled" + sudo tlp-stat -b || true # exits non-zero with no battery (desktop/VM) + echo +} + +install_ufw () { + confirm "UFW" || return 0 + sudo apt install -y ufw + sudo ufw default deny incoming + sudo ufw default allow outgoing + # If running over SSH, allow the port this session came in on so enabling doesn't kill it + if [ -n "$SSH_CONNECTION" ]; then + SSH_PORT=$(echo "$SSH_CONNECTION" | awk '{print $4}') + sudo ufw allow "$SSH_PORT/tcp" + fi + sudo ufw --force enable + sudo ufw status verbose + echo +} + +# ---------- vendor repos / downloads ---------- + install_brave_origin () { - PACKAGE="Brave Origin" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - curl -fsS https://dl.brave.com/install.sh | FLAVOR=origin sh - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Brave Origin" || return 0 + curl -fsS https://dl.brave.com/install.sh | FLAVOR=origin sh echo } install_discord () { - PACKAGE="Discord" - DISCORD_URL="https://discord.com/api/download?platform=linux&format=deb" - DEB_FILE="discord_latest_amd64.deb" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - wget -O "$DEB_FILE" "$DISCORD_URL" - sudo dpkg -i "$DEB_FILE" || sudo apt -f install -y - rm -f "$DEB_FILE" - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Discord" || return 0 + require_amd64 "Discord" || return 0 + wget -q --show-progress -O "$WORKDIR/discord.deb" "https://discord.com/api/download?platform=linux&format=deb" + sudo apt install -y "$WORKDIR/discord.deb" echo } install_angry_ip_scanner () { - PACKAGE="Angry IP Scanner" + confirm "Angry IP Scanner" || return 0 + require_amd64 "Angry IP Scanner" || return 0 REPO="angryip/ipscan" - ARCH="amd64" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - # Get latest release tag from GitHub API - LATEST_TAG=$(curl -s https://api.github.com/repos/$REPO/releases/latest \ - | grep '"tag_name"' \ - | cut -d '"' -f4) - - if [ -z "$LATEST_TAG" ]; then - echo "❌ Failed to determine latest version" - exit 1 - fi - # Extract version number (e.g. 3.6.2) - VERSION="${LATEST_TAG#v}" - DEB_FILE="ipscan_${VERSION}_${ARCH}.deb" - DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/$DEB_FILE" - wget -q --show-progress "$DOWNLOAD_URL" - sudo dpkg -i "$DEB_FILE" || sudo apt -f install -y - - # Cleanup - rm -f "$DEB_FILE" - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" \ + | grep '"tag_name"' \ + | cut -d '"' -f4) + if [ -z "$LATEST_TAG" ]; then + echo "❌ Failed to determine latest version" + exit 1 + fi + VERSION="${LATEST_TAG#v}" + DEB_FILE="ipscan_${VERSION}_${ARCH}.deb" + wget -q --show-progress -O "$WORKDIR/$DEB_FILE" "https://github.com/$REPO/releases/download/$LATEST_TAG/$DEB_FILE" + sudo apt install -y "$WORKDIR/$DEB_FILE" echo } install_onlyoffice () { - PACKAGE="OnlyOffice" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer + confirm "OnlyOffice" || return 0 + mkdir -p -m 700 ~/.gnupg + + # Import the ONLYOFFICE GPG key into a throwaway keyring + gpg --no-default-keyring \ + --keyring "gnupg-ring:$WORKDIR/onlyoffice.gpg" \ + --keyserver hkp://keyserver.ubuntu.com:80 \ + --recv-keys CB2DE8E5 + sudo install -m 644 -o root -g root "$WORKDIR/onlyoffice.gpg" /usr/share/keyrings/onlyoffice.gpg + + echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] https://download.onlyoffice.com/repo/debian squeeze main" \ + | sudo tee /etc/apt/sources.list.d/onlyoffice.list > /dev/null + sudo apt update + sudo apt install -y onlyoffice-desktopeditors + echo + + # Separate prompt, because this removes software and user settings + printf "Also remove LibreOffice and its user settings? [y/N]: " + read -r answer || answer="" case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - #Create GPG directory - mkdir -p -m 700 ~/.gnupg - - #Import the ONLYOFFICE GPG key - gpg --no-default-keyring \ - --keyring gnupg-ring:/tmp/onlyoffice.gpg \ - --keyserver hkp://keyserver.ubuntu.com:80 \ - --recv-keys CB2DE8E5 - - #Fix permissions and move the keyring - chmod 644 /tmp/onlyoffice.gpg - sudo chown root:root /tmp/onlyoffice.gpg - sudo mv /tmp/onlyoffice.gpg /usr/share/keyrings/onlyoffice.gpg - - #Add the ONLYOFFICE repository - echo "deb [signed-by=/usr/share/keyrings/onlyoffice.gpg] https://download.onlyoffice.com/repo/debian squeeze main" \ - | sudo tee /etc/apt/sources.list.d/onlyoffice.list > /dev/null - - #Update package lists - sudo apt-get update - - #Install ONLYOFFICE Desktop Editors - sudo apt-get install -y onlyoffice-desktopeditors - - #Remove LibreOffice - sudo apt purge libreoffice* + y|Y|yes|YES) + # No -y on purpose: read apt's removal list before confirming + sudo apt purge 'libreoffice*' sudo apt autoremove --purge - rm -rf ~/.config/libreoffice - rm -rf ~/.cache/libreoffice - rm -rf ~/.local/share/libreoffice - ;; - *) - echo "Skipping $PACKAGE" + rm -rf ~/.config/libreoffice ~/.cache/libreoffice ~/.local/share/libreoffice ;; + *) echo "Keeping LibreOffice" ;; esac echo } install_sublime () { - PACKAGE="Sublime Text Editor" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - sudo wget -O- https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/sublimehq.gpg - echo 'deb [signed-by=/usr/share/keyrings/sublimehq.gpg] https://download.sublimetext.com/ apt/stable/' | sudo tee /etc/apt/sources.list.d/sublime-text.list - sudo apt update - sudo apt install sublime-text - rm -f ./wget-log - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Sublime Text Editor" || return 0 + wget -qO- https://download.sublimetext.com/sublimehq-pub.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/sublimehq.gpg > /dev/null + echo 'deb [signed-by=/usr/share/keyrings/sublimehq.gpg] https://download.sublimetext.com/ apt/stable/' | sudo tee /etc/apt/sources.list.d/sublime-text.list > /dev/null + sudo apt update + sudo apt install -y sublime-text echo } install_joplin () { - PACKAGE="Joplin" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - wget -O - https://raw.githubusercontent.com/laurent22/joplin/dev/Joplin_install_and_update.sh | bash - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Joplin" || return 0 + # Vendor's official installer; pulled from the mutable "dev" branch + wget -qO - https://raw.githubusercontent.com/laurent22/joplin/dev/Joplin_install_and_update.sh | bash echo } install_flatseal () { - PACKAGE="Flatseal" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - if ! command -v flatpak >/dev/null 2>&1; then - echo "Flatpak not found, installing..." - sudo apt install -y flatpak - fi - if ! flatpak remote-list | grep -q flathub; then - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - fi - flatpak install -y flathub com.github.tchx84.Flatseal - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Flatseal" || return 0 + ensure_flathub + flatpak install --user -y flathub com.github.tchx84.Flatseal echo } install_stremio () { - PACKAGE="Stremio" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - if ! command -v flatpak >/dev/null 2>&1; then - echo "Flatpak not found, installing..." - sudo apt install -y flatpak - fi - if ! flatpak remote-list | grep -q flathub; then - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - fi - flatpak install -y flathub com.stremio.Stremio - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Stremio" || return 0 + ensure_flathub + flatpak install --user -y flathub com.stremio.Stremio echo } install_balena_etcher () { - PACKAGE="balenaEtcher" + confirm "balenaEtcher" || return 0 + require_amd64 "balenaEtcher" || return 0 REPO="balena-io/etcher" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - DEB_URL=$(curl -s https://api.github.com/repos/$REPO/releases/latest \ - | grep "browser_download_url.*amd64.deb" \ - | cut -d '"' -f4) - - if [ -z "$DEB_URL" ]; then - echo "❌ Failed to determine latest release" - exit 1 - fi - DEB_FILE=$(basename "$DEB_URL") - wget -q --show-progress "$DEB_URL" - sudo apt install -y "./$DEB_FILE" - - # Cleanup - rm -f "$DEB_FILE" - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac - echo -} - -install_tlp () { - PACKAGE="TLP" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - # power-profiles-daemon (default on GNOME/KDE) fights TLP over the same settings - if systemctl list-unit-files power-profiles-daemon.service >/dev/null 2>&1; then - sudo systemctl disable --now power-profiles-daemon.service || true - sudo systemctl mask power-profiles-daemon.service - fi - sudo apt install -y tlp tlp-rdw - sudo systemctl enable --now tlp.service - sudo tlp-stat -s # should show "State = enabled" - sudo tlp-stat -b || true # battery info - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + DEB_URL=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" \ + | grep "browser_download_url.*amd64.deb" \ + | cut -d '"' -f4 \ + | head -n1) + if [ -z "$DEB_URL" ]; then + echo "❌ Failed to determine latest release" + exit 1 + fi + DEB_FILE=$(basename "$DEB_URL") + wget -q --show-progress -O "$WORKDIR/$DEB_FILE" "$DEB_URL" + sudo apt install -y "$WORKDIR/$DEB_FILE" echo } install_vscode () { - PACKAGE="Visual Studio Code" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - sudo apt install -y wget gpg apt-transport-https - wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/packages.microsoft.gpg > /dev/null - echo "deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null - sudo apt update - sudo apt install -y code - sudo rm -f /etc/apt/sources.list.d/vscode.list - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac + confirm "Visual Studio Code" || return 0 + sudo apt install -y wget gpg apt-transport-https + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/packages.microsoft.gpg > /dev/null + echo "deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null + sudo apt update + sudo apt install -y code echo } -install_ufw () { - PACKAGE="UFW" - printf "Install %s? [y/N]: " "$PACKAGE" - read answer - case "$answer" in - y|Y) - echo "Installing $PACKAGE..." - sudo apt install -y ufw - sudo ufw default deny incoming - sudo ufw default allow outgoing - # If running over SSH, allow the port this session came in on so enabling doesn't kill it - if [ -n "$SSH_CONNECTION" ]; then - SSH_PORT=$(echo "$SSH_CONNECTION" | awk '{print $4}') - sudo ufw allow "$SSH_PORT/tcp" - fi - sudo ufw --force enable - sudo ufw status verbose - ;; - *) - echo "Skipping $PACKAGE" - ;; - esac - echo -} +# ---------- run ---------- echo "Updating package list..." sudo apt update echo -# APT packages +# Plain APT packages ask_install "PCManFM" "pcmanfm" -ask_install "Wireshark" "wireshark" ask_install "Flameshot" "flameshot" ask_install "Remmina" "remmina" ask_install "PuTTY" "putty" ask_install "WireGuard" "wireguard" -ask_install "Steam" "steam" ask_install "mpv" "mpv" ask_install "Hydrapaper" "hydrapaper" ask_install "Thunderbird" "thunderbird" -ask_install "Firefox ESR" "firefox-esr" +ask_install "Firefox" "$FIREFOX_PKG" -# Not in standard Debian repos +# APT packages needing extra setup +install_wireshark +install_steam +install_tlp + +# Vendor repos, downloads, Flatpak install_brave_origin install_discord install_angry_ip_scanner @@ -345,13 +262,14 @@ install_joplin install_flatseal install_stremio install_balena_etcher -install_tlp install_vscode + +# Last, so nothing above depends on firewall rules install_ufw #jexiftoolgui? #redshift? -#wine +#wine (you already have the WineHQ repo configured) #WineZGUI echo "Finished." \ No newline at end of file