Skip to content

Instantly share code, notes, and snippets.

@adithya2306
Last active June 5, 2025 17:20
Show Gist options
  • Save adithya2306/005dc8a57b246316cae7bea2cb7f16aa to your computer and use it in GitHub Desktop.
Save adithya2306/005dc8a57b246316cae7bea2cb7f16aa to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Script to set up an Ubuntu 22.04+ server
# (with minimum 16GB RAM, 8 threads CPU) for android platform, linux builds and more
#
# Sudo access is mandatory to run this script.
# Recommended to apply personal dotfiles afterwards.
#
# Usage:
# ./ubuntu-setup.sh
#
SWITCH_TO_ZSH=true
APKTOOL_URL="https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.11.1.jar"
JADX_URL="https://github.com/skylot/jadx/releases/download/v1.5.1/jadx-1.5.1.zip"
KTFMT_URL="https://github.com/facebook/ktfmt/releases/download/v0.55/ktfmt-0.55-with-dependencies.jar"
APT="sudo DEBIAN_FRONTEND=noninteractive apt-get -qq -y"
# Go to home dir
orig_dir=$(pwd)
cd $HOME
######################################
# APT packages
######################################
echo -e "Installing and upgrading APT packages...\n"
$APT update > /dev/null
$APT install apt-utils > /dev/null
$APT full-upgrade > /dev/null
# From LineageOS wiki + additional (after z)
PACKAGES="bc bison build-essential ccache curl flex g++-multilib gcc-multilib git git-lfs gnupg \
gperf imagemagick protobuf-compiler python3-protobuf lib32readline-dev lib32z1-dev libdw-dev \
libelf-dev lz4 libsdl1.2-dev libssl-dev libxml2 libxml2-utils lzop pngcrush rsync schedtool \
squashfs-tools xsltproc zip zlib1g-dev \
clang clang-format htop tmux wget aria2 unzip p7zip-full cpio brotli nano vim less file \
python3 python3-pip python3-venv python-is-python3 pipx default-jdk dos2unix ripgrep rclone \
rsync apksigner neofetch patchelf netcat-openbsd device-tree-compiler"
install_failed=""
for p in $PACKAGES; do
echo "Installing $p..."
$APT install $p > /dev/null || {
echo "Failed."
install_failed="$install_failed $p"
}
done
echo "Installing libtinfo5..."
aria2c -q https://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2_amd64.deb && \
(
sudo dpkg -i libtinfo5_6.3-2_amd64.deb > /dev/null
rm libtinfo5_6.3-2_amd64.deb
) || echo "Failed."
echo "Installing libncurses5..."
aria2c -q https://archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libncurses5_6.3-2_amd64.deb && \
(
sudo dpkg -i libncurses5_6.3-2_amd64.deb > /dev/null
rm libncurses5_6.3-2_amd64.deb
) || echo "Failed."
$APT autoremove > /dev/null
$APT purge snapd > /dev/null
echo -e "\nDone."
[ -z "$install_failed" ] || echo -e "Following packages FAILED to install:\n$install_failed"
######################################
# External packages
######################################
echo -e "\nInstalling external packages...\n"
echo "Installing git-repo..."
aria2c -q https://storage.googleapis.com/git-repo-downloads/repo && \
(
chmod a+x repo
sudo install repo /usr/local/bin/repo
rm repo
) || echo "Failed."
echo "Installing Android SDK platform tools..."
aria2c -q https://dl.google.com/android/repository/platform-tools-latest-linux.zip && \
(
unzip -qq platform-tools-latest-linux.zip
rm platform-tools-latest-linux.zip
) || echo "Failed."
# echo "Installing Google Drive CLI..."
# wget -q https://raw.githubusercontent.com/usmanmughalji/gdriveupload/master/gdrive
# chmod a+x gdrive
# sudo install gdrive /usr/local/bin/gdrive
# rm gdrive
echo "Installing apktool..."
mkdir -p bin
aria2c -q -o bin/apktool.jar $APKTOOL_URL || echo "Failed."
echo "Installing jadx..."
aria2c -q -o jadx.zip $JADX_URL && \
(
unzip -qq jadx.zip -d jadx
rm jadx.zip
) || echo "Failed."
echo "Installing ktfmt..."
aria2c -q -o bin/ktfmt.jar $KTFMT_URL || echo "Failed."
echo -e "\nDone."
######################################
# Switch to ZSH
######################################
$SWITCH_TO_ZSH && {
echo -e "\nInstalling zsh..."
$APT install zsh > /dev/null
echo "Installing omz..."
export RUNZSH=no # don’t start zsh automatically after install
export CHSH=no # don’t change default shell immediately
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "Changing default shell to zsh..."
sudo usermod --shell /usr/bin/zsh $USER
echo -e "\nDone."
}
######################################
# End
######################################
# Increase maximum ccache size
ccache -M 50G
# Create ssh key
echo -e "\nCreating a new ssh key pair..."
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N "" -C "$(whoami)@$(hostname)"
echo -e "\nAll tasks completed.\nPlease relogin for environment changes to take effect."
# Go back to original dir
cd "$orig_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment