Last active
August 18, 2025 18:26
-
-
Save ozturkoktay/4d85afd42316b16f6bb6a7f6a391992a to your computer and use it in GitHub Desktop.
Bash script for installing Ubuntu apps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This script automates the setup of a fresh Ubuntu installation. | |
# It installs common applications, development tools, and sets up the shell environment. | |
# Exit immediately if a command exits with a non-zero status. | |
set -e | |
print_header() { | |
tput setaf 1; echo -e "\n===> $1"; tput sgr0 | |
} | |
add_gpg_key() { | |
print_header "Adding GPG key for $2" | |
if [ ! -f "$2" ]; then | |
curl -fsSL "$1" | sudo gpg --dearmor -o "$2" | |
else | |
echo "GPG key $2 already exists. Skipping." | |
fi | |
} | |
add_apt_repository_and_key() { | |
add_gpg_key "$1" "$2" | |
echo "$3" | sudo tee "/etc/apt/sources.list.d/$4.list" > /dev/null | |
} | |
install_deb_from_url() { | |
local app_name="$1" | |
local url="$2" | |
local pkg_name="$3" | |
if dpkg -s "$pkg_name" &> /dev/null; then | |
echo "$app_name is already installed. Skipping." | |
else | |
print_header "Installing $app_name" | |
local deb_file="$app_name.deb" | |
wget --show-progress -q -O "$deb_file" "$url" | |
sudo apt install -y "./$deb_file" | |
rm -f "./$deb_file" | |
fi | |
} | |
# --- Main Script --- | |
# Create a temporary directory for downloads and schedule it for removal on exit. | |
TMP_DIR=$(mktemp -d) | |
trap 'rm -rf -- "$TMP_DIR"' EXIT | |
cd "$TMP_DIR" | |
# --- System Update and Base Packages --- | |
print_header "Updating system and installing base packages" | |
sudo apt update && sudo apt upgrade -y && sudo apt dist-upgrade -y && sudo apt full-upgrade -y && sudo ubuntu-drivers autoinstall | |
sudo apt install -y ca-certificates curl gnupg lsb-release software-properties-common | |
# --- Add APT Repositories --- | |
print_header "Adding third-party APT repositories" | |
# DBeaver | |
add_apt_repository_and_key \ | |
"https://dbeaver.io/debs/dbeaver.gpg.key" \ | |
"/usr/share/keyrings/dbeaver.gpg" \ | |
"deb [signed-by=/usr/share/keyrings/dbeaver.gpg] https://dbeaver.io/debs/dbeaver-ce /" \ | |
"dbeaver" | |
# Anydesk | |
add_apt_repository_and_key \ | |
"https://keys.anydesk.com/repos/DEB-GPG-KEY" \ | |
"/usr/share/keyrings/anydesk.gpg" \ | |
"deb [signed-by=/usr/share/keyrings/anydesk.gpg] http://deb.anydesk.com/ all main" \ | |
"anydesk-stable" | |
# Signal Desktop | |
add_apt_repository_and_key \ | |
"https://updates.signal.org/desktop/apt/keys.asc" \ | |
"/usr/share/keyrings/signal-desktop-keyring.gpg" \ | |
"deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main" \ | |
"signal-xenial" | |
# Albert | |
add_apt_repository_and_key \ | |
"https://download.opensuse.org/repositories/home:manuelschneid3r/xUbuntu_$(lsb_release -rs)/Release.key" \ | |
"/usr/share/keyrings/home_manuelschneid3r.gpg" \ | |
"deb [signed-by=/usr/share/keyrings/home_manuelschneid3r.gpg] http://download.opensuse.org/repositories/home:/manuelschneid3r/xUbuntu_$(lsb_release -rs)/ /" \ | |
"home:manuelschneid3r" | |
# Clean up old VSCode repository configurations | |
print_header "Cleaning up old VSCode configurations" | |
sudo rm -f /etc/apt/sources.list.d/vscode.list* | |
sudo rm -f /usr/share/keyrings/microsoft.gpg | |
# VSCode | |
add_apt_repository_and_key \ | |
"https://packages.microsoft.com/keys/microsoft.asc" \ | |
"/usr/share/keyrings/packages.microsoft.gpg" \ | |
"deb [arch=amd64,arm64,armhf signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" \ | |
"vscode" | |
# Docker | |
add_apt_repository_and_key \ | |
"https://download.docker.com/linux/ubuntu/gpg" \ | |
"/usr/share/keyrings/docker-archive-keyring.gpg" \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \ | |
"docker" | |
# --- Add PPAs --- | |
print_header "Adding PPAs" | |
sudo add-apt-repository -y ppa:obsproject/obs-studio | |
sudo add-apt-repository -y ppa:qbittorrent-team/qbittorrent-stable | |
# --- Install .deb packages from URLs --- | |
install_deb_from_url "Discord" "https://discordapp.com/api/download?platform=linux&format=deb" "discord" | |
install_deb_from_url "Zoom" "https://zoom.us/client/latest/zoom_amd64.deb" "zoom" | |
install_deb_from_url "Mailspring" "https://updates.getmailspring.com/download?platform=linuxDeb" "mailspring" | |
install_deb_from_url "Teamviewer" "https://download.teamviewer.com/download/linux/teamviewer-host_amd64.deb" "teamviewer-host" | |
# --- Install APT Packages --- | |
print_header "Installing APT packages" | |
sudo apt update | |
sudo apt install -y \ | |
nvidia-cuda-toolkit nvidia-cudnn dconf-editor build-essential apt-utils git nano vim lsof locate net-tools \ | |
libssl-dev curl unzip unrar cmake openjdk-11-jdk openjdk-11-jre jq \ | |
redis tlp apt-transport-https mysql-client dbeaver-ce anydesk libssl-dev \ | |
zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libgdbm-dev \ | |
libdb5.3-dev flatpak gnome-software-plugin-flatpak libbz2-dev libexpat1-dev liblzma-dev tk-dev \ | |
libffi-dev bleachbit stacer timeshift gimp zsh signal-desktop ffmpeg \ | |
chromium-codecs-ffmpeg-extra tmux vlc python3-pip python3-dev \ | |
psensor htop gnome-tweak-tool gparted albert terminator code \ | |
tree obs-studio docker-ce docker-ce-cli containerd.io rclone spice-vdagent \ | |
tor neofetch qbittorrent virtualbox virtualbox-ext-pack | |
snap install bluemail | |
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo | |
flatpak install com.bitwarden.desktop | |
# --- Install Other Tools --- | |
print_header "Installing Speedtest CLI" | |
if command -v speedtest &> /dev/null; then | |
echo "Speedtest CLI is already installed. Skipping." | |
else | |
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash | |
sudo apt install -y speedtest | |
fi | |
print_header "Installing Postman" | |
if snap list | grep -q "postman"; then | |
echo "Postman is already installed. Skipping." | |
else | |
sudo snap install postman | |
fi | |
# --- System and Shell Configuration --- | |
print_header "Configuring system settings" | |
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false | |
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM | |
gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode FIXED | |
gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 24 | |
gsettings set org.gnome.shell.extensions.dash-to-dock unity-backlit-items true | |
gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize' | |
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true | |
gsettings set com.canonical.indicator.power show-percentage true | |
gsettings set org.gnome.nautilus.list-view default-zoom-level 'smaller' | |
gsettings set org.gtk.Settings.FileChooser show-hidden true | |
print_header "Configuring shell environment" | |
SHELL_CONFIGS=("$HOME/.zshrc" "$HOME/.bashrc") | |
for config in "${SHELL_CONFIGS[@]}"; do | |
{ | |
echo '' | |
echo '# --- Custom Environment ---' | |
echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' | |
echo 'export PATH=$PATH:$JAVA_HOME/bin' | |
echo 'alias python=python3' | |
echo 'alias pip=pip3' | |
} >> "$config" | |
done | |
# --- SSH Key Generation --- | |
print_header "Generating SSH key" | |
if [ ! -f "$HOME/.ssh/id_rsa" ]; then | |
mkdir -p "$HOME/.ssh" | |
chmod 700 "$HOME/.ssh" | |
ssh-keygen -t rsa -b 4096 -C "$(whoami)@$(hostname)" -N "" -f "$HOME/.ssh/id_rsa" | |
print_header "SSH key generated. Please add the public key to your services (GitHub, GitLab, etc.)" | |
cat "$HOME/.ssh/id_rsa.pub" | |
else | |
echo "SSH key already exists. Skipping generation." | |
fi | |
# --- Final Steps --- | |
print_header "Disabling services on startup" | |
sudo systemctl disable mysql anydesk.service redis postgresql.service docker.service docker.socket || true | |
sudo teamviewer --daemon disable || true | |
print_header "Cleaning up" | |
sudo apt autoclean -y && sudo apt autoremove -y | |
print_header "Installing Oh My Zsh" | |
if [ ! -d "$HOME/.oh-my-zsh" ]; then | |
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
fi | |
print_header "Setting Zsh as default shell" | |
if [ "$SHELL" != "$(which zsh)" ]; then | |
sudo chsh -s "$(which zsh)" "$USER" | |
echo "Zsh is now the default shell. Please log out and log back in for the change to take effect." | |
else | |
echo "Zsh is already the default shell." | |
fi | |
print_header "Script finished successfully!" | |
echo "Please restart your terminal or run 'source ~/.bashrc' or 'source ~/.zshrc' for changes to take effect." | |
echo "You may also want to restart your system." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment