From 59b5b264f06d0f330b78d5cd7273144f841eeaf6 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sat, 18 Mar 2017 12:04:47 -0500 Subject: [PATCH] * usr/bin/purge-old-kernels, usr/share/man/man1/purge-old-kernels.1: - add a --quiet option for cronjobs - add note in the manpage --- debian/changelog | 5 +++++ usr/bin/purge-old-kernels | 16 ++++++++++++++-- usr/share/man/man1/purge-old-kernels.1 | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 767d2d86..8f5ce9b2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,11 @@ byobu (5.116) unreleased; urgency=medium - save 100K lines of scrollback, rather than 10K, which I find gets eclipsed too often when you actually need it + [ janvonde ] + * usr/bin/purge-old-kernels, usr/share/man/man1/purge-old-kernels.1: + - add a --quiet option for cronjobs + - add note in the manpage + -- Dustin Kirkland Mon, 06 Feb 2017 12:22:26 -0600 byobu (5.115-0ubuntu1) zesty; urgency=medium diff --git a/usr/bin/purge-old-kernels b/usr/bin/purge-old-kernels index 419d18c2..63272825 100755 --- a/usr/bin/purge-old-kernels +++ b/usr/bin/purge-old-kernels @@ -28,10 +28,18 @@ fi # NOTE: This script will ALWAYS keep the currently running kernel # NOTE: Default is to keep 2 more, user overrides with --keep N KEEP=2 +# NOTE: This script will give a hint if no kernels are eligible for removal +# NOTE: You can disable this with the --quit parameter +QUIET=0 # NOTE: Any unrecognized option will be passed straight through to apt APT_OPTS= while [ ! -z "$1" ]; do case "$1" in + --quiet) + # No hint on no kernels for removal, better for cronjobs + QUIET=1 + shift 1 + ;; --keep) # User specified the number of kernels to keep KEEP="$2" @@ -61,8 +69,12 @@ for v in $VERSIONS; do done if [ -z "$PURGE" ]; then - echo "No kernels are eligible for removal" - exit 0 + if [ "${QUIET}" -ne "1" ]; then + echo "No kernels are eligible for removal" + exit 0 + else + exit 0 + fi fi # Use apt-get, rather than apt, for compatibility with precise/trusty diff --git a/usr/share/man/man1/purge-old-kernels.1 b/usr/share/man/man1/purge-old-kernels.1 index 08fbc216..9722fb7f 100644 --- a/usr/share/man/man1/purge-old-kernels.1 +++ b/usr/share/man/man1/purge-old-kernels.1 @@ -3,11 +3,13 @@ purge-old-kernels - remove old kernel and header packages from the system .SH SYNOPSIS -\fBpurge-old-kernels\fP [--keep N] [*] +\fBpurge-old-kernels\fP [--keep N] [--quiet] [*] .SH DESCRIPTION This program will remove old kernel and header packages from the system, freeing disk space. It will never remove the currently running kernel. By default, it will keep at least the latest 2 kernels, but the user can override that value using the --keep parameter. Any additional parameters will be passed directly to \fBapt-get\fP(8). +The --quiet option is useful for cronjobs, to ensure silence messages when there's nothing new to do. + This program requires administrative access. .SH EXAMPLE