c1bac651cb
For some use cases, it can be useful to keep all the kernels and not just keep the latest one. Add a parameter that allows it, and continue cleaning up kernels by default. Change-Id: Ia6e6c1fa18e3724c1eb89226151d81e9e748b793
26 lines
572 B
Bash
Executable file
26 lines
572 B
Bash
Executable file
#!/bin/bash
|
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
set -x
|
|
fi
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
if [ $DIB_DISABLE_KERNEL_CLEANUP -ne 0 ]; then
|
|
echo "Skipping kernel cleanup as configured"
|
|
exit 0
|
|
fi
|
|
|
|
YUM=${YUM:-yum}
|
|
|
|
if [[ ${YUM} == "dnf" ]]; then
|
|
# cribbed from
|
|
# http://dnf.readthedocs.org/en/latest/cli_vs_yum.html
|
|
_old_kernels="$(dnf repoquery --installonly --latest-limit -1 -q)"
|
|
if [[ -n "${_old_kernels}" ]]; then
|
|
dnf remove -y ${_old_kernels}
|
|
fi
|
|
else
|
|
install-packages yum-utils
|
|
package-cleanup --oldkernels -y --count=1
|
|
fi
|