This repository contains scripts to automate the setup and configuration of Ubuntu servers with enhanced system monitoring, optimized swap memory, and Docker installation.
- System monitoring tools installation
- Configurable swap memory setup (200GB)
- Docker installation and configuration
- Container cleanup utilities
- Android emulator cluster setup
- Ubuntu Server (18.04 LTS or newer)
- Root or sudo privileges
- Internet connection for package downloads
# Update package index
sudo apt-get update
# Install monitoring utilities
sudo apt install htop nmon glances nethogs iftop# Check current swap configuration
sudo swapon --show
# Turn off any existing swap
sudo swapoff -a
# Create a 100GB swap file
sudo fallocate -l 100G /swapfile
# Alternative if fallocate doesn't work:
# sudo dd if=/dev/zero of=/swapfile bs=1G count=100
# Set correct permissions
sudo chmod 600 /swapfile
# Format as swap
sudo mkswap /swapfile
# Enable the swap
sudo swapon /swapfile
# Make it permanent (add to fstab)
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab# Install dependencies
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
# Set up the stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
# Update package index again
sudo apt-get update
# Install Docker CE
sudo apt-get install -y docker-ce docker-ce-cli containerd.io
# Start and enable Docker
sudo systemctl start docker
sudo systemctl enable docker
# Verify installation
sudo docker run hello-world# Remove all containers
docker stop $(docker ps -q)
docker rm $(docker ps -a -q)Clone the Android Emulator Cluster repository:
cd /opt
git clone https://github.com/ZeeshanAdilButt/android-emulator-cluster-in-docker.git
cd /opt/android-emulator-cluster-in-dockerSet execute permissions for all script files:
# Docker files
cd /opt/android-emulator-cluster-in-docker/docker-files
chmod +x dockerfile
chmod +x run.sh
# Main scripts
cd /opt/android-emulator-cluster-in-docker
chmod +x startup.sh
chmod +x soft-restart.sh
# Danger zone scripts
mkdir -p /opt/android-emulator-cluster-in-docker/danger
cd /opt/android-emulator-cluster-in-docker/danger
chmod +x cleanup.sh
chmod +x restart.sh
cd ..
cd .. The script installs the following monitoring utilities:
- htop: Interactive process viewer
- nmon: Performance monitoring tool
- glances: System monitoring tool with web interface
- nethogs: Net top tool grouping bandwidth per process
- iftop: Display bandwidth usage on an interface
After completing all the setup steps above, you can build and run the Android emulator cluster:
cd /opt/android-emulator-cluster-in-docker/docker-files
docker build -t zee-docker-android-persist .cd /opt/android-emulator-cluster-in-docker
./startup.sh {number of devices}When you need to restart containers without removing them:
cd /opt/android-emulator-cluster-in-docker
./soft-restart.sh {container ids failing on emulator } - happens when the resources are not shared equally
# soft restart devices only if needed
./soft-restart.sh 8,26,31,29,27,20,21To remove containers and perform cleanup:
cd /opt/android-emulator-cluster-in-docker/danger
./cleanup.sh {container ids failing on emulator }To perform a complete reset and fresh restart of all containers:
cd /opt/android-emulator-cluster-in-docker/danger
./restart.sh {container ids failing on emulator }
# recreate devices
./cleanup.sh 8,26,31,29,27,20,21
./restart.sh 8,26,31,29,27,20,21docker psapt install adb
apt install google-android-platform-tools-installer
clear
for i in {5555..5594}; do adb connect localhost:$i; done
adb devicesdocker logs [container_id]docker exec -it [container_id] /bin/bashdocker psdocker logs [container_id]docker exec -it [container_id] /bin/bashContributions are welcome! Please feel free to submit a Pull Request.