3 # Copyright © 2012 Nick Bowler
5 # Prunes directories in /lib/modules that do not correspond to any kernel
6 # version in /boot. If the -f option is not specified, only print out what
9 # License WTFPL2: Do What The Fuck You Want To Public License, version 2.
10 # This is free software: you are free to do what the fuck you want to.
11 # There is NO WARRANTY, to the extent permitted by law.
15 while getopts 'fv' opt $@; do
23 [[ force = yes ]] || verbose=yes
26 kernbase=$boot/vmlinuz-
27 kernels=($kernbase*(N))
29 if ! [[ $#kernels -ge 1 ]]; then
30 printf '%s: no kernels found in %s, aborting\n' "$0" "$boot"
35 for v in ${${kernels%.old}#$kernbase}; do
40 for d in $modbase/*; do
42 if $kernmap[$v] :; then
43 [[ $verbose = yes ]] && printf '%s\n' "$d"
44 [[ $force = yes ]] && rm -rf "$d"