diff options
author | Barry Jackson <barjac@users.noreply.github.com> | 2023-01-05 15:22:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-05 15:22:25 +0000 |
commit | 8d6bb61cf2c23bba979716d9cb0ee26789f594bd (patch) | |
tree | e228c4131be5bc255a7b2e6a679fdd7c505b2241 | |
parent | 7651d383f33ee245a082e657a9055f318f5d6886 (diff) | |
download | remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar.gz remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar.bz2 remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.tar.xz remove-old-kernels-8d6bb61cf2c23bba979716d9cb0ee26789f594bd.zip |
Add files via upload
initial import
-rw-r--r-- | README.urpmi | 23 | ||||
-rw-r--r-- | locale/de_DE.UTF-8/LC_MESSAGES/remove-old-kernels.mo | bin | 0 -> 5837 bytes | |||
-rw-r--r-- | locale/en_GB.UTF-8/LC_MESSAGES/remove-old-kernels.mo | bin | 0 -> 5380 bytes | |||
-rw-r--r-- | locale/en_US.UTF-8/LC_MESSAGES/remove-old-kernels.mo | bin | 0 -> 5380 bytes | |||
-rw-r--r-- | locale/fr_FR.UTF-8/LC_MESSAGES/remove-old-kernels.mo | bin | 0 -> 5806 bytes | |||
-rw-r--r-- | locale/nl_NL.UTF-8/LC_MESSAGES/remove-old-kernels.mo | bin | 0 -> 5783 bytes | |||
-rw-r--r-- | mk-mo | 23 | ||||
-rw-r--r-- | org.mageia.remove-old-kernels.policy | 22 | ||||
-rw-r--r-- | po/de_DE.UTF-8.po | 159 | ||||
-rw-r--r-- | po/en_GB.UTF-8.po | 162 | ||||
-rw-r--r-- | po/en_US.UTF-8.po | 159 | ||||
-rw-r--r-- | po/fr_FR.UTF-8.po | 159 | ||||
-rw-r--r-- | po/nl_NL.UTF-8.po | 160 | ||||
-rw-r--r-- | remove-old-kernels | 499 | ||||
-rw-r--r-- | remove-old-kernels-pkexec | 3 | ||||
-rw-r--r-- | remove-old-kernels.1 | 187 | ||||
-rw-r--r-- | remove-old-kernels.cfg | 54 | ||||
-rw-r--r-- | remove-old-kernels.cron | 18 | ||||
-rw-r--r-- | remove-old-kernels.desktop | 22 | ||||
-rw-r--r-- | remove-old-kernels.svg | 337 | ||||
-rw-r--r-- | remove-old-kernels_N.cfg.template | 48 |
21 files changed, 2035 insertions, 0 deletions
diff --git a/README.urpmi b/README.urpmi new file mode 100644 index 0000000..d2b3b4a --- /dev/null +++ b/README.urpmi @@ -0,0 +1,23 @@ +You have installed or updated remove-old-kernels which will automatically remove obsolete system kernels safely, using urpme. + +A large accumulation of these can break systems with limited disk space. +See: https://bugs.mageia.org/show_bug.cgi?id=24403 + +By default it will do this weekly and will leave two previous kernels plus the one in use, +of each flavour installed. e.g. If you have 3 kernel-desktops and 3 kernel-linus installed +then nothing will be removed. If there are 4 of one flavour then the one installed FIRST will +be removed, or suggested for removal in interactive mode. + +It is intended primarily for regular users and those without the technical knowledge or motivation +to do this manually. + +It also has an advanced mode to suit developers and testers. Please read the -h help or, for full details +the man page. + +If this is NOT what you want, then there are several options: + +1. Use the available options to adjust the settings to be more appropriate for your use. +Such as, turning off the automatic mode, invoking the advanced mode or increasing the number to keep. +Please read the man page. + +2. Uninstall the remove-old-kernels package, but first explore it's capabilities, you may find it useful! diff --git a/locale/de_DE.UTF-8/LC_MESSAGES/remove-old-kernels.mo b/locale/de_DE.UTF-8/LC_MESSAGES/remove-old-kernels.mo Binary files differnew file mode 100644 index 0000000..7d7043b --- /dev/null +++ b/locale/de_DE.UTF-8/LC_MESSAGES/remove-old-kernels.mo diff --git a/locale/en_GB.UTF-8/LC_MESSAGES/remove-old-kernels.mo b/locale/en_GB.UTF-8/LC_MESSAGES/remove-old-kernels.mo Binary files differnew file mode 100644 index 0000000..fdf738d --- /dev/null +++ b/locale/en_GB.UTF-8/LC_MESSAGES/remove-old-kernels.mo diff --git a/locale/en_US.UTF-8/LC_MESSAGES/remove-old-kernels.mo b/locale/en_US.UTF-8/LC_MESSAGES/remove-old-kernels.mo Binary files differnew file mode 100644 index 0000000..9f8b154 --- /dev/null +++ b/locale/en_US.UTF-8/LC_MESSAGES/remove-old-kernels.mo diff --git a/locale/fr_FR.UTF-8/LC_MESSAGES/remove-old-kernels.mo b/locale/fr_FR.UTF-8/LC_MESSAGES/remove-old-kernels.mo Binary files differnew file mode 100644 index 0000000..71748d8 --- /dev/null +++ b/locale/fr_FR.UTF-8/LC_MESSAGES/remove-old-kernels.mo diff --git a/locale/nl_NL.UTF-8/LC_MESSAGES/remove-old-kernels.mo b/locale/nl_NL.UTF-8/LC_MESSAGES/remove-old-kernels.mo Binary files differnew file mode 100644 index 0000000..317cc86 --- /dev/null +++ b/locale/nl_NL.UTF-8/LC_MESSAGES/remove-old-kernels.mo @@ -0,0 +1,23 @@ +#!/bin/bash + +# Recreates ALL .mo binaries from .po text files in po directory + +[[ -d locale ]] && rm -r locale + +mkdir locale + +cd po + +for po in *.po; do + +echo $po + +molang=$(echo $po|rev|cut -d. -f2-|rev) + +mkdir -p ../locale/$molang/LC_MESSAGES + +msgfmt -vco ../locale/$molang/LC_MESSAGES/remove-old-kernels.mo $po + +done + +cd .. diff --git a/org.mageia.remove-old-kernels.policy b/org.mageia.remove-old-kernels.policy new file mode 100644 index 0000000..b1b7c05 --- /dev/null +++ b/org.mageia.remove-old-kernels.policy @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE policyconfig PUBLIC + "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" + "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd"> +<policyconfig> +<vendor>Mageia</vendor> +<vendor_url>http://www.mageia.org/</vendor_url> +<action id="org.mageia.remove-old-kernels.pkexec.run"> +<description>Run Mageia Old Kernel Remover</description> +<message> +Authentication is required to run remove-old-kernels +</message> +<icon_name>remove-old-kernels</icon_name> +<defaults> +<allow_any>no</allow_any> +<allow_inactive>no</allow_inactive> +<allow_active>auth_admin_keep</allow_active> +</defaults> +<annotate key="org.freedesktop.policykit.exec.path">/usr/libexec/remove-old-kernels</annotate> +<annotate key="org.freedesktop.policykit.exec.allow_gui">false</annotate> +</action> +</policyconfig> diff --git a/po/de_DE.UTF-8.po b/po/de_DE.UTF-8.po new file mode 100644 index 0000000..a074a4f --- /dev/null +++ b/po/de_DE.UTF-8.po @@ -0,0 +1,159 @@ +msgid "" +msgstr "" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Project-Id-Version: remove-old-kernels\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Google\n" +"Language-Team: Google\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: de_DE\n" +"X-Generator: Poedit 2.4.2\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: \n" + +msgid "Welcome to 'remove-old-kernels' Interactive" +msgstr "Willkommen bei 'remove-old-kernels' Interactive" + +msgid "Keep" +msgstr "Behalten" + +msgid "Remove" +msgstr "Entfernen" + +msgid "KEEP" +msgstr "BEHALTEN" + +msgid "AUTO" +msgstr "AUTO" + +msgid "Must be root to allow removal" +msgstr "Muss root sein, um das Entfernen zu ermöglichen" + +msgid "Must be root to edit configuration" +msgstr "Muss root sein, um die Konfiguration zu bearbeiten" + +msgid "kernel" +msgstr "kernel" + +msgid "kernels" +msgstr "Kerne" + +msgid "y/N/i (i=confirm for each)" +msgstr "y/N/i (y=ja N=nein i=jeweils bestätigen)" + +msgid "y/N/q (q=quit)" +msgstr "y/N/q (y=ja N=nein q=verlassen)" + +msgid "interactive" +msgstr "interaktiv" + +msgid "abort" +msgstr "abbrechen" + +msgid "quit" +msgstr "verlassen" + +msgid "Kernels in" +msgstr "Kerne rein" + +msgid "Gain" +msgstr "Gewinnen" + +msgid "Tap spacebar to exit" +msgstr "Tippen Sie zum Beenden auf die Leertaste" + +msgid "Tap spacebar" +msgstr "Tippen Sie auf die Leertaste" + +msgid "In use now" +msgstr "Jetzt im Einsatz" + +msgid "Test mode is on - kernels will not be removed" +msgstr "Der Testmodus ist aktiviert – Kernel werden nicht entfernt" + +msgid "DEBUG: Could execute: urpme" +msgstr "DEBUG: Könnte ausführen: urpme" + +msgid "Command that would be used" +msgstr "Befehl, der verwendet werden würde" + +msgid "Commands that would be used" +msgstr "Befehle, die verwendet werden würden" + +msgid "Your alternative configuration file does not exist:" +msgstr "Ihre alternative Konfigurationsdatei existiert nicht:" + +msgid "Either replace it or set ALTCFG=0 in" +msgstr "Entweder ersetzen oder ALTCFG=0 setzen" + +msgid "FATAL: Failed to read:" +msgstr "FATAL: Lesen fehlgeschlagen:" + +msgid "No such alternative configuration file:" +msgstr "Keine solche alternative Konfigurationsdatei:" + +msgid "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" +msgstr "Verwendung: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n Anzahl] [-N Anzahl] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" + +msgid " -a = automatic, no questions. Interactive if not specified. (must be root)" +msgstr " -a = Automatisch, keine Frage. Interaktiv, falls nicht angegeben. (muss root sein)" + +msgid " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" +msgstr " -A Wert = y oder n, um die automatische wöchentliche Entfernung von Kerneln ein- oder auszuschalten. (zB -Ay)" + +msgid " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" +msgstr " -c = wie automatisch, prüft aber auch auf CRON=y in der cfg-Datei oder beendet sich. (muss root sein)" + +msgid " -t = Test mode, nothing is removed, urpme is simulated." +msgstr " -t = Testmodus, es wird nichts entfernt, urpme wird simuliert." + +msgid " -f value = number of the alternate .cfg file to use this time only. Exits if missing." +msgstr " -f Wert = Nummer der alternativen .cfg-Datei, die nur dieses Mal verwendet werden soll. Ausgänge falls fehlend." + +msgid " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." +msgstr " -F Wert = Nummer der zu verwendenden alt .cfg-Datei. Dadurch wird die Einstellung ALTCFG= in der .cfg-Hauptdatei geändert." + +msgid " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" +msgstr " -n Wert = Anzahl der Kernel, die nur diese Zeit behalten werden sollen. (-n5 oder -n 5 behält 5 Kernel), Min=2, Standard=3" + +msgid " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" +msgstr " -N Wert = Anzahl der zu behaltenden Kerne. Dies ändert die Einstellung der Konfigurationsdatei. (zB -N 5)" + +msgid " -p = preview the urpme commands which would be used." +msgstr " -p = Vorschau der urpme-Befehle, die verwendet werden würden." + +msgid " -q = advanced mode, this time only - see man page." +msgstr " -q = Erweiterter Modus, diesmal nur - siehe Manpage." + +msgid " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" +msgstr " -Q Wert = 1 oder 0 (1 = EIN) erweiterter Modus, dauerhaft. (zB -Q 1)" + +msgid " -l = list the last 1000 lines of the log." +msgstr " -l = listet die letzten 1000 Zeilen des Protokolls auf." + +msgid " -m = mono. No colours in screen output." +msgstr " -m = Mono. Keine Farben in der Bildschirmausgabe." + +msgid " -v = version." +msgstr " -v = Ausführung." + +msgid " -? or -h = show this help." +msgstr " -? or -h = Zeigen Sie diese Hilfe." + +msgid "KEY for column 3:" +msgstr "SCHLÜSSEL für Spalte 3:" + +msgid " U = curently (U)sed running kernel." +msgstr " U = aktuell (U)sed laufender Kernel." + +msgid " V = keeping for (V)irtualbox -latest. (only in advanced mode)" +msgstr " V = Aufbewahrung für (V)irtualbox -neueste. (nur im erweiterten Modus)" + +msgid " X = keeping for (X)tables-addons -latest. (only in advanced mode)" +msgstr " X = Aufbewahrung für (X)tables-addons -latest. (nur im erweiterten Modus)" + +msgid " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" +msgstr " K = keeping kernel-*-devel for installed (K)ernel. (nur im erweiterten Modus)" diff --git a/po/en_GB.UTF-8.po b/po/en_GB.UTF-8.po new file mode 100644 index 0000000..78b6df1 --- /dev/null +++ b/po/en_GB.UTF-8.po @@ -0,0 +1,162 @@ +msgid "" +msgstr "" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Project-Id-Version: remove-old-kernels\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en_GB\n" +"X-Generator: Poedit 2.4.2\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: \n" + +msgid "Welcome to 'remove-old-kernels' Interactive" +msgstr "Welcome to 'rok' Interactive" + +msgid "Keep" +msgstr "Keep" + +msgid "Remove" +msgstr "Remove" + +msgid "KEEP" +msgstr "KEEP" + +msgid "AUTO" +msgstr "AUTO" + +msgid "Must be root to allow removal" +msgstr "Must be root to allow removal" + +msgid "Must be root to edit configuration" +msgstr "Must be root to edit configuration" + +msgid "kernel" +msgstr "kernel" + +msgid "kernels" +msgstr "kernels" + +# For languages where y/N/i is not appropriate DO NOT change "y/N/i" +# but add (y=yes N=no i=confirm) with only 'yes' and 'no' translated. +# See fr_FR.po as example +msgid "y/N/i (i=confirm for each)" +msgstr "y/N/i (i=confirm for each)" + +msgid "y/N/q (q=quit)" +msgstr "y/N/q (q=quit)" + +msgid "interactive" +msgstr "interactive" + +msgid "abort" +msgstr "abort" + +msgid "quit" +msgstr "quit" + +msgid "Kernels in" +msgstr "Kernels in" + +msgid "Gain" +msgstr "Gain" + +msgid "Tap spacebar to exit" +msgstr "Tap spacebar to exit" + +msgid "Tap spacebar" +msgstr "Tap spacebar" + +msgid "In use now" +msgstr "In use now" + +msgid "Test mode is on - kernels will not be removed" +msgstr "Test mode is on - kernels will not be removed" + +msgid "DEBUG: Could execute: urpme" +msgstr "DEBUG: Could execute: urpme" + +msgid "Command that would be used" +msgstr "Command that would be used" + +msgid "Commands that would be used" +msgstr "Commands that would be used" + +msgid "Your alternative configuration file does not exist:" +msgstr "Your alternative configuration file does not exist:" + +msgid "Either replace it or set ALTCFG=0 in" +msgstr "Either replace it or set ALTCFG=0 in" + +msgid "FATAL: Failed to read:" +msgstr "FATAL: Failed to read:" + +msgid "No such alternative configuration file:" +msgstr "No such alternative configuration file:" + +msgid "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" +msgstr "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" + +msgid " -a = automatic, no questions. Interactive if not specified. (must be root)" +msgstr " -a = automatic, no questions. Interactive if not specified. (must be root)" + +msgid " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" +msgstr " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" + +msgid " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" +msgstr " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" + +msgid " -t = Test mode, nothing is removed, urpme is simulated." +msgstr " -t = Test mode, nothing is removed, urpme is simulated." + +msgid " -f value = number of the alternate .cfg file to use this time only. Exits if missing." +msgstr " -f value = number of the alternate .cfg file to use this time only. Exits if missing." + +msgid " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." +msgstr " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." + +msgid " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" +msgstr " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" + +msgid " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" +msgstr " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" + +msgid " -p = preview the urpme commands which would be used." +msgstr " -p = preview the urpme commands which would be used." + +msgid " -q = advanced mode, this time only - see man page." +msgstr " -q = advanced mode, this time only - see man page." + +msgid " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" +msgstr " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" + +msgid " -l = list the last 1000 lines of the log." +msgstr " -l = list the last 1000 lines of the log." + +msgid " -m = mono. No colours in screen output." +msgstr " -m = mono. No colours in screen output." + +msgid " -v = version." +msgstr " -v = version." + +msgid " -? or -h = show this help." +msgstr " -? or -h = show this help." + +msgid "KEY for column 3:" +msgstr "KEY for column 3:" + +msgid " U = curently (U)sed running kernel." +msgstr " U = curently (U)sed running kernel." + +msgid " V = keeping for (V)irtualbox -latest. (only in advanced mode)" +msgstr " V = keeping for (V)irtualbox -latest. (only in advanced mode)" + +msgid " X = keeping for (X)tables-addons -latest. (only in advanced mode)" +msgstr " X = keeping for (X)tables-addons -latest. (only in advanced mode)" + +msgid " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" +msgstr " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" diff --git a/po/en_US.UTF-8.po b/po/en_US.UTF-8.po new file mode 100644 index 0000000..ec22512 --- /dev/null +++ b/po/en_US.UTF-8.po @@ -0,0 +1,159 @@ +msgid "" +msgstr "" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Project-Id-Version: remove-old-kernels\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: en_US\n" +"X-Generator: Poedit 2.4.2\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: \n" + +msgid "Welcome to 'remove-old-kernels' Interactive" +msgstr "Welcome to 'rok' Interactive" + +msgid "Keep" +msgstr "Keep" + +msgid "Remove" +msgstr "Remove" + +msgid "KEEP" +msgstr "KEEP" + +msgid "AUTO" +msgstr "AUTO" + +msgid "Must be root to allow removal" +msgstr "Must be root to allow removal" + +msgid "Must be root to edit configuration" +msgstr "Must be root to edit configuration" + +msgid "kernel" +msgstr "kernel" + +msgid "kernels" +msgstr "kernels" + +msgid "y/N/i (i=confirm for each)" +msgstr "y/N/i (i=confirm for each)" + +msgid "y/N/q (q=quit)" +msgstr "y/N/q (q=quit)" + +msgid "interactive" +msgstr "interactive" + +msgid "abort" +msgstr "abort" + +msgid "quit" +msgstr "quit" + +msgid "Kernels in" +msgstr "Kernels in" + +msgid "Gain" +msgstr "Gain" + +msgid "Tap spacebar to exit" +msgstr "Tap spacebar to exit" + +msgid "Tap spacebar" +msgstr "Tap spacebar" + +msgid "In use now" +msgstr "In use now" + +msgid "Test mode is on - kernels will not be removed" +msgstr "Test mode is on - kernels will not be removed" + +msgid "DEBUG: Could execute: urpme" +msgstr "DEBUG: Could execute: urpme" + +msgid "Command that would be used" +msgstr "Command that would be used" + +msgid "Commands that would be used" +msgstr "Commands that would be used" + +msgid "Your alternative configuration file does not exist:" +msgstr "Your alternative configuration file does not exist:" + +msgid "Either replace it or set ALTCFG=0 in" +msgstr "Either replace it or set ALTCFG=0 in" + +msgid "FATAL: Failed to read:" +msgstr "FATAL: Failed to read:" + +msgid "No such alternative configuration file:" +msgstr "No such alternative configuration file:" + +msgid "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" +msgstr "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" + +msgid " -a = automatic, no questions. Interactive if not specified. (must be root)" +msgstr " -a = automatic, no questions. Interactive if not specified. (must be root)" + +msgid " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" +msgstr " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" + +msgid " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" +msgstr " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" + +msgid " -t = Test mode, nothing is removed, urpme is simulated." +msgstr " -t = Test mode, nothing is removed, urpme is simulated." + +msgid " -f value = number of the alternate .cfg file to use this time only. Exits if missing." +msgstr " -f value = number of the alternate .cfg file to use this time only. Exits if missing." + +msgid " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." +msgstr " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." + +msgid " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" +msgstr " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" + +msgid " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" +msgstr " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" + +msgid " -p = preview the urpme commands which would be used." +msgstr " -p = preview the urpme commands which would be used." + +msgid " -q = advanced mode, this time only - see man page." +msgstr " -q = advanced mode, this time only - see man page." + +msgid " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" +msgstr " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" + +msgid " -l = list the last 1000 lines of the log." +msgstr " -l = list the last 1000 lines of the log." + +msgid " -m = mono. No colours in screen output." +msgstr " -m = mono. No colours in screen output." + +msgid " -v = version." +msgstr " -v = version." + +msgid " -? or -h = show this help." +msgstr " -? or -h = show this help." + +msgid "KEY for column 3:" +msgstr "KEY for column 3:" + +msgid " U = curently (U)sed running kernel." +msgstr " U = curently (U)sed running kernel." + +msgid " V = keeping for (V)irtualbox -latest. (only in advanced mode)" +msgstr " V = keeping for (V)irtualbox -latest. (only in advanced mode)" + +msgid " X = keeping for (X)tables-addons -latest. (only in advanced mode)" +msgstr " X = keeping for (X)tables-addons -latest. (only in advanced mode)" + +msgid " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" +msgstr " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" diff --git a/po/fr_FR.UTF-8.po b/po/fr_FR.UTF-8.po new file mode 100644 index 0000000..4b71d28 --- /dev/null +++ b/po/fr_FR.UTF-8.po @@ -0,0 +1,159 @@ +msgid "" +msgstr "" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Project-Id-Version: remove-old-kernels\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Google\n" +"Language-Team: Google\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: fr_FR\n" +"X-Generator: Poedit 2.4.2\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: \n" + +msgid "Welcome to 'remove-old-kernels' Interactive" +msgstr "Bienvenue sur 'remove-old-kernels' Interactive" + +msgid "Keep" +msgstr "Garder" + +msgid "KEEP" +msgstr "GARDER" + +msgid "Remove" +msgstr "Enlever" + +msgid "AUTO" +msgstr "AUTO" + +msgid "Must be root to allow removal" +msgstr "Doit être root pour permettre enlever" + +msgid "Must be root to edit configuration" +msgstr "Doit être root pour modifier la configuration" + +msgid "kernel" +msgstr "noyau" + +msgid "kernels" +msgstr "noyaux" + +msgid "y/N/i (i=confirm for each)" +msgstr "y/N/i (y=oui N=non i=confirmer pour chaque)" + +msgid "y/N/q (q=quit)" +msgstr "y/N/q (y=oui N=non q=quitter)" + +msgid "interactive" +msgstr "interactif" + +msgid "abort" +msgstr "abandonner" + +msgid "quit" +msgstr "quitter" + +msgid "Kernels in" +msgstr "Noyaux dans" + +msgid "Gain" +msgstr "Gain" + +msgid "Tap spacebar to exit" +msgstr "Appuyez sur la barre d'espace pour quitter" + +msgid "Tap spacebar" +msgstr "Appuyez sur la barre d'espace" + +msgid "In use now" +msgstr "En usage maintenant" + +msgid "Test mode is on - kernels will not be removed" +msgstr "Le mode test est activé - les noyaux ne seront pas supprimés" + +msgid "DEBUG: Could execute: urpme" +msgstr "DEBUG : Peut s'exécuter : urpme" + +msgid "Command that would be used" +msgstr "Commande qui serait utilisée" + +msgid "Commands that would be used" +msgstr "Commandes qui seraient utilisées" + +msgid "Your alternative configuration file does not exist:" +msgstr "Votre fichier de configuration alternatif n'existe pas :" + +msgid "Either replace it or set ALTCFG=0 in" +msgstr "Remplacez-le ou définissez ALTCFG=0 dans" + +msgid "FATAL: Failed to read:" +msgstr "FATAL : Échec de la lecture :" + +msgid "No such alternative configuration file:" +msgstr "Aucun fichier de configuration alternatif de ce type :" + +msgid "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" +msgstr "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n numéro] [-N numéro] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" + +msgid " -a = automatic, no questions. Interactive if not specified. (must be root)" +msgstr " -a = automatique, pas de questions. Interactif si non spécifié. (doit être root)" + +msgid " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" +msgstr " -A valeur = y ou n pour activer ou désactiver la suppression automatique des noyaux. (e.g. -Ay)" + +msgid " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" +msgstr " -c = comme automatique mais vérifie également CRON=y dans le fichier cfg ou quitte. (doit être root)" + +msgid " -t = Test mode, nothing is removed, urpme is simulated." +msgstr " -t = Mode test, rien n'est supprimé, urpme est simulé." + +msgid " -f value = number of the alternate .cfg file to use this time only. Exits if missing." +msgstr " -f valeur = numéro du fichier .cfg alternatif à utiliser cette fois uniquement. Quitte si manquant." + +msgid " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." +msgstr " -F valeur = numéro du fichier alt .cfg à utiliser. Cela modifie le paramètre ALTCFG= dans le fichier .cfg principal." + +msgid " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" +msgstr " -n valeur = nombre de noyaux à conserver cette fois seulement. (-n5 ou -n 5 conserve 5 noyaux), Min=2, Default=3" + +msgid " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" +msgstr " -N valeur = nombre de noyaux à conserver. Cela modifie le paramètre du fichier de configuration. (e.g. -N 5)" + +msgid " -p = preview the urpme commands which would be used." +msgstr " -p = prévisualisez les commandes urpme qui seraient utilisées." + +msgid " -q = advanced mode, this time only - see man page." +msgstr " -q = mode avancé, cette fois uniquement - voir la page de manuel." + +msgid " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" +msgstr " -Q valeur = 1 ou 0 (1 = ON) mode avancé, persistant. (e.g. -Q 1)" + +msgid " -l = list the last 1000 lines of the log." +msgstr " -l = liste les 1000 dernières lignes du journal." + +msgid " -m = mono. No colours in screen output." +msgstr " -m = mono. Pas de couleurs dans la sortie d'écran." + +msgid " -v = version." +msgstr " -v = version." + +msgid " -? or -h = show this help." +msgstr " -? or -h = montrer cette aide." + +msgid "KEY for column 3:" +msgstr "LÉGENDE pour la colonne 3 :" + +msgid " U = curently (U)sed running kernel." +msgstr " U = noyau en cours d'exécution actuellement." + +msgid " V = keeping for (V)irtualbox -latest. (only in advanced mode)" +msgstr " V = à conserver pour (V)irtualbox -latest. (uniquement en mode avancé)" + +msgid " X = keeping for (X)tables-addons -latest. (only in advanced mode)" +msgstr " X = à conserver pour (X)tables-addons -latest. (uniquement en mode avancé)" + +msgid " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" +msgstr " K = conserver kernel-*-devel pour le noyau installé. (uniquement en mode avancé)" diff --git a/po/nl_NL.UTF-8.po b/po/nl_NL.UTF-8.po new file mode 100644 index 0000000..3b7c297 --- /dev/null +++ b/po/nl_NL.UTF-8.po @@ -0,0 +1,160 @@ +msgid "" +msgstr "" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"Project-Id-Version: remove-old-kernels\n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: Google\n" +"Language-Team: Google\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: nl_NL\n" +"X-Generator: Poedit 2.4.2\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: \n" + +msgid "Welcome to 'remove-old-kernels' Interactive" +msgstr "Welkom bij 'oude kernels verwijderen' Interactive" + +msgid "Keep" +msgstr "Houden" + +msgid "Remove" +msgstr "Verwijderen" + +msgid "KEEP" +msgstr "HOUDEN" + +msgid "AUTO" +msgstr "AUTO" + +msgid "Must be root to allow removal" +msgstr "Moet root zijn om verwijdering mogelijk te maken" + +msgid "Must be root to edit configuration" +msgstr "Moet root zijn om de configuratie te bewerken" + +msgid "kernel" +msgstr "kernel" + +msgid "kernels" +msgstr "kernels" + +msgid "y/N/i (i=confirm for each)" +msgstr "y/N/i (y=ja N=nee i=bevestig voor elk)" + +msgid "y/N/q (q=quit)" +msgstr "y/N/q (y=ja N=nee q=vertrekken)" + +msgid "interactive" +msgstr "interactief" + +msgid "abort" +msgstr "abort" + +msgid "quit" +msgstr "vertrekken" + +msgid "Kernels in" +msgstr "Kernels in" + +msgid "Gain" +msgstr "Winnen" + +msgid "Tap spacebar to exit" +msgstr "Tik op de spatiebalk om af te sluiten" + +msgid "Tap spacebar" +msgstr "Tik op de spatiebalk" + +msgid "In use now" +msgstr "Nu in gebruik" + +msgid "Test mode is on - kernels will not be removed" +msgstr "Testmodus is ingeschakeld - kernels worden niet verwijderd" + +msgid "DEBUG: Could execute: urpme" +msgstr "DEBUG: Kan uitvoeren: urpme" + +msgid "Command that would be used" +msgstr "Commando dat zou worden gebruikt" + +msgid "Commands that would be used" +msgstr "Commando's die zouden worden gebruikt" + +msgid "Your alternative configuration file does not exist:" +msgstr "Uw alternatieve configuratiebestand bestaat niet:" + +msgid "Either replace it or set ALTCFG=0 in" +msgstr "Vervang het of stel ALTCFG=0 in" + +msgid "FATAL: Failed to read:" +msgstr "FATAL: Kan niet lezen:" + +msgid "No such alternative configuration file:" +msgstr "Geen dergelijk alternatief configuratiebestand:" + +msgid "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" +msgstr "Gebruik: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n nummer] [-N nummer] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]" + +msgid " -a = automatic, no questions. Interactive if not specified. (must be root)" +msgstr " -a = automatisch, geen vragen. Interactief indien niet gespecificeerd. (moet root zijn)" + +msgid " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)" +msgstr " -A waarde = y of n om automatische wekelijkse verwijdering van kernels AAN of UIT te zetten. (bijv. -Ay)" + +msgid " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)" +msgstr " -c = als automatisch maar controleert ook op CRON=y in het cfg-bestand of sluit af. (moet root zijn)" + +msgid " -t = Test mode, nothing is removed, urpme is simulated." +msgstr " -t = Testmodus, niets wordt verwijderd, urpme wordt gesimuleerd." + +msgid " -f value = number of the alternate .cfg file to use this time only. Exits if missing." +msgstr " -f waarde = nummer van het alternatieve .cfg-bestand dat alleen deze keer moet worden gebruikt. Uitgangen indien vermist." + +msgid " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file." +msgstr " -F waarde = aantal te gebruiken alt .cfg-bestanden. Dit verandert de ALTCFG=-instelling in het .cfg-hoofdbestand." + +msgid " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3" +msgstr " -n waarde = aantal kernels om alleen deze tijd te behouden. (-n5 of -n 5 behouden 5 kernels), Min=2, Standaard=3" + +msgid " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)" +msgstr " -N waarde = aantal te behouden kernels. Dit verandert de instelling van het configuratiebestand. (bijv. -N 5)" + +msgid " -p = preview the urpme commands which would be used." +msgstr " -p = bekijk een voorbeeld van de urpme-commando's die zouden worden gebruikt." + +msgid " -q = advanced mode, this time only - see man page." +msgstr " -q = geavanceerde modus, alleen deze keer - zie man-pagina." + +msgid " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)" +msgstr " -Q waarde = 1 of 0 (1 = AAN) geavanceerde modus, permanent. (bijv. -Q 1)" + +msgid " -l = list the last 1000 lines of the log." +msgstr " -l = maak een lijst van de laatste 1000 regels van het logboek." + +msgid " -m = mono. No colours in screen output." +msgstr " -m = mono. Geen kleuren in schermuitvoer." + +msgid " -v = version." +msgstr " -v = versie." + +msgid " -? or -h = show this help." +msgstr " -? or -h = laat deze hulp zien." + +msgid "KEY for column 3:" +msgstr "SLEUTEL voor kolom 3:" + +msgid " U = curently (U)sed running kernel." +msgstr " U = momenteel gebruikte lopende kernel." + +msgid " V = keeping for (V)irtualbox -latest. (only in advanced mode)" +msgstr " V = bewaren voor Virtualbox -latest. (alleen in geavanceerde modus)" + +msgid " X = keeping for (X)tables-addons -latest. (only in advanced mode)" +msgstr " X = behouden voor Xtables-add-ons -nieuwste. (alleen in geavanceerde modus)" + +msgid " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" +msgstr " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)" + diff --git a/remove-old-kernels b/remove-old-kernels new file mode 100644 index 0000000..2f7eb0a --- /dev/null +++ b/remove-old-kernels @@ -0,0 +1,499 @@ +#!/usr/bin/bash +# +# Remove old kernels safely and cleanly using urpme. +# +# LISTK contains the list of kernels to analyse +# The script keeps NBK most recent kernels +# (c) Pierre Jarillon - 2018-04-03 - 2021-11-27 +# (c) Jean-Baptiste Biernacki 2021 +# (c) Barry C Jackson 2022-2023 +#################################### +# +# Do not edit the values below unless you know 'exactly' what you are doing. +# You can pass parameters on the command line to acheive the same functionality. +NBK=3 # Default number of kernels to keep. +DEBUG=0 # 1 for test mode, urpme is simulated and not applied +MODE="I" # mode A)utomatic, I)nteractve (DO NOT CHANGE THIS) +VISU=0 # If VISU=1, show commands which can be used +LANG=$(echo $LANGUAGE|cut -d: -f1) + +# Colours for display Defaults Used for +Normal="\e[0m" # System default f/g colour +KeepCol="\e[92m" # Light Green Keep text +RemvCol="\e[91m" # Light Red Remove text +InfoCol="\e[33m" # Orange Information text +HdBgCol="\e[102;30m" # Light Green Background Heading background +WarnBgCol="\e[101m" # Light Red Background Warnings in heading +ClearLine="\r\e[2K" # Clear the line + +# List of kernel types to include. +# This list is only used if LISTK is omitted from the .cfg file in use. +LISTK=\ +"kernel-desktop586 +kernel-desktop +kernel-desktop-devel +kernel-server +kernel-server-devel +kernel-source +kernel-tmb-desktop +kernel-tmb-desktop-devel +kernel-tmb-source +kernel-linus +kernel-linus-devel +kernel-linus-source +" +prog="remove-old-kernels" +cfgpath="/etc/" +maincfg="${cfgpath}${prog}.cfg" +currcfg=${maincfg} + +# Perform translations +i18n() { +gettext $prog "$1" +} + +# Display -help +usage() { +echo "$(i18n "Usage: <remove-old kernels|rok> [-a] [-A <y/n>] [-c] [-t] [-f 0-9] [-F 0-9] [-n number] [-N number] [-p] [-q] [-Q 0|1][-l] [-m] [-v] [-h|-?]")" +echo "$(i18n " -a = automatic, no questions. Interactive if not specified. (must be root)")" +echo "$(i18n " -A value = y or n to turn ON or OFF automatic weekly removal of kernels. (e.g. -Ay)")" +echo "$(i18n " -c = as automatic but also checks for CRON=y in the cfg file or exits. (must be root)")" +echo "$(i18n " -t = Test mode, nothing is removed, urpme is simulated.")" +echo "$(i18n " -f value = number of the alternate .cfg file to use this time only. Exits if missing.")" +echo "$(i18n " -F value = number of alt .cfg file to use. This changes the ALTCFG= setting in the main .cfg file.")" +echo "$(i18n " -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3")" +echo "$(i18n " -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5)")" +echo "$(i18n " -p = preview the urpme commands which would be used.")" +echo "$(i18n " -q = advanced mode, this time only - see man page.")" +echo "$(i18n " -Q value = 1 or 0 (1 = ON) advanced mode, persistent. (e.g. -Q 1)")" +echo "$(i18n " -l = list the last 1000 lines of the log.")" +echo "$(i18n " -m = mono. No colours in screen output.")" +echo "$(i18n " -v = version.")" +echo "$(i18n " -? or -h = show this help.")" +echo "" +echo "$(i18n "KEY for column 3:")" +echo "$(i18n " U = curently (U)sed running kernel.")" +echo "$(i18n " V = keeping for (V)irtualbox -latest. (only in advanced mode)")" +echo "$(i18n " X = keeping for (X)tables-addons -latest. (only in advanced mode)")" +echo "$(i18n " K = keeping kernel-*-devel for installed (K)ernel. (only advanced mode)")" +echo "" +} + +# Source main .cfg file if it exists, or issue warning and abort. +source ${maincfg} || { echo -e "${RemvCol}$(i18n "FATAL: Failed to read:")${Normal} ${maincfg}"; exit 1; } + +# If an alt .cfg is set in main .cfg +if cat ${maincfg}|grep -q "ALTCFG=" && [[ $ALTCFG -gt 0 ]]; then + # Check it really exists + if [[ -f /etc/remove-old-kernels_$ALTCFG.cfg ]]; then + # Set current cfg to it + currcfg="${cfgpath}${prog}_${ALTCFG}.cfg" + source $currcfg + else + echo -e "${RemvCol}$(i18n "Your alternative configuration file does not exist:")${Normal}\ + /etc/remove-old-kernels_$ALTCFG.cfg\n$(i18n "Either replace it or set ALTCFG=0 in") /etc/remove-old-kernels.cfg" + exit 1 + fi +fi + +# Check for CRON variable in config or add default. (Some users may have early version without this feature) +if ! grep -q -e "CRON=" ${maincfg}; then + echo -e "\n# # Allow cron to run 'remove-old-kernels' weekly. Replace 'y' with 'n' (lower case) to disable it.\nCRON=y" >> ${maincfg} +fi + +# Check dnf limit before option parsing +dnfNBK=0; dnfmsg=false +[[ -f /etc/dnf/dnf.conf ]] && dnfNBK=$(cat /etc/dnf/dnf.conf|grep "installonly_limit="|cut -d= -f2) + +# Check running as root +chkroot() { +if (((UID))); then + echo -e "${RemvCol}$(i18n "Must be root to edit configuration")${Normal}\nHit spacebar" + read -n1; echo -en "${ClearLine}" + exit 0 +fi +} + +# Function to handle -f or -F options +altcfg() { +cfgno=$1 +# Called with f +if [[ ed -ne 1 ]]; then + # Check for cfg 0 + if [[ $cfgno -eq 0 ]]; then + source ${maincfg} + ALTCFG=${cfgno} + else + # If alt cfg file exists source it + if [[ -f /etc/remove-old-kernels_${cfgno}.cfg ]]; then + source /etc/remove-old-kernels_${cfgno}.cfg + ALTCFG=${cfgno} + else + echo -e "${RemvCol}$(i18n "No such alternative configuration file:")${Normal} /etc/remove-old-kernels_${cfgno}.cfg" + exit 1 + fi + fi +else + # Called with F + # If ALTCFG var is missing from the main .cfg file, add it + if ! cat ${maincfg} |grep -q "ALTCFG="; then + echo "ALTCFG=" >> ${maincfg} + fi + # Switch back to .cfg 0 + if [[ $cfgno -eq 0 ]]; then + /usr/bin/sed -i "s/ALTCFG=.*/ALTCFG=${cfgno}/" ${maincfg} + source ${maincfg}; currcfg=${maincfg} + else + # If alt cfg file exists + if [[ -f /etc/remove-old-kernels_${cfgno}.cfg ]]; then + # Add it in main .cfg + /usr/bin/sed -i "s/ALTCFG=.*/ALTCFG=${cfgno}/" ${maincfg} + ALTCFG=${cfgno}; + currcfg="${cfgpath}${prog}_${ALTCFG}.cfg" + source $currcfg + else + echo -e "${RemvCol}$(i18n "No such alternative configuration file:")${Normal} /etc/remove-old-kernels_${cfgno}.cfg" + exit 1 + fi + fi +fi +} + +# Parse arguments from command line which take precedence over script and cfg file +if [[ ${#} -gt 0 ]] ; then + while getopts aA:ctf:F:plmvn:N:qQ:?h NAME; do + case ${NAME} in + a) MODE="A" + ;; + A) chkroot + echo ${currcfg} + CRONN=${OPTARG} && [[ ${#CRONN} = 1 ]] && [[ "yn" =~ "$CRONN" ]] && \ + /usr/bin/sed -i "s/CRON=.*/CRON=${CRONN}/" ${currcfg} && CRON=$CRONN + ;; + c) MODE="A" && [[ ${#CRON} -gt 0 ]] && [[ "$CRON" == "y" ]] || exit 0 + ;; + t) DEBUG=1 + ;; + f) [[ ${OPTARG} =~ ^[0-9] ]] && altcfg ${OPTARG} + ;; + F) chkroot + [[ ${OPTARG} =~ ^[0-9] ]] && ed=1 && altcfg ${OPTARG} + ;; + p) VISU=1 + ;; + q) QA=1 + ;; + Q) chkroot + [[ ${OPTARG} =~ ^[0-1] ]] && QAN="${OPTARG}" + if cat ${currcfg}|grep -q "QA="; then + /usr/bin/sed -i "s/QA=.*/QA=${QAN}/" ${currcfg} && QA=${QAN} + else + echo "QA=${QAN}" >> ${currcfg} && QA=${QAN} + fi + ;; + n) [[ ${OPTARG} =~ ^[0-9]+$ ]] && NBK=${OPTARG} + ;; + N) chkroot + NBKN=${OPTARG} + if [[ $NBKN =~ ^[0-9]+$ ]] && [[ $NBKN -ge $dnfNBK ]]; then + /usr/bin/sed -i "s/NBK=.*/NBK=$NBKN/" ${currcfg} && NBK=$NBKN + else + dnfmsg=true + fi + ;; + l) tail -n1000 /var/log/remove-old-kernels.log && { echo -e "\n$(i18n "Tap spacebar")\n"; read -n1; echo -en "${ClearLine}"; } + ;; + m) Normal="";RemvCol="";KeepCol="";InfoCol="";HdBgCol="";WarnBgCol="";Clearline="" + ;; + v) printf "$(rpm -q remove-old-kernels)\n" + exit 2 + ;; + ?|h) clear; usage + exit 2 + ;; + esac + done + # Don't allow NBK < 2 + if (( NBK < 2 )); then + NBK=2 + fi +fi + +# Only use greeting in interactive mode +if [[ $MODE == "I" ]]; then +clear +echo -e " $(i18n "Welcome to 'remove-old-kernels' Interactive")\n" + +fi + +# Use dnf kernel 'number to keep' if installed +if [[ $dnfNBK -gt $NBK ]] || $dnfmsg; then + NBK=$dnfNBK + dnfmssg="${InfoCol}INFO: Number to keep is restricted to $dnfNBK, by the dnf 'installonly_limit' set in /etc/dnf/dnf.conf${Normal}" +fi + +# Get info for status message +if [[ "$CRON" == "y" ]]; then autostat="ON"; else autostat="${Normal}${WarnBgCol}OFF${HdBgCol}"; fi +if [[ "$QA" == "1" ]]; then qamssg="| Q:ON "; fi +if [[ $ALTCFG -gt 0 ]]; then cfgmssg="|${Normal}${WarnBgCol}F:${ALTCFG}${HdBgCol} "; fi + +# Check that the running kernel is still installed: https://bugs.mageia.org/show_bug.cgi?id=31015 +[[ -e /lib/modules/$(uname -r) ]] || { echo -e "${RemvCol}FATAL: Has the running kernel been uninstalled since last boot? - Aborting."; exit 1; } + +# Get the full name of the current running kernel +CURK=$(rpm -qf /lib/modules/$(uname -r)) + +# Storage for the list of kernels to remove +TMPKTR=$(mktemp) + +# Check storage usage on root partition +OCCDISK1=$(df -B 1M -l --output=used / | tail -n1 | awk '{ print $1 }') + +# Pad translated strings for column 2 + keepstr=$(i18n "Keep"); remstr=$(i18n "Remove") + if [[ ${#keepstr} != ${#remstr} ]]; then + if [[ ${#keepstr} > ${#remstr} ]]; then + while (( ${#remstr} < ${#keepstr} )); do remstr="${remstr} "; done + else + while (( ${#remstr} > ${#keepstr} )); do keepstr="${keepstr} "; done + fi + fi + +#========================= Analyse /boot/ ============================= + +NK=$(ls /boot/vmlinuz*.mga* | wc -l) + +# In automatic mode exit immediately if kernels in boot <= number allowed to be removed + [[ $MODE = "A" ]] && [[ ${NK} -le ${NBK} ]] && exit 0 + +#================================ Show status ============================== + +echo -e "${HdBgCol} System: $(cat /etc/mageia-release) | $(i18n "Kernels in") /boot/:${NK} | AUTO:$autostat | $(i18n "KEEP"):$NBK ${qamssg}${cfgmssg}${Normal} " + +#================================= Analyse rpms ============================= +# Get master list from rpm -qa --last +allkernels=$(rpm -qa --last|grep "kernel-") + +# Get the kernel version and release required by the installed virtualbox-flavour-latest +get_vbox_kern() { +if echo "$allkernels"|grep -q "virtualbox-${kernelType}-latest"; then + vb_latest_ver=$(echo "$allkernels"|grep "virtualbox-${kernelType}-latest"|cut -d- -f5-|rev|cut -d. -f2-|rev) +else + qavkern=; return +fi +depkern=$(echo "$allkernels"|grep $vb_latest_ver|grep -v latest|grep virtualbox-kernel-[0-9]) +kern_ver=$(echo $depkern|cut -d- -f3-|cut -d- -f1) +kern_rel=$(echo $depkern|cut -d- -f5-|cut -d. -f1) +[[ ${#kern_ver} > 0 ]] && [[ ${#kern_rel} > 0 ]] && qavkern="${kern_ver}-${kern_rel}" +} + +# Get the kernel version and release required by the installed xtables-addons-flavour-latest +get_xtables_kern() { +if echo "$allkernels"|grep -q "xtables-addons-${kernelType}-latest"; then + xt_latest_ver=$(echo "$allkernels"|grep kernel-|grep "xtables-addons-kernel"|grep "latest"|cut -d- -f6-|rev|cut -d. -f2-|rev) +else + qaxkern=; return +fi +depkern=$(echo "$allkernels"|grep $xt_latest_ver|grep xtables-addons-kernel-[0-9]|cut -d ' ' -f1) +kern_ver=$(echo $depkern|cut -d- -f4) +kern_rel=$(echo $depkern|cut -d- -f6 -|cut -d. -f1) +[[ ${#kern_ver} > 0 ]] && [[ ${#kern_rel} > 0 ]] && qaxkern="${kern_ver}-${kern_rel}" +} + +# Keep the -devel package for any installed kernel package +depdev() { +# Reset some vars +pkg=; kpkgname=; nnk="" + # Is current pkg a -devel + if echo "${installedKernelPackage}" | grep -q "\-devel"; then + # Get matching kernel package name + kpkgname=$(echo "${installedKernelPackage}"| /usr/bin/sed -e 's/\-devel//') + # Find kernel in installed list without timestamp + for pkg in $(echo "$allkernels"|cut -d ' ' -f1); do + # Look through installed kernels for kernel package + if [[ ${pkg} == ${kpkgname} ]]; then + nnk="K"; REMVBL=0 + # Is kernel flagged for removal? + if cat ${TMPKTR} | grep -q $kpkgname ; then + # Then this -devel is also removable + nnk=""; REMVBL=1 + fi + # We are done here + break + fi + done + fi +} + +# Exclude 'latest' packages from installed kernel list +rpmqaList=$(echo "$allkernels"|grep -v latest) + +# Loop through kernel types in LISTK +for kernelType in ${LISTK}; do + [[ $QA -eq 1 ]] && get_vbox_kern && get_xtables_kern + installedKernelCounter=0; +# Scan through installed kernels to match with kernel type in LISTK + echo "$rpmqaList"|grep "${kernelType}-[0-9]"|while read installedKernel; do + # Clear these for each loop + NOTA=""; REMVBL=1 +# Increment installedKernelCounter + installedKernelCounter=$((${installedKernelCounter} + 1)) + +# Return to the line if there exists at least one installedKernel of this kernelType + if [[ ${installedKernelCounter} -eq 1 ]] ; then + echo -ne "\r ==> ${kernelType}" + echo "" + fi + +# Remove time stamp + installedKernelPackage=$(echo ${installedKernel} | cut -d ' ' -f 1 ) + +# Check for current kernel + if [[ $(echo ${installedKernel} | grep ${CURK} | wc -l ) -eq 1 ]] ; then + NOTA="U" # current kernel + REMVBL=0 # not removable + fi + +# Check if kernel is required by vbox latest kernel + if [[ $QA -eq 1 ]] && [[ ${#qavkern} -gt 0 ]] && [[ $(echo ${installedKernel} | grep "$qavkern" | wc -l ) -eq 1 ]]; then + NOTA="${NOTA}V" # Required by VBox + REMVBL=0 # not removable + fi + +# Check if kernel is required by xtables latest kernel + if [[ $QA -eq 1 ]] && [[ ${#qaxkern} -gt 0 ]] && [[ $(echo ${installedKernel} | grep "$qaxkern" | wc -l ) -eq 1 ]]; then + NOTA="${NOTA}X" # Required by xtables + REMVBL=0 # not removable + fi + +# If a kernel devel package has the corresponding kernel package keep it + if [[ $QA -eq 1 ]]; then + depdev + NOTA="${NOTA}${nnk}" + fi + +# Pad NOTA to 4 + while (( ${#NOTA} < 4 )); do NOTA="${NOTA} "; done + +# Pad installedKernelCounter (col 1) to 3 + while (( ${#installedKernelCounter} < 3 )); do installedKernelCounter="${installedKernelCounter} "; done + + if [[ ${installedKernelCounter} -gt $NBK ]]; then + if [[ ${REMVBL} -ne 1 ]] ; then + echo -e "\r ${installedKernelCounter}${KeepCol} : $keepstr: ${NOTA}: ${installedKernel} ${Normal}" + else + echo -e "\r ${installedKernelCounter}${RemvCol} : $remstr: ${NOTA}: ${installedKernel} ${Normal}" + # Add package to removal list + echo ${installedKernelPackage} >> ${TMPKTR} + fi + else + echo -e "\r ${installedKernelCounter}${KeepCol} : $keepstr: ${NOTA}: ${installedKernel} ${Normal}" + fi + done +done + +# Position 'in use' key under symbol below column 3 +padUse=$((${#keepstr}+9)); padstr="" +while (( ${#padstr} < $padUse )); do padstr="${padstr} "; done + +echo -en "${ClearLine}" +echo -e "${padstr}${KeepCol}U${InfoCol} = $(i18n "In use now")${Normal}" +if [[ ${#dnfmssg} > 0 ]];then echo -e "${dnfmssg}"; fi + +#================================= Mode of execution =================== + +nbt=$(cat ${TMPKTR} | wc -l) +if [[ ${nbt} -ne 0 ]] ; then + (((UID))) && echo -e "${RemvCol}$(i18n "Must be root to allow removal")\n${Normal}" + if [[ ${VISU} -eq 1 ]]; then + plural="s"; [[ ${nbt} -eq 1 ]] && plural="" + echo "$(i18n "Command${plural} that would be used"):" + for f in $(tac ${TMPKTR}); do + echo "urpme ${f}" + done + i18n "Tap spacebar to exit" + read -n1 + echo -en "${ClearLine}" + rm -f ${TMPKTR} + exit 0 + fi + + if [[ ${MODE} != "A" ]] ; then + if [[ ${DEBUG} -eq 1 ]] ; then + echo -e "\n${KeepCol}>> $(i18n "Test mode is on - kernels will not be removed") <<${Normal}" + fi + plural="s"; [[ ${nbt} -eq 1 ]] && plural="" + read -p "$(i18n "Remove") ${nbt} $(i18n "kernel${plural}") ? $(i18n "y/N/i (i=confirm for each)") " -n 1 response + if [[ -z ${response} ]] ; then response="n" ; fi + case ${response} in + [Yy]) + AUTO="--auto" + ASK=0 + MODE="A" + echo -e " \n" + ;; + [Ii]) + AUTO="--auto" + MODE="I" + echo " $(i18n "interactive")" + ;; + *) + echo -e "\n$(i18n "Aborted")\n" + rm -f ${TMPKTR} + exit 0 + ;; + esac + fi + +#================================= Execution =========================== + + for installedKernelPackage in $(tac ${TMPKTR}) ; do + if [[ ${MODE} = "I" ]] ; then # --- interactive mode --- + read -p "$(i18n "Remove") ${installedKernelPackage} ? $(i18n "y/N/q (q=quit)") " -n 1 response + echo -e " \n" + if [[ -z ${response} ]]; then + response="N" + fi + case ${response} in + [Yy]) + if [[ ${DEBUG} -eq 1 ]] ; then + echo -e "\n${InfoCol}$(i18n "DEBUG: Could execute: urpme") ${AUTO} ${installedKernelPackage}${Normal}" + nbt=$((${nbt} - 1)) + else + urpme ${installedKernelPackage} + nbt=$((${nbt} - 1)) + fi + ;; + [qQ]) + echo -e "\n$(i18n "Aborted")" + rm -f ${TMPKTR}; + exit 0 + ;; + *) + echo " " + ;; + esac + else # --- automatic mode --- + if [[ ${DEBUG} -eq 1 ]] ; then + echo -e "${InfoCol}$(i18n "DEBUG: Could execute: urpme") ${AUTO} ${installedKernelPackage}${Normal}" + nbt=$((${nbt} - 1)) + else + # echo "Auto execution" + echo -ne 'y\n' | urpme ${AUTO} ${installedKernelPackage} + nbt=$((${nbt} - 1)) + fi + fi + done + NK=$(ls /boot/vmlinuz*.mga[0-9] | wc -l) + OCCDISK2=$(df -B 1M -l --output=used / | tail -n1 | awk '{ print $1 }') + echo -e "${HdBgCol} $(i18n "Gain") : $((OCCDISK1 - OCCDISK2)) MB - $(i18n "Kernels in") /boot/: ${NK} ${Normal}" +fi + +[[ $MODE == "I" ]] && { i18n "Tap spacebar to exit"; read -n1; echo -en "${ClearLine}"; } + +rm -f ${TMPKTR} + +# Run again if some removable kernels are left +(((UID))) && exit 0 # Not root user so exit +[ ${MODE} != "I" ] && exit 0 # Auto so exit +[ ${nbt} -gt 0 ] && ${0} # Root user and interactive so run again if removable kernels left diff --git a/remove-old-kernels-pkexec b/remove-old-kernels-pkexec new file mode 100644 index 0000000..c8ca9f4 --- /dev/null +++ b/remove-old-kernels-pkexec @@ -0,0 +1,3 @@ +#!/bin/sh +pkexec "/usr/sbin/remove-old-kernels" "$@" + diff --git a/remove-old-kernels.1 b/remove-old-kernels.1 new file mode 100644 index 0000000..95e9664 --- /dev/null +++ b/remove-old-kernels.1 @@ -0,0 +1,187 @@ +.TH remove-old-kernels "22 Nov 2022" +.SH NAME +remove-old-kernels \- Utility to remove obsolete kernels in Mageia Systems using urpme. +.SH SYNOPSIS +\fBremove-old-kernels\fP [\fI\-option\fP] + +\fBrok\fP [\fI\-option\fP] + +.SH DESCRIPTION +\fBremove-old-kernels\fR runs automatically under cron.weekly using configuration settings in /etc/remove-old-kernels.cfg. This is the default in order to avoid system failure due to old kernels filling the root file system. +.br +For most users it can be left, as installed, to do it's job without any user intervention or concern. + +.br +It keeps the default (3) kernels of EACH kernel flavour, NOT 3 in total. If there are kernels of various flavours installed, then only the flavours with more than 3 would see any removed. + +.br +It will never remove the running kernel. + +.br +If the running kernel has been accidentally removed by some utility since boot then it will report the error and abort, removing nothing. + +\fBremove-old-kernels\fP also allows interactive command\-line removal of kernel packages using various options. + +\fBremove-old-kernels\fR with no arguments as a regular user, will display the current kernel(s) installed, the one in use, marked with 'U', and the ones it suggests to remove in red, if any. +.br +This is a good way to make a quick check without any risk of error. + +\fBremove-old-kernels\fP is also available from the Mageia main menu system in graphical desktops for ease of use by users unfamiliar with the command line. Usually found under Tools -> System Tools. It will ask for the root password. + +\fBIn automatic mode a log is kept at /var/log/remove-old-kernels.log. The log is limited to 1000 lines (up to a year) and will then start to remove the oldest entries whilst adding new ones. See the -l option to view the log. + +.SH DISPLAY + +.TP +\fB\The header bar. +This shows: +.br +The system release information. +.br +The number of kernels found in the /boot directory +.br +Whether the automatic mode is on or off. OFF is highlighted in red as a warning. +.br +The number of kernels to be kept per flavour. +.br +Whether in advanced mode. Not shown when OFF. e.g. Q:1 +.br +The configuration file in use. Not shown for the main configuration file. e.g. F:1 + +.TP +\fB\The list columns. +.br +Column 1 shows the number of kernels found of each flavour. +.br +Column 2 indicates whether the kernel will be kept or removed. +.br +Column 3 shows a key letter to indicate the reason for keeping. Run 'rok -h' for key. +.br +Column 4 shows the full kernel package name concerned. +.br +Column 5 shows the date and time that the kernel was installed. + +.SH CONFIGURATION + +\fBThe configuration file is /etc/remove-old-kernels.cfg which may be edited manually if desired. +.br +\fBThere are several options below which can also be used more conveniently to change settings in the configuration file +from the command line when run as root. +.br +.br +Several alternative configuration files may be added manually if desired. They must be named as follows: +.br +/etc/remove-old-kernels_N.cfg where N is a digit from 1 to 9. +.br +A template configuration file is provided containing default values which may be copied: +/usr/share/doc/remove-old-kernels/remove-old-kernels_N.cfg.template. +.br +To use a new alternative configuration file for the current run you can use the -f N option, or -F N to switch to it persistently. +NOTE that any changes like auto ON/OFF, or the number of kernels to keep, that are made while running an alternative configuration +will be saved to THAT configuration file. They will not affect the default 'main' configuration. +.br +To switch back to the original configuration use -F 0. + +.SH OPTIONS + +.TP +\fI\-h -?\fP help + +Displays the available options and a key to column 3 of the display. + +.TP +\fI\-n N\fP Set the number of kernels to keep. ONLY for the current run. + +This parameter sets the number of kernels to keep (this time) in interactive mode. It must be 2 or more, it's value may be restricted by the setting in etc/dnf/dnf.conf if dnf is installed, in which case there is an on-screen warning. dnf sets a default value of 3. + +.TP +\fI\-N N\fP Like -n but stores the 'number of kernels to keep' persistently in the config file. e.g. -N 4 + +It must be run as root to take effect. + +.TP +\fI\-a\fP automatic mode. Run once with no questions asked. + +Similar to the weekly cron job and will use settings from /etc/remove-old-kernels.cfg. +.br +It may be used with the -n N option if desired. NOTE: No output is sent to the log when run manually. + +.TP +\fI\-A [y|n]\fP Automatic mode ON/OFF switch. + +This switches the automatic weekly run ON (y) or OFF (n). +It directly edits /etc/remove-old-kernels.cfg, setting CRON=y or CRON=n so must be run as root to have any effect. + +.TP +\fI\-c\fP Special option for system automatic mode. This option is NOT intended for manual use. + +Checks if CRON=y is in /etc/remove-old-kernels.cfg before running, or exits. The output is logged to /var/log/remove-old-kernels.log. +It is run by /etc/cron.weekly/remove-old-kernels.cron which also trims the log to 1000 lines if it is greater. This equates to something over one year of use for basic systems. +See the -l option for viewing the log. + +.TP +\fI\-f N\fP Switch to an alternative configuration file. ONLY for the current run. + +N is any number from 1 to 9. Alternative configuration files need to be prepared in advance. + +.TP +\fI\-F N\fP Switch to an alternative configuration file. Persistently. (Must be root) + +N is any number from 1 to 9. Alternative configuration files need to be prepared in advance. + +.TP +\fI\-t\fP Test mode. + +A test mode where nothing is removed, to see what would be done. + +.TP +\fI\-p\fP Preview mode. + +Dry run showing the urpme commands that would be used. + +.TP +\fI\-q\fP Advanced mode, run once. + +An advanced mode (developed for Mageia QA testers). +.br +In addition to the regular mode, when ON this will also NOT remove: +.br +A kernel devel package of the same version as a corresponding installed kernel, unless the kernel is going to be removed as well. +.br +A kernel potentially needed by an installed virtualbox kernel latest. +.br +A kernel potentially needed by an installed xtables-addons kernel latest. + +.TP +\fI\-Q N\fP Advanced mode, persistent. OFF by default. +When ON, "Q:ON" is displayed near the right end of the header bar. + +N = 1 for enable, 0 to disable. Default disabled. + +.TP +\fI\-l N\fP Display the log file. (Only created by the weekly automatic runs) +.br +The last 1000 lines of the log are retained. If no log has yet been created then it will exit. + +.TP +\fI\-v\fP Show the version of the installed remove-old-kernels package. + +.SH EXAMPLES +\fBrok\fP +.br +A shorthand link to 'remove-old-kernels'. Run as root to remove kernels or change settings. + +\fBremove-old-kernels -n4\fP +.br +Remove old kernels interactively, this time, keeping 4 kernels of each flavour. + +\fBrok -l\fP +.br +Display the log file. + +.SH BUGS +None known. Report any issues with the program or documentation to https://bugs.mageia.org/ + +.SH AUTHOR +\fBremove-old-kernels is by Pierre Jarillon (2018-2021) Jean-Baptiste Biernacki (2021) Barry C Jackson (2022)\fP +This document is by Barry C Jackson <barjac@mageia.org>. diff --git a/remove-old-kernels.cfg b/remove-old-kernels.cfg new file mode 100644 index 0000000..ee2c56a --- /dev/null +++ b/remove-old-kernels.cfg @@ -0,0 +1,54 @@ +# remove-old-kernels.cfg + +# This is the main configuration file for 'remove-old-kernels' and must exist. + +# Installed location is /etc/remove-old-kernels.cfg + +# NOTE: Some of these settings may be changed by command line options, see the man page. + +# If dnf is installed then 'remove-old-kernels' will always +# leave at least the number of kernels set in /etc/dnf/dnf.conf +# which defaults to three. + +# Number of kernels of each flavour to keep - Must be 2 or greater. +NBK=3 + +# Handy info: https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors +# Colours for display Defaults Used for +Normal="\e[0m" +KeepCol="\e[92m" # Light Green Keep text +RemvCol="\e[91m" # Light Red Remove text +InfoCol="\e[33m" # Orange Information text +HdBgCol="\e[102;30m" # Light Green Background Heading background +WarnBgCol="\e[101m" # Light Red Background Warnings in heading +ClearLine="\r\e[2K" # Clear the line + +# Kernel types to test for removal - keep the same order i.e. kernel before -devel etc. +LISTK=\ +"kernel-desktop586 +kernel-desktop +kernel-desktop-devel +kernel-server +kernel-server-devel +kernel-source +kernel-tmb-desktop +kernel-tmb-desktop-devel +kernel-tmb-source +kernel-linus +kernel-linus-devel +kernel-linus-source +" + +# Allow cron to run 'remove-old-kernels' weekly. Replace 'y' with 'n' (lower case) to disable it. +CRON=y + +# Turn on the advanced mode. [0|1] (1 is ON) +QA=0 + +# Alternate config file to use, 0 is default (none). 1 to 9 are allowed which must be named as: +# /etc/remove-old-kernels_N.cfg (e.g. /etc/remove-old-kernels_3.cfg) +# To create an alternative .cfg file use a copy of the template here: +# /usr/share/doc/remove-old-kernels/remove-old-kernels_N.cfg.template +# Do not edit this line, use the -f or -F options which will validate that it exists. See man page. +ALTCFG=0 +# DO NOT include the above line in any alternative .cfg files! diff --git a/remove-old-kernels.cron b/remove-old-kernels.cron new file mode 100644 index 0000000..df583d8 --- /dev/null +++ b/remove-old-kernels.cron @@ -0,0 +1,18 @@ +#!/usr/bin/bash + +# cron job to remove old kernels +# this runs remove-old-kernels to remove old kernels according +# to the settings in /etc/remove-old-kernels.cfg + +if [[ -x /usr/sbin/remove-old-kernels ]]; then +# Trim log before starting remove-old-kernels with colours disabled + if [[ -f /var/log/remove-old-kernels.log ]]; then + keeplines=1000; fail="" + roktmplog=$(mktemp) + ( tail -n $keeplines /var/log/remove-old-kernels.log > $roktmplog && \ + cat $roktmplog > /var/log/remove-old-kernels.log && rm -f $roktmplog ) || fail="WARNING: log trim failed" + fi +echo -e "\n=========================== $(date +%d/%m/%Y-%H:%M) ===========================\n$fail" >> /var/log/remove-old-kernels.log +# Use -c option to check that CRON=y is in the cfg file before running in auto mode. + /usr/sbin/remove-old-kernels -c -m >> /var/log/remove-old-kernels.log +fi diff --git a/remove-old-kernels.desktop b/remove-old-kernels.desktop new file mode 100644 index 0000000..1288b93 --- /dev/null +++ b/remove-old-kernels.desktop @@ -0,0 +1,22 @@ +[Desktop Entry] +Comment=Removal tool for obsolete system kernels +Comment[en_GB]=Removal tool for obsolete system kernels +Exec=/usr/sbin/remove-old-kernels-pkexec +GenericName=Remove Old Kernels +GenericName[en_GB]=Remove Old Kernels +GenericName[fr]=Enlever les noyaux superflus +Icon=/usr/share/icons/hicolor/scalable/apps/remove-old-kernels.svg +MimeType= +Name=Remove Old Kernels +Name[en]=Remove Old Kernels +Name[en_GB]=Remove Old Kernels +Name[fr]=Enlever les noyaux superflus +StartupNotify=true +Terminal=true +Type=Application +Categories=System;Utility;X-Mageia-CrossDesktop; +X-DBUS-ServiceName= +X-DBUS-StartupType=none +X-KDE-SubstituteUID=false +X-KDE-Username= +X-KeepTerminal=false diff --git a/remove-old-kernels.svg b/remove-old-kernels.svg new file mode 100644 index 0000000..b848b03 --- /dev/null +++ b/remove-old-kernels.svg @@ -0,0 +1,337 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="32" + height="32" + id="svg5453" + version="1.1" + inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)" + sodipodi:docname="mageiawelcome.svg" + inkscape:export-filename="mgaonline48.png" + inkscape:export-xdpi="135" + inkscape:export-ydpi="135" + xml:space="preserve" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:dc="http://purl.org/dc/elements/1.1/"><defs + id="defs5455"><linearGradient + id="linearGradient4290" + inkscape:collect="always"><stop + id="stop4292" + offset="0" + style="stop-color:#7cbaf8;stop-opacity:1" /><stop + id="stop4294" + offset="1" + style="stop-color:#f4fcff;stop-opacity:1" /></linearGradient><linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4290" + id="linearGradient4194" + x1="398.57144" + y1="535.79797" + x2="398.57144" + y2="527.79797" + gradientUnits="userSpaceOnUse" /><linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4290" + id="linearGradient4175" + gradientUnits="userSpaceOnUse" + x1="398.57144" + y1="535.79797" + x2="398.57144" + y2="527.79797" /><linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4290" + id="linearGradient7775" + gradientUnits="userSpaceOnUse" + x1="398.57144" + y1="535.79797" + x2="398.57144" + y2="527.79797" /><linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4290" + id="linearGradient7777" + gradientUnits="userSpaceOnUse" + x1="398.57144" + y1="535.79797" + x2="398.57144" + y2="527.79797" /><linearGradient + inkscape:collect="always" + xlink:href="#linearGradient4290" + id="linearGradient7779" + gradientUnits="userSpaceOnUse" + x1="398.57144" + y1="535.79797" + x2="398.57144" + y2="527.79797" /></defs><sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:zoom="15.999999" + inkscape:cx="17.187501" + inkscape:cy="15.937501" + inkscape:document-units="px" + inkscape:current-layer="g4171" + showgrid="true" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" + inkscape:window-width="1280" + inkscape:window-height="959" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:showpageshadow="false" + borderlayer="true" + showguides="true" + inkscape:snap-midpoints="false" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1"><inkscape:grid + type="xygrid" + id="grid4063" /><sodipodi:guide + position="1.1650391e-05,32.000026" + orientation="32,0" + id="guide4157" + inkscape:locked="false" /><sodipodi:guide + position="1.1650391e-05,2.6367188e-05" + orientation="0,32" + id="guide4159" + inkscape:locked="false" /><sodipodi:guide + position="32.000012,2.6367188e-05" + orientation="-32,0" + id="guide4161" + inkscape:locked="false" /><sodipodi:guide + position="32.000012,32.000026" + orientation="0,-32" + id="guide4163" + inkscape:locked="false" /><sodipodi:guide + position="2.0000117,30.000026" + orientation="28,0" + id="guide4167" + inkscape:locked="false" /><sodipodi:guide + position="2.0000117,2.0000264" + orientation="0,28" + id="guide4169" + inkscape:locked="false" /><sodipodi:guide + position="30.000012,2.0000264" + orientation="-28,0" + id="guide4171" + inkscape:locked="false" /><sodipodi:guide + position="30.000012,30.000026" + orientation="0,-28" + id="guide4173" + inkscape:locked="false" /><sodipodi:guide + position="2.0000117,30.000026" + orientation="28,0" + id="guide4181" + inkscape:locked="false" /><sodipodi:guide + position="2.0000117,2.0000264" + orientation="0,14" + id="guide4183" + inkscape:locked="false" /><sodipodi:guide + position="16.771352,12.721507" + orientation="-28,0" + id="guide4185" + inkscape:locked="false" /><sodipodi:guide + position="16.000012,30.000026" + orientation="0,-14" + id="guide4187" + inkscape:locked="false" /><sodipodi:guide + position="9.0000117,23.000026" + orientation="14,0" + id="guide4193" + inkscape:locked="false" /><sodipodi:guide + position="9.0000117,9.0000264" + orientation="0,14.000031" + id="guide4195" + inkscape:locked="false" /><sodipodi:guide + position="23.000042,9.0000264" + orientation="-14,0" + id="guide4197" + inkscape:locked="false" /><sodipodi:guide + position="23.000042,23.000026" + orientation="0,-14.000031" + id="guide4199" + inkscape:locked="false" /></sodipodi:namedview><metadata + id="metadata5458"><rdf:RDF><cc:Work + rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /></cc:Work></rdf:RDF></metadata><g + inkscape:label="Capa 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(-384.57143,-515.798)"><g + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.5px;line-height:125%;font-family:'Clear Sans';-inkscape-font-specification:'Clear Sans Bold';letter-spacing:0px;word-spacing:0px;opacity:1;fill:url(#linearGradient4194);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + id="text4184"><g + id="g4171" + style="fill:url(#linearGradient4175);fill-opacity:1"><g + id="g996" + transform="matrix(0.15262653,0,0,0.16081363,384.87993,516.57173)" + style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12.5px;line-height:125%;font-family:'Clear Sans';-inkscape-font-specification:'Clear Sans Bold';letter-spacing:0px;word-spacing:0px;fill:url(#linearGradient7779);fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"><g + inkscape:label="Layer 1" + id="layer1-3" + style="fill:url(#linearGradient7775)"><rect + style="fill:#000000;stroke-width:0.264583" + id="rect970" + width="183.85124" + height="173.59367" + x="11.346816" + y="7.5816488" + ry="2.1122603" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect2012-9" + width="13.423958" + height="3.4610584" + x="164.3107" + y="31.344818" + ry="1.7305292" /><rect + style="fill:#ff0000;stroke-width:0.264583" + id="rect1809-62" + width="101.7161" + height="3.5737784" + x="56.477978" + y="70.711464" + ry="1.4358689" + rx="0" /><rect + style="fill:#ff0000;stroke-width:0.264583" + id="rect1809-35" + width="101.7161" + height="3.5737784" + x="56.513832" + y="64.224121" + ry="1.4358689" + rx="0" /><rect + style="fill:#ff0000;stroke-width:0.264583" + id="rect1809-5" + width="101.7161" + height="3.5737784" + x="56.626263" + y="57.83477" + ry="1.4358689" + rx="0" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect1809-7" + width="101.7161" + height="3.5737784" + x="56.835758" + y="51.083687" + ry="1.4358689" + rx="0" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect1809-6" + width="101.7161" + height="3.5737784" + x="56.679832" + y="44.480804" + ry="1.4358689" + rx="0" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect1809-3" + width="101.7161" + height="3.5737784" + x="56.633389" + y="37.959045" + ry="1.4358689" + rx="0" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect2012" + width="13.423958" + height="3.4610584" + x="37.35762" + y="31.250603" + ry="1.7305292" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect2012-1" + width="13.423958" + height="3.4610584" + x="37.538624" + y="38.143776" + ry="1.7305292" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect2012-2" + width="13.423958" + height="3.4610584" + x="37.703911" + y="44.413418" + ry="1.7305292" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect2012-1-7" + width="13.423958" + height="3.4610584" + x="37.748642" + y="51.306591" + ry="1.7305292" /><rect + style="fill:#ff0000;stroke-width:0.264583" + id="rect2012-0" + width="13.423958" + height="3.4610584" + x="37.784607" + y="57.461933" + ry="1.7305292" /><rect + style="fill:#ff0000;stroke-width:0.264583" + id="rect2012-1-9" + width="13.423958" + height="3.4610584" + x="37.787979" + y="63.980339" + ry="1.7305292" /><rect + style="fill:#ff0000;stroke-width:0.264583" + id="rect2012-1-9-3" + width="13.423958" + height="3.4610584" + x="37.851917" + y="70.556793" + ry="1.7305292" /><text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:105.941px;line-height:1.25;font-family:sans-serif;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.397278" + x="25.86445" + y="163.02611" + id="text2222" + transform="scale(1.004718,0.99530419)"><tspan + sodipodi:role="line" + id="tspan2220" + style="font-size:105.941px;fill:#ff0000;stroke-width:0.397278" + x="25.86445" + y="163.02611">K</tspan></text><text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:35.2778px;line-height:1.25;font-family:sans-serif;fill:#00ff00;fill-opacity:1;stroke:none;stroke-width:0.264583" + x="148.46155" + y="134.78926" + id="text2276"><tspan + sodipodi:role="line" + id="tspan2274" + style="font-size:35.2778px;fill:#00ff00;fill-opacity:1;stroke-width:0.264583" + x="148.46155" + y="134.78926">K</tspan></text><path + style="fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 90.378872,111.20479 55.839798,15.47269 -56.508459,16.6052 0.122513,-32.239 z" + id="path2332" /><path + style="fill:#ffff00;fill-opacity:1;stroke-width:0.314619" + d="m 89.98093,121.5599 v -15.73221 l 2.123676,0.58895 c 1.168024,0.32393 13.542994,3.74824 27.499934,7.60958 13.95695,3.86135 25.34945,7.04879 25.31667,7.0832 -0.0328,0.0344 -12.15998,3.61401 -26.94935,7.95466 -14.78937,4.34065 -27.137527,7.96768 -27.440345,8.06006 -0.519263,0.15842 -0.550585,-0.72693 -0.550585,-15.56424 z" + id="path2472" /></g><g + id="layer2" + inkscape:label="Layer 2" + style="fill:url(#linearGradient7777)"><rect + style="fill:#ffffff;stroke-width:0.246766" + id="rect1755" + width="57.971539" + height="3.7839279" + x="37.402649" + y="23.341612" + ry="1.8373547" /><rect + style="fill:#00ff00;stroke-width:0.264583" + id="rect1809" + width="101.7161" + height="3.5737784" + x="56.536282" + y="31.34889" + ry="1.4358689" + rx="0" /></g></g></g></g></g></svg> diff --git a/remove-old-kernels_N.cfg.template b/remove-old-kernels_N.cfg.template new file mode 100644 index 0000000..8e95d97 --- /dev/null +++ b/remove-old-kernels_N.cfg.template @@ -0,0 +1,48 @@ +# remove-old-kernels_N.cfg.template + +# NOTE: This is a default template to use for 'alternative' .cfg files +# All settings in here are the default as used in the main configuration file. + +#=========================================== +# This file may be copied as /etc/remove-old-kernels_N.cfg and edited as desired. +# N must only be a single digit from 1 to 9. +#=========================================== + +# If dnf is installed then 'remove-old-kernels' will always +# keep at least the number of kernels set in /etc/dnf/dnf.conf +# which defaults to three. + +# Number of kernels of each flavour to keep - Must be 2 or greater. +NBK=3 + +# Handy info: https://misc.flogisoft.com/bash/tip_colors_and_formatting#colors +# Colours for display Defaults Used for +Normal="\e[0m" +KeepCol="\e[92m" # Light Green Keep text +RemvCol="\e[91m" # Light Red Remove text +InfoCol="\e[33m" # Orange Information text +HdBgCol="\e[102;30m" # Light Green Background Heading background +WarnBgCol="\e[101m" # Light Red Background Warnings in heading +ClearLine="\r\e[2K" # Clear the line + +# Kernel types to test for removal - keep the same order i.e. kernels before -devel etc. or leave alone. +LISTK=\ +"kernel-desktop586 +kernel-desktop +kernel-desktop-devel +kernel-server +kernel-server-devel +kernel-source +kernel-tmb-desktop +kernel-tmb-desktop-devel +kernel-tmb-source +kernel-linus +kernel-linus-devel +kernel-linus-source +" + +# Allow cron to run 'remove-old-kernels' weekly. Replace 'y' with 'n' (lower case) to disable it. +CRON=y + +# Turn on the advanced mode. [0|1] (1 is ON) +QA=0 |