Files
runner-images/images/linux/scripts/installers/cleanup.sh
Leonid Lapshin ed38c86cbb Move linux provision scripts to virtual-environments (#1714)
* add linux-related scripts from MMS provisioner

* removed EOL

* removed Ubuntu condition

* moved PATH checking to cleanup section

* add clarification for cgroups names

* names alignment

* removed memory-configuration and agent specific scripts

* renamed folder to psot-generation, added template instructions

* moved key import to git installation

* moved PATH check to post-deployment instead of cleanup script

* add scripts

* output tests file

* add startup logic

* add powershell module for furute helpers

* removed unused modules

* copy to tmp folder because of permissions, copy to opt on post-generation step

* removed Pester test

* change post-generation location

* incorrect if statement

Co-authored-by: Leonid Lapshin <originalnoe-nazvanie@yandex.ru>
2020-10-12 17:44:31 +03:00

31 lines
740 B
Bash

#!/bin/bash
# before cleanup
before=$(df / -Pm | awk 'NR==2{print $4}')
# clears out the local repository of retrieved package files
# It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial
apt-get clean
rm -rf /tmp/*
# journalctl
if command -v journalctl; then
journalctl --rotate
journalctl --vacuum-time=1s
fi
# delete all .gz and rotated file
find /var/log -type f -regex ".*\.gz$" -delete
find /var/log -type f -regex ".*\.[0-9]$" -delete
# wipe log files
find /var/log/ -type f -exec cp /dev/null {} \;
# after cleanup
after=$(df / -Pm | awk 'NR==2{print $4}')
# display size
echo "Before: $before MB"
echo "After : $after MB"
echo "Delta : $(($after-$before)) MB"