-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
function list_installed_packages() | ||
{ | ||
apt list --installed "$1" 2>/dev/null | awk -F'/' 'NR>1{print $1}' | tr '\n' ' ' | ||
} | ||
|
||
function free_up_disk_space_ubuntu() | ||
{ | ||
local packages=( | ||
'azure-cli' | ||
'aspnetcore-*' | ||
'dotnet-*' | ||
'firefox*' | ||
'google-chrome-*' | ||
'google-cloud-*' | ||
'libmono-*' | ||
'llvm-*' | ||
'imagemagick' | ||
'postgresql-*' | ||
'rubu-*' | ||
'spinxsearch' | ||
'unixodbc-dev' | ||
'mercurial' | ||
'esl-erlang' | ||
'microsoft-edge-stable' | ||
'mono-*' | ||
'msbuild' | ||
'mysql-server-core-*' | ||
'php-*' | ||
'php7*' | ||
'powershell*' | ||
'mongo*' | ||
'microsoft-edge*' | ||
'subversion') | ||
|
||
for package in "${packages[@]}"; do | ||
installed_packages=$(list_installed_packages "${package}") | ||
echo "Removing packages by pattern ${package}: ${installed_packages}" | ||
sudo apt-get --auto-remove -y purge ${installed_packages} | ||
done | ||
|
||
echo "Autoremoving packages" | ||
sudo apt-get autoremove -y | ||
|
||
echo "Autocleaning" | ||
sudo apt-get autoclean -y | ||
|
||
echo "Removing toolchains" | ||
sudo rm -rf \ | ||
/usr/local/graalvm \ | ||
/usr/local/lib/android/ \ | ||
/usr/share/dotnet/ \ | ||
/opt/ghc/ \ | ||
/usr/local/share/boost/ \ | ||
"${AGENT_TOOLSDIRECTORY}" | ||
|
||
echo "Prune docker images" | ||
sudo docker system prune --all -f | ||
} | ||
|
||
echo "Disk space usage before cleaning:" | ||
df -k . | ||
|
||
echo "Clearing up disk usage:" | ||
free_up_disk_space_ubuntu | ||
|
||
echo "Disk space usage after cleaning:" | ||
df -k . |
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