meta données pour cette page
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
schplurtziel:menageatator [2017/02/17 06:50] ztrulphcs créée |
schplurtziel:menageatator [2020/12/28 08:09] (Version actuelle) ztrulphcs [Utilisation / Usage] présentation |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Menageatator ====== | ====== Menageatator ====== | ||
- | 2017-02-17 | + | 2017-10-26 |
<WRAP column 45%> | <WRAP column 45%> | ||
Ligne 15: | Ligne 15: | ||
<WRAP column 45%> | <WRAP column 45%> | ||
- | On pourrait croire que le problème est réglé depuis longtemps, mais, de temps en temps pour des raisons bizarres, je tombe toujours sur des ordinaeurs | + | On pourrait croire que le problème est réglé depuis longtemps, mais, de temps en temps pour des raisons bizarres, je tombe toujours sur des ordinateurs |
- | Le script ci dessous est très simple, mais aussi très efficace. il considère que tous les noyaux installés sont effaceables | + | Le script ci dessous est très simple, mais aussi très efficace. il considère que tous les noyaux installés sont effaçables |
* le noyaux utilisé | * le noyaux utilisé | ||
* les noyaux provenant de paquet //on hold// | * les noyaux provenant de paquet //on hold// | ||
* le dernier | * le dernier | ||
* l' | * l' | ||
+ | * les noyaux à moitié installé ou cassés | ||
Il conservera donc au moins deux noyaux, dont le dernier et celui en cours. | Il conservera donc au moins deux noyaux, dont le dernier et celui en cours. | ||
Ligne 36: | Ligne 37: | ||
* the most recent one | * the most recent one | ||
* the last but one when the current kernel is the most recent one | * the last but one when the current kernel is the most recent one | ||
+ | * half installed or broken kernels | ||
It keeps at least two kernels : the running one and, apart from this, the most recent. | It keeps at least two kernels : the running one and, apart from this, the most recent. | ||
Ligne 45: | Ligne 47: | ||
<code bash menageatator> | <code bash menageatator> | ||
- | #! /bin/sh | + | #! /bin/bash |
# encoding: utf-8 | # encoding: utf-8 | ||
# vim: se ts=2 sw=2 et: | # vim: se ts=2 sw=2 et: | ||
# menageatator: | # menageatator: | ||
+ | # http:// | ||
# | # | ||
- | # Copyright Schplurtz Le Déboulonné, | + | # |
# | # | ||
# Schplurtz le Déboulonné < | # Schplurtz le Déboulonné < | ||
Ligne 115: | Ligne 118: | ||
# les termes. | # les termes. | ||
- | # Yeah I know. Could use ruby/ | + | # Yeah I know. Could use ruby/ |
- | # Could use array, associative arrays etc... Just prefering simplicity | + | # Could use array, associative arrays etc... Just prefering simplicity, |
# clarity and possibility to run with dumb^Wsimple shells. | # clarity and possibility to run with dumb^Wsimple shells. | ||
Ligne 131: | Ligne 134: | ||
IFS=" | IFS=" | ||
" | " | ||
+ | # /sbin and /usr/sbin are usually not in cron PATH. add them | ||
+ | # if they' | ||
+ | case " | ||
+ | (*:/ | ||
+ | (*) PATH=" | ||
+ | esac | ||
+ | case " | ||
+ | (*:/ | ||
+ | (*) PATH=" | ||
+ | esac | ||
+ | |||
set -e # Stop on any error. | set -e # Stop on any error. | ||
Ligne 138: | Ligne 152: | ||
no_suffix() { | no_suffix() { | ||
sed -e ' | sed -e ' | ||
+ | } | ||
+ | |||
+ | reject() { | ||
+ | grep -v " | ||
} | } | ||
Ligne 148: | Ligne 166: | ||
# ii linux-image-3.13.0-95-generic | # ii linux-image-3.13.0-95-generic | ||
# ii linux-image-3.13.0-98-generic | # ii linux-image-3.13.0-98-generic | ||
- | dpkg-query -W -f '${db:Status-Abbrev} ${package}\n' | + | |
+ | # old dpkg-query (from ubuntu 12.04 lucid for example) don't support | ||
+ | # ${db: | ||
+ | # We have to convert things like " | ||
+ | # "rc " | ||
+ | # examples : | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # hold ok installed linux-image-3.2.0-23-generic | ||
+ | # The sed script does this : | ||
+ | # | ||
+ | # 2) replace the first 3 word by their initials in changing order | ||
+ | # fe " | ||
+ | # 3) in 3rd column, replace " | ||
+ | # Also we are not interested in uninstalled kernels, so we filter | ||
+ | # out the kernels that dpkg has never touched : /^un / | ||
+ | |||
+ | | ||
+ | sed -e ' | ||
+ | s/^\(.\)[^ ]* *\(.\)[^ ]* *\(.\)[^ ]* */\1\3\2 / | ||
+ | s/ | ||
+ | ' | ||
+ | reject '^un ' | ||
sort -k 2,2V # always return list sorted by version number | sort -k 2,2V # always return list sorted by version number | ||
- | } | ||
- | |||
- | reject() { | ||
- | grep -v " | ||
} | } | ||
Ligne 160: | Ligne 197: | ||
apt-get " | apt-get " | ||
} | } | ||
+ | ARGV=( " | ||
linux_vers_tpl=' | linux_vers_tpl=' | ||
Ligne 165: | Ligne 203: | ||
linux_images_extra_tpl=" | linux_images_extra_tpl=" | ||
| | ||
+ | | ||
# list of all linux-image packages dpkg is aware of | # list of all linux-image packages dpkg is aware of | ||
Ligne 238: | Ligne 277: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | | + | " |
+ | | ||
reject " | reject " | ||
awk '{ print $2 }' | awk '{ print $2 }' | ||
Ligne 245: | Ligne 285: | ||
# If there are kernels to remove, remove them | # If there are kernels to remove, remove them | ||
- | { test $# -gt 0 && _apt_get purge " | + | { test $# -gt 0 && _apt_get |
# Given this list of kernel, | # Given this list of kernel, | ||
Ligne 259: | Ligne 299: | ||
# performs these removal : | # performs these removal : | ||
# apt-get purge linux-image-3.13.0-93-generic linux-image-3.13.0-96-generic linux-image-3.13.0-98-generic linux-image-3.13.0-100-generic linux-image-3.13.0-101-generic | # apt-get purge linux-image-3.13.0-93-generic linux-image-3.13.0-96-generic linux-image-3.13.0-98-generic linux-image-3.13.0-100-generic linux-image-3.13.0-101-generic | ||
+ | </ | ||
+ | |||
+ | ===== Utilisation / Usage ===== | ||
+ | |||
+ | < | ||
+ | sudo menageatator | ||
+ | </ | ||
+ | <WRAP clear></ | ||
+ | |||
+ | ----- | ||
+ | |||
+ | <WRAP column 45%> | ||
+ | Si vous êtes brave et ne voulez pas confirmer les choix de menageatator | ||
+ | </ | ||
+ | <WRAP column 45%> | ||
+ | If you are brave and don't want to confirm menageatator choices | ||
+ | </ | ||
+ | |||
+ | <WRAP clear/> | ||
+ | < | ||
+ | sudo menageatator -y | ||
</ | </ |