2014-02-18 22:14:43 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-09-04 04:56:29 +00:00
|
|
|
if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then
|
|
|
|
set -x
|
|
|
|
fi
|
2014-03-29 03:28:22 +00:00
|
|
|
set -eu
|
|
|
|
set -o pipefail
|
|
|
|
|
2016-08-11 11:29:29 +00:00
|
|
|
if [ $DIB_DISABLE_KERNEL_CLEANUP -ne 0 ]; then
|
|
|
|
echo "Skipping kernel cleanup as configured"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-11-25 03:31:50 +00:00
|
|
|
YUM=${YUM:-yum}
|
2014-02-18 22:14:43 +00:00
|
|
|
|
2015-11-25 03:31:50 +00:00
|
|
|
if [[ ${YUM} == "dnf" ]]; then
|
|
|
|
# cribbed from
|
|
|
|
# http://dnf.readthedocs.org/en/latest/cli_vs_yum.html
|
2017-07-18 03:15:09 +00:00
|
|
|
_old_kernels="$(dnf repoquery --installonly --latest-limit=-1 -q)"
|
2015-11-25 03:31:50 +00:00
|
|
|
if [[ -n "${_old_kernels}" ]]; then
|
|
|
|
dnf remove -y ${_old_kernels}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
install-packages yum-utils
|
|
|
|
package-cleanup --oldkernels -y --count=1
|
|
|
|
fi
|