Last active
June 21, 2024 22:55
-
-
Save feliperdamaceno/c668a2f7494b6f91c933ae64403335cc to your computer and use it in GitHub Desktop.
Script for post-install setup on Pop!_OS (^22.04 LTS).
This file contains 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
#!/usr/bin/env bash | |
# | |
# Script used to setup Pop!_OS (^22.04 LTS) | |
# | |
# ------------------------------------------------------------------------------- # | |
# ---------------------------------- VARIABLES ---------------------------------- # | |
## Shell Colors | |
RED_COLOR='\e[1;91m' | |
GREEN_COLOR='\e[1;92m' | |
NO_COLOR='\e[0m' | |
## Workdir | |
DOWNLOADS_DIR="$HOME/Downloads/temp" | |
BOOKMARKS_DIR="$HOME/.config/gtk-3.0/bookmarks" | |
## Packages | |
DEB_PACKAGES=( | |
"https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" | |
) | |
APT_PACKAGES=( | |
solaar | |
gparted | |
gufw | |
vlc | |
code | |
gnome-sushi | |
folder-color | |
git | |
ubuntu-restricted-extras | |
build-essential | |
xdotool | |
) | |
FLATPACK_PACKAGES=( | |
com.valvesoftware.Steam | |
com.github.tchx84.Flatseal | |
org.qbittorrent.qBittorrent | |
com.stremio.Stremio | |
org.flameshot.Flameshot | |
com.getpostman.Postman | |
com.spotify.Client | |
it.mijorus.smile # Remember to add keyboar shortcut "ctrl + ." | |
) | |
# ------------------------------------------------------------------------------- # | |
# ---------------------------------- FUNCTIONS ---------------------------------- # | |
test_internet_connection() { | |
if ! ping -c 1 8.8.8.8 -q &>/dev/null; then | |
echo -e "${RED_COLOR}[ERROR] - Your machine has no internet connection.${NO_COLOR}" | |
exit 1 | |
else | |
echo -e "${GREEN_COLOR}[INFO] - Internet connection working successfully.${NO_COLOR}" | |
fi | |
} | |
# | |
# Used to update system, repositories and Flatpak before installing packages. | |
# | |
update_system() { | |
echo "${GREEN_COLOR}[INFO] - Updating package list and performing distribution upgrade...${NO_COLOR}" | |
sudo apt update | |
sudo apt dist-upgrade -y | |
sudo apt upgrade -y | |
flatpak update -y | |
echo "${GREEN_COLOR}[INFO] - System update complete.${NO_COLOR}" | |
} | |
# | |
# Remove lock files used by the APT. These lock files are used to prevent multiple | |
# instances of package management tools from running simultaneously, which can cause | |
# conflicts and corruption of package data. | |
# | |
remove_apt_lock_files() { | |
sudo rm /var/lib/dpkg/lock-frontend | |
sudo rm /var/cache/apt/archives/lock | |
} | |
# | |
# Add support for i386 architecture on a Debian-based system. | |
# Necessary for installing and running 32-bit apps and libraries on a 64-bit system. | |
# | |
add_archi386_support() { | |
sudo dpkg --add-architecture i386 | |
} | |
# | |
# Download and install all external deb packages. | |
# | |
install_deb_packages() { | |
mkdir "$DOWNLOADS_DIR" | |
echo -e "${GREEN_COLOR}[INFO] - Downloading .deb packages...${NO_COLOR}" | |
for source in "${DEV_PACKAGES[@]}"; do | |
wget -c "$source" -P "$DOWNLOADS_DIR" | |
done | |
echo -e "${GREEN_COLOR}[INFO] - Installing .deb packages...${NO_COLOR}" | |
sudo dpkg -i $DOWNLOADS_DIR/*.deb | |
echo "${GREEN_COLOR}[INFO] - .dev packages installation complete.${NO_COLOR}" | |
rm -rf "$DOWNLOADS_DIR" | |
} | |
# | |
# Download and install apt packages. | |
# | |
install_apt_packages() { | |
echo -e "${GREEN_COLOR}[INFO] - Installing apt packages...${NO_COLOR}" | |
for package in ${APT_PACKAGES[@]}; do | |
if ! dpkg-query -W "$package" &>/dev/null; then | |
echo "Installing $package..." | |
sudo apt install "$package" -y | |
else | |
echo "$package is already installed." | |
fi | |
done | |
echo "${GREEN_COLOR}[INFO] - APT packages installation complete.${NO_COLOR}" | |
} | |
# | |
# Download and install flatpak packages. | |
# | |
install_flatpak_packages() { | |
echo -e "${GREEN_COLOR}[INFO] - Installing Flatpak packages...${NO_COLOR}" | |
for package in "${FLATPAK_PACKAGES[@]}"; do | |
echo "Installing $package..." | |
flatpak install flathub "$package" -y | |
done | |
} | |
# | |
# Create bookmarks in nautilus for productivity. | |
# | |
create_nautilus_bookmarks() { | |
mkdir $HOME/local | |
mkdir $HOME/remote | |
mkdir $HOME/screenshots | |
if [[ ! -f "$BOOKMARKS_DIR" ]]; then | |
echo "$BOOKMARKS_DIR not found, creating now..." | |
touch "$BOOKMARKS_DIR" | |
fi | |
echo "file:///$HOME/local local" >>$BOOKMARKS_DIR | |
echo "file:///$HOME/remote remote" >>$BOOKMARKS_DIR | |
echo "file:///$HOME/screenshots screenshots" >>$BOOKMARKS_DIR | |
echo "${GREEN_COLOR}[INFO] - Nautilus bookmarks created successfully.${NO_COLOR}" | |
} | |
# | |
# Used to cleanup system and cleaning up unnecessary files. | |
# | |
system_cleanup() { | |
echo "${GREEN_COLOR}[INFO] - Performing system cleanup...${NO_COLOR}" | |
sudo apt autoclean && sudo apt autoremove -y | |
nautilus -q | |
} | |
# ------------------------------------------------------------------------------- # | |
# ---------------------------------- EXECUTION ---------------------------------- # | |
main() { | |
set -e | |
remove_apt_lock_files | |
test_internet_connection | |
update_system | |
add_archi386_support | |
update_system | |
install_deb_packages | |
install_apt_packages | |
install_flatpak_packages | |
create_nautilus_bookmarks | |
system_cleanup | |
echo -e "${GREEN_COLOR}[INFO] - Script completed successfully!${NO_COLOR}" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment