2020-12-24 17:44:17 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
if [[ $OSTYPE != "linux-gnu" ]]; then
|
|
|
|
printf "This Cleanup Script Should Be Run On Ubuntu Runner.\n"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-01-02 18:59:32 +01:00
|
|
|
# Make Sure The Environment Is Non-Interactive
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
# Prepare
|
|
|
|
while ((${SECONDS_LEFT:=5} > 0)); do
|
2021-03-01 20:13:13 +01:00
|
|
|
printf "Please wait %ss ...\n" "${SECONDS_LEFT}"
|
|
|
|
sleep 1
|
|
|
|
SECONDS_LEFT=$((SECONDS_LEFT - 1))
|
2021-02-14 16:42:31 +01:00
|
|
|
done
|
|
|
|
unset SECONDS_LEFT
|
|
|
|
|
|
|
|
echo "::group::Disk Space Before Cleanup"
|
2021-03-21 21:38:37 +01:00
|
|
|
df -hlT /
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2021-01-02 18:59:32 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Clearing Docker Image Caches"
|
2021-01-30 12:57:46 +01:00
|
|
|
docker rmi -f $(docker images -q) &>/dev/null
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2020-12-24 17:44:17 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Uninstalling Unnecessary Applications"
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo -EH apt-get -qq -y update &>/dev/null
|
|
|
|
REL=$(grep "UBUNTU_CODENAME" /etc/os-release | cut -d'=' -f2)
|
|
|
|
if [[ ${REL} == "focal" ]]; then
|
2021-03-25 12:55:36 +01:00
|
|
|
APT_Pac4Purge="alsa-topology-conf alsa-ucm-conf python2 python2-minimal libpython-dev clang-9 clang-format-9 llvm-10-dev llvm-10-runtime llvm-10-tools llvm-10 lld-10 lld-9 libllvm10 libllvm9 libclang-common-10-dev libclang-cpp10 libclang1-10 clang-10 clang-format-10"
|
2021-03-01 20:13:13 +01:00
|
|
|
elif [[ ${REL} == "bionic" ]]; then
|
2021-03-25 12:55:36 +01:00
|
|
|
APT_Pac4Purge="clang-6.0 clang-format-6.0 libclang-common-6.0-dev libclang1-6.0 liblldb-6.0 libllvm6.0 llvm-6.0-dev lld-6.0"
|
2021-03-01 20:13:13 +01:00
|
|
|
fi
|
|
|
|
unset REL
|
|
|
|
sudo -EH apt-get -qq -y purge \
|
|
|
|
${APT_Pac4Purge} \
|
2021-03-21 21:38:37 +01:00
|
|
|
adoptopenjdk-* openjdk* ant* \
|
2021-03-01 20:13:13 +01:00
|
|
|
*-icon-theme plymouth *-theme* fonts-* gsfonts gtk-update-icon-cache \
|
2021-03-25 12:55:36 +01:00
|
|
|
google-cloud-sdk heroku \
|
2021-03-01 20:13:13 +01:00
|
|
|
apache2* nginx msodbcsql* mssql-tools mysql* libmysqlclient* unixodbc-dev postgresql* libpq-dev odbcinst* mongodb-* sphinxsearch \
|
|
|
|
apport* popularity-contest \
|
|
|
|
aspnetcore-* dotnet* \
|
|
|
|
azure-cli session-manager-plugin \
|
2021-01-02 18:59:32 +01:00
|
|
|
bazel* \
|
2021-03-01 20:13:13 +01:00
|
|
|
brltty byobu htop \
|
|
|
|
buildah hhvm kubectl packagekit* podman podman-plugins skopeo \
|
|
|
|
chromium-browser firebird* firefox google-chrome* xvfb \
|
2021-03-25 12:55:36 +01:00
|
|
|
clang-8 clang-format-8 libclang-common-8-dev libclang1-8 cpp-7 cpp-8 lld-8 llvm-8* libllvm8 liblldb-8 \
|
2021-03-01 20:13:13 +01:00
|
|
|
esl-erlang ghc-* groff-base rake r-base* r-cran-* r-recommended ruby* swig* \
|
|
|
|
g++-7* gcc-7* g++-8* gcc-8* gfortran* \
|
|
|
|
gh subversion mercurial mercurial-common \
|
|
|
|
info install-info landscape-common \
|
2021-03-25 12:55:36 +01:00
|
|
|
libpython2* imagemagick* libmagic* vim vim-* \
|
2021-02-14 16:42:31 +01:00
|
|
|
man-db manpages \
|
2021-03-01 20:13:13 +01:00
|
|
|
mono-* mono* libmono-* \
|
|
|
|
nuget packages-microsoft-prod snapd yarn \
|
2021-02-14 16:42:31 +01:00
|
|
|
php-* php5* php7* php8* snmp \
|
2021-03-01 20:13:13 +01:00
|
|
|
&>/dev/null
|
|
|
|
sudo -EH apt-get -qq -y autoremove &>/dev/null
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2021-01-02 18:59:32 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Removing Homebrew Completely"
|
2021-01-30 12:57:46 +01:00
|
|
|
curl -sL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh -o uninstall-brew.sh && chmod a+x uninstall-brew.sh
|
2021-03-22 13:25:06 +01:00
|
|
|
./uninstall-brew.sh -f -q &>/dev/null
|
|
|
|
sudo rm -rf -- ./uninstall-brew.sh /home/linuxbrew &>/dev/null
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2021-01-02 18:59:32 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Removing NodeJS, NPM & NPX"
|
|
|
|
{
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo npm list -g --depth=0. 2>/dev/null | awk -F ' ' '{print $2}' | awk -F '@[0-9]' '{print $1}' | grep -v "^n$" | sudo xargs npm remove -g
|
2021-02-14 16:42:31 +01:00
|
|
|
yes | sudo n uninstall
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo rm -rf -- /usr/local/lib/node_modules /usr/local/n /usr/local/bin/n \
|
2021-02-14 16:42:31 +01:00
|
|
|
/usr/local/bin/vercel /usr/local/bin/now
|
2021-03-22 13:25:06 +01:00
|
|
|
} &>/dev/null
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2021-01-04 01:07:01 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Purging PIPX & PIP packages"
|
|
|
|
{
|
2021-03-01 20:13:13 +01:00
|
|
|
pipx uninstall-all && sudo pip3 uninstall -q -y pipx
|
2021-02-14 16:42:31 +01:00
|
|
|
find /usr/share /usr/lib ~/.local/lib -depth -type d -name __pycache__ \
|
|
|
|
-exec rm -rf '{}' + 2>/dev/null;
|
2021-03-22 13:25:06 +01:00
|
|
|
} &>/dev/null
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2021-01-03 20:36:57 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Removing Lots of Cached Programs & Unneeded Folders"
|
|
|
|
{
|
|
|
|
printf "Removing Runner Tool Cache...\n"
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo rm -rf -- /opt/hostedtoolcache
|
2021-02-14 16:42:31 +01:00
|
|
|
printf "Removing Android SDK, NDK, Platform Tools, Gradle, Maven...\n"
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo rm -rf -- /usr/local/lib/android \
|
|
|
|
/usr/share/gradle* /usr/bin/gradle /usr/share/apache-maven* /usr/bin/mvn
|
2021-02-14 16:42:31 +01:00
|
|
|
printf "Removing Microsoft vcpkg, Miniconda, Leiningen, Pulumi...\n"
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo rm -rf -- /usr/local/share/vcpkg /usr/local/bin/vcpkg \
|
|
|
|
/usr/share/miniconda /usr/bin/conda \
|
|
|
|
/usr/local/lib/lein /usr/local/bin/lein /usr/local/bin/pulumi*
|
2021-02-14 16:42:31 +01:00
|
|
|
printf "Removing Browser-based Webdrivers...\n"
|
|
|
|
sudo rm -rf -- /usr/share/java/selenium-server-standalone.jar \
|
|
|
|
/usr/local/share/phantomjs* /usr/local/bin/phantomjs \
|
|
|
|
/usr/local/share/chrome_driver /usr/bin/chromedriver \
|
|
|
|
/usr/local/share/gecko_driver /usr/bin/geckodriver
|
|
|
|
printf "Removing PHP, Composer, Database Management Program Remains...\n"
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo rm -rf -- /etc/php /usr/bin/composer /usr/local/bin/phpunit \
|
|
|
|
/var/lib/mysql /etc/mysql /usr/local/bin/sqlcmd /usr/local/bin/bcp \
|
|
|
|
/usr/local/bin/session-manager-plugin
|
|
|
|
printf "Removing Julia, Rust, Cargo, Rubugems, Rake, Swift, Haskell, Erlang...\n"
|
|
|
|
sudo rm -rf -- /usr/local/julia* /usr/bin/julia \
|
2021-03-21 21:38:37 +01:00
|
|
|
/usr/share/rust /home/runner/.cargo /home/runner/.rustup /home/runner/.ghcup \
|
2021-03-01 20:13:13 +01:00
|
|
|
/usr/local/bin/rake /usr/local/bin/rdoc /usr/local/bin/ri /usr/local/bin/racc /usr/local/bin/rougify \
|
|
|
|
/usr/local/bin/bundle /usr/local/bin/bundler /var/lib/gems \
|
|
|
|
/usr/share/swift /usr/local/bin/swift /usr/local/bin/swiftc \
|
|
|
|
/usr/bin/ghc /usr/local/.ghcup /usr/local/bin/stack \
|
2021-03-21 21:38:37 +01:00
|
|
|
/usr/local/bin/rebar3 /usr/share/sbt /usr/bin/sbt \
|
2021-03-01 20:13:13 +01:00
|
|
|
/usr/bin/go /usr/bin/gofmt
|
2021-02-14 16:42:31 +01:00
|
|
|
printf "Removing Various Cloud CLI Tools...\n"
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo rm -rf -- /usr/local/bin/aws /usr/local/bin/aws_completer /usr/local/aws-cli /usr/local/aws \
|
|
|
|
/usr/local/bin/aliyun /usr/share/az_* /opt/az /usr/bin/az \
|
2021-03-21 21:38:37 +01:00
|
|
|
/usr/local/bin/azcopy* /usr/bin/azcopy /usr/lib/azcopy \
|
2021-03-01 20:13:13 +01:00
|
|
|
/usr/local/bin/oc /usr/local/bin/oras \
|
|
|
|
/usr/local/bin/README.md
|
2021-02-14 16:42:31 +01:00
|
|
|
printf "Removing Different Kubernetes & Container Management Programs...\n"
|
|
|
|
sudo rm -rf -- /usr/local/bin/packer /usr/local/bin/terraform \
|
|
|
|
/usr/local/bin/helm /usr/local/bin/kubectl /usr/local/bin/kind \
|
|
|
|
/usr/local/bin/kustomize /usr/local/bin/minikube \
|
|
|
|
/usr/libexec/catatonit/catatonit
|
|
|
|
printf "Removing Microsoft dotnet Application Remains...\n"
|
|
|
|
sudo rm -rf -- /usr/share/dotnet
|
|
|
|
printf "Removing Java GraalVM...\n"
|
|
|
|
sudo rm -rf -- /usr/local/graalvm
|
|
|
|
printf "Removing Manpages...\n"
|
|
|
|
sudo rm -rf -- /usr/share/man
|
2021-03-01 20:13:13 +01:00
|
|
|
printf "Clearing Remains of Apt Packages...\n"
|
|
|
|
sudo rm -rf -- /var/lib/apt/lists/* /var/cache/apt/archives/* /etc/apt/sources.list.d/*
|
2021-02-14 16:42:31 +01:00
|
|
|
} 2>/dev/null
|
|
|
|
echo "::endgroup::"
|
2021-01-30 14:53:19 +01:00
|
|
|
|
2021-03-01 20:13:13 +01:00
|
|
|
echo "::group::Clearing Unwanted Environment Variables"
|
2021-02-14 16:42:31 +01:00
|
|
|
{
|
2021-03-01 20:13:13 +01:00
|
|
|
sudo sed -i -e '/^PATH=/d;/hostedtoolcache/d;/^AZURE/d;/^SWIFT/d;/^DOTNET/d;/DRIVER/d;/^CHROME/d;/HASKELL/d;/^JAVA/d;/^SELENIUM/d;/^GRAALVM/d;/^ANT/d;/^GRADLE/d;/^LEIN/d;/^CONDA/d;/^VCPKG/d;/^ANDROID/d;/^PIPX/d;/^HOMEBREW/d;' /etc/environment
|
|
|
|
sudo sed -i '1i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' /etc/environment
|
|
|
|
sed -i '/HOME\/\.local\/bin/d' /home/runner/.bashrc
|
|
|
|
source /home/runner/.bashrc
|
2021-03-22 13:25:06 +01:00
|
|
|
} &>/dev/null
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2020-12-24 17:44:17 +01:00
|
|
|
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::group::Disk Space After Cleanup"
|
2021-03-21 21:38:37 +01:00
|
|
|
df -hlT /
|
2021-02-14 16:42:31 +01:00
|
|
|
echo "::endgroup::"
|
2021-03-21 21:38:37 +01:00
|
|
|
|
|
|
|
exit
|