293 lines
9.3 KiB
Bash
293 lines
9.3 KiB
Bash
#!/bin/sh
|
|
# Install script for Debian-based distros (Debian, Ubuntu, Linux Mint).
|
|
# Each prompt is independent; answer N to skip anything.
|
|
|
|
set -e
|
|
|
|
command -v apt >/dev/null 2>&1 || { echo "apt not found, this script is for Debian-based distros"; exit 1; }
|
|
|
|
. /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|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" || true
|
|
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 () {
|
|
if [ ! -d /sys/class/power_supply/BAT0 ] && [ ! -d /sys/class/power_supply/BAT1 ]; then
|
|
echo "No battery detected, skipping TLP"
|
|
echo
|
|
return 0
|
|
fi
|
|
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 () {
|
|
confirm "Brave Origin" || return 0
|
|
curl -fsS https://dl.brave.com/install.sh | FLAVOR=origin sh
|
|
echo
|
|
}
|
|
|
|
install_discord () {
|
|
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 () {
|
|
confirm "Angry IP Scanner" || return 0
|
|
require_amd64 "Angry IP Scanner" || return 0
|
|
REPO="angryip/ipscan"
|
|
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, skipping"
|
|
echo
|
|
return 0
|
|
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 () {
|
|
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|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 ~/.cache/libreoffice ~/.local/share/libreoffice
|
|
;;
|
|
*) echo "Keeping LibreOffice" ;;
|
|
esac
|
|
echo
|
|
}
|
|
|
|
install_sublime () {
|
|
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 () {
|
|
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 () {
|
|
confirm "Flatseal" || return 0
|
|
ensure_flathub
|
|
flatpak install --user -y flathub com.github.tchx84.Flatseal
|
|
echo
|
|
}
|
|
|
|
install_stremio () {
|
|
confirm "Stremio" || return 0
|
|
ensure_flathub
|
|
flatpak install --user -y flathub com.stremio.Stremio
|
|
echo
|
|
}
|
|
|
|
install_balena_etcher () {
|
|
confirm "balenaEtcher" || return 0
|
|
require_amd64 "balenaEtcher" || return 0
|
|
REPO="balena-io/etcher"
|
|
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, skipping"
|
|
echo
|
|
return 0
|
|
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 () {
|
|
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_signal () {
|
|
confirm "Signal Desktop" || return 0
|
|
require_amd64 "Signal Desktop" || return 0
|
|
wget -qO- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null
|
|
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | sudo tee /etc/apt/sources.list.d/signal-desktop.list > /dev/null
|
|
sudo apt update
|
|
sudo apt install -y signal-desktop
|
|
echo
|
|
}
|
|
|
|
# ---------- run ----------
|
|
|
|
echo "Updating package list..."
|
|
sudo apt update
|
|
echo
|
|
|
|
# Plain APT packages
|
|
ask_install "PCManFM" "pcmanfm"
|
|
ask_install "Flameshot" "flameshot"
|
|
ask_install "Remmina" "remmina"
|
|
ask_install "PuTTY" "putty"
|
|
ask_install "WireGuard" "wireguard"
|
|
ask_install "mpv" "mpv"
|
|
ask_install "Hydrapaper" "hydrapaper"
|
|
ask_install "Thunderbird" "thunderbird"
|
|
ask_install "Firefox" "$FIREFOX_PKG"
|
|
|
|
# APT packages needing extra setup
|
|
install_wireshark
|
|
install_steam
|
|
install_tlp
|
|
|
|
# Vendor repos, downloads, Flatpak
|
|
install_brave_origin
|
|
install_discord
|
|
install_angry_ip_scanner
|
|
install_onlyoffice
|
|
install_sublime
|
|
install_joplin
|
|
install_flatseal
|
|
install_stremio
|
|
install_balena_etcher
|
|
install_vscode
|
|
install_signal
|
|
|
|
# Last, so nothing above depends on firewall rules
|
|
install_ufw
|
|
|
|
#jexiftoolgui?
|
|
#redshift?
|
|
#wine
|
|
#WineZGUI
|
|
|
|
echo "Finished." |