Fast Ubuntu APT mirror selector and network optimizer.
Power APT Boost tests multiple Ubuntu mirrors, selects the fastest working mirror for your server, rewrites APT sources safely, applies network optimizations, and runs apt-get update.
curl -fsSL https://raw.githubusercontent.com/power0matin/power-apt-boost/main/power-apt-boost.sh | sudo bashOr test first without changes:
sudo bash power-apt-boost.sh --dry-run- Auto-detects Ubuntu codename
- Tests 20+ global Ubuntu mirrors
- Selects the fastest working mirror
- Automatic rollback on failure
- Backs up APT configuration before changes
- Writes modern deb822-format APT sources
- Configures APT network optimizations
- Machine-readable JSON output for CI/CD
- Country-based mirror filtering
- IPv6 mirror testing support
- Persistent logging to file
- Safe
Ctrl+Cinterruption - Comprehensive test suite
curl -fsSL https://raw.githubusercontent.com/power0matin/power-apt-boost/main/power-apt-boost.sh | sudo bashgit clone https://github.com/power0matin/power-apt-boost.git
cd power-apt-boost
sudo bash power-apt-boost.shcurl -fsSL https://raw.githubusercontent.com/power0matin/power-apt-boost/main/power-apt-boost.sh | less
# Review the script, then:
curl -fsSL https://raw.githubusercontent.com/power0matin/power-apt-boost/main/power-apt-boost.sh | sudo bashsudo bash power-apt-boost.shsudo bash power-apt-boost.sh --dry-runsudo bash power-apt-boost.sh --mirror https://mirror.example.com/ubuntusudo bash power-apt-boost.sh --restoresudo bash power-apt-boost.sh --listsudo bash power-apt-boost.sh --json --quietsudo bash power-apt-boost.sh --country ussudo bash power-apt-boost.sh --verbose| Option | Description |
|---|---|
-h, --help |
Show help message |
-v, --version |
Show version |
-m, --mirror URL |
Use a specific mirror |
-r, --restore |
Restore APT config from latest backup |
--restore-path PATH |
Restore from a specific backup |
--dry-run |
Test mirrors without changing config |
--skip-update |
Write config but skip apt-get update |
--list |
List available mirrors and test them |
--json |
Output as JSON (sets --quiet --no-spinner) |
--verbose |
Show detailed output |
--quiet |
Suppress non-essential output |
--no-spinner |
Disable spinner (for CI/CD) |
--timeout SECS |
Probe timeout in seconds (default: 20) |
--country CODE |
Filter mirrors by country code |
--ipv6 |
Use IPv6 for mirror testing |
--log-file PATH |
Write log to file |
- Detects Ubuntu version codename
- Tests multiple Ubuntu mirrors for reachability and speed
- Selects the fastest working mirror
- Backs up current APT configuration to
/var/backups/power-apt-boost/ - Writes modern deb822-format APT sources to
/etc/apt/sources.list.d/ubuntu.sources - Configures APT network optimizations (IPv4, retries, timeouts)
- Cleans stale package lists
- Runs
apt-get update
| File | Action |
|---|---|
/etc/apt/sources.list.d/ubuntu.sources |
Created/overwritten |
/etc/apt/apt.conf.d/99-power-apt-boost |
Created/overwritten |
/etc/apt/sources.list |
Removed (if no third-party repos) |
/var/lib/apt/lists/* |
Cleaned |
Backups are created at:
/var/backups/power-apt-boost/YYYY-MM-DD_HH-MM-SS/
Each backup contains copies of:
ubuntu.sources(deb822 format)sources.list(legacy format)sources.list.d/apt.conf.d/
sudo bash power-apt-boost.sh --restoresudo bash power-apt-boost.sh --restore-path /var/backups/power-apt-boost/2025-01-01_12-00-00# List available backups
ls -la /var/backups/power-apt-boost/
# Restore manually
sudo cp -a /var/backups/power-apt-boost/BACKUP/sources.list.d /etc/apt/
sudo cp -a /var/backups/power-apt-boost/BACKUP/apt.conf.d /etc/apt/
sudo rm -f /etc/apt/sources.list.d/ubuntu.sources
sudo apt-get update- Package installation behavior
- System security settings
- Network configuration
- Firewall rules
- Any files outside
/etc/apt/
Power APT Boost tests each mirror against three endpoints:
/dists/<codename>/InRelease
/dists/<codename>-updates/InRelease
/dists/<codename>-security/InRelease
Only mirrors that return HTTP 200 for all three are considered. The fastest mirror (lowest combined response time) is selected.
Iranian mirrors are tested first for geographic optimization, then international mirrors as fallback.
| Region | Mirrors |
|---|---|
| Iran | ir.archive.ubuntu.com, mirror.arvancloud.ir, mirror.iranserver.com, ubuntu.hostiran.ir, mirror.hostbaran.com, mirror.aminidc.com, archive.ito.gov.ir, archive.ubuntu.petiak.ir, mirror.mobinhost.com, linuxmirrors.ir, mirror.kubarcloud.com |
| Global | archive.ubuntu.com, mirrors.kernel.org |
| US | us.archive.ubuntu.com, mirror.math.princeton.edu, mirror.cs.uchicago.edu, mirror.csclub.uwaterloo.ca, mirror.rit.edu, mirror.arizona.edu |
| UK | uk.archive.ubuntu.com |
| Europe | de.archive.ubuntu.com, fr.archive.ubuntu.com, it.archive.ubuntu.com, nl.archive.ubuntu.com |
| Asia-Pacific | au.archive.ubuntu.com, jp.archive.ubuntu.com, kr.archive.ubuntu.com, in.archive.ubuntu.com |
| Americas | br.archive.ubuntu.com |
Power APT Boost includes a dedicated Iranian mirror pool for users located in Iran. These mirrors are tested first for geographic optimization — reducing benchmark time for Iranian users.
Iranian mirrors included in the default pool:
| Mirror | URL |
|---|---|
| Ubuntu Iran Archive | https://ir.archive.ubuntu.com/ubuntu |
| ArvanCloud | https://mirror.arvancloud.ir/ubuntu |
| IranServer | https://mirror.iranserver.com/ubuntu |
| HostIran | https://ubuntu.hostiran.ir/ubuntu |
| HostBaran | https://mirror.hostbaran.com/ubuntu |
| AminiDC | https://mirror.aminidc.com/ubuntu |
| ITO | https://archive.ito.gov.ir/ubuntu |
| Petiak | https://archive.ubuntu.petiak.ir/ubuntu |
| MobinHost | https://mirror.mobinhost.com/ubuntu |
| LinuxMirrors | https://linuxmirrors.ir/ubuntu |
| KubarCloud | https://mirror.kubarcloud.com/ubuntu |
To filter mirrors by Iran specifically:
sudo bash power-apt-boost.sh --country irTo use a specific Iranian mirror:
sudo bash power-apt-boost.sh --mirror https://mirror.arvancloud.ir/ubuntu| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Usage error (invalid arguments) |
| 3 | Network error |
| 4 | Not running as root |
| 5 | Not Ubuntu |
| 6 | No working mirror found |
| 7 | Backup failed |
| 8 | Restore failed |
sudo bash power-apt-boost.shapt-get install -y curl- Check your network connection
- Try with a longer timeout:
--timeout 60 - Try a specific mirror:
--mirror https://archive.ubuntu.com/ubuntu
The script automatically restores the previous configuration. To restore manually:
sudo bash power-apt-boost.sh --restoreIf you have third-party APT sources in /etc/apt/sources.list, Power APT Boost preserves them and only removes the file if it contains only Ubuntu sources.
| Ubuntu Version | Status |
|---|---|
| 24.04 LTS Noble | Tested |
| 22.04 LTS Jammy | Tested |
| 20.04 LTS Focal | Tested |
Requires Bash 4.0+ and one of: curl, wget.
- See SECURITY.md for reporting vulnerabilities
- Review the script before running from a URL
- Use
--dry-runto preview changes - All changes are backed up automatically
See CONTRIBUTING.md for guidelines.
# Development setup
git clone https://github.com/power0matin/power-apt-boost.git
cd power-apt-boost
chmod +x power-apt-boost.sh
# Lint
shellcheck -x power-apt-boost.sh
shfmt -d power-apt-boost.sh
# Test
bash tests/run_tests.shSee ROADMAP.md for planned features.
Matin Shahabadi — @power0matin