Mageia Bugzilla – Attachment 13489 Details for
Bug 24403
Feature request : tool to remove old kernels
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
rok test script (qa)
remove-old-kernels-0.99.1_7 (text/plain), 12.12 KB, created by
Barry Jackson
on 2022-11-09 14:21:29 CET
(
hide
)
Description:
rok test script (qa)
Filename:
MIME Type:
Creator:
Barry Jackson
Created:
2022-11-09 14:21:29 CET
Size:
12.12 KB
patch
obsolete
>#!/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 - Tested on Mageia 5..8 ># (c) Jean-Baptiste Biernacki 2021 ># (c) Barry C Jackson 2022 ># For package version: 0.99.1-6 >#################################### ># ># Do not edit the values below unless you know exactly what you are doing, ># You can pass parameters on the command line ># to over-ride these. See 'man remove-old-kernels'. >NBK=3 # Default number of kernels to keep. >DEBUG=0 # 1 for debug/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 >QA=1 >USAGE=\ >"Usage: %s: [-a] [-A value] [-c] [-d|t] [-n value] [-N value] [-p] [-l] [-m] [-v] [-h|?] > -a = automatic, no questions. Interactive if not specified. (must be root) > -A value = y or n to allow automatic weekly removal of kernels (e.g. -Ay) (must be root) > -c = as automatic but also checks for CRON=y in the cfg file or exits (must be root) > -d or -t = Debug or test mode, nothing is removed, urpme is simulated > -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3 > -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5) > -p = show the urpme commands which would be used > -l = list the last 100 lines of the log > -m = no colours in screen output > -v = version > -? or -h = show this help. >Old kernels are removed safely and cleanly using urpme.\n >" ># Colors >Normal="\e[0m" >Green="\e[92m" # Light Green >Red="\e[91m" # Light Red >Orange="\e[33m" >GrBg="\e[102;30m" # Light Green Background >RdBg="\e[101m" # Light Red Background >ClearLine="\r\e[2K" # Clear the line > >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 >" > ># Source cfg file if it exists, or issue warning and abort. >. /etc/remove-old-kernels.cfg || { echo -e "${Red}FATAL: Failed to read /etc/remove-old-kernels.cfg"; exit 1; } > ># Check for CRON variable in config or add default. (Some users may have early version without this feature) >if ! grep -q -e "CRON=" /etc/remove-old-kernels.cfg; then > echo -e "\n# This allows cron to run 'remove-old-kernels'. Replace 'y' with 'n' (lower case) to disable it.\nCRON=y" >> /etc/remove-old-kernels.cfg >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) > ># Parse arguments from command line which take precedence over script and cfg file >if [[ ${#} -gt 0 ]] ; then > while getopts aA:cdtplmvn:N:?h NAME ; do > case ${NAME} in > a) MODE="A" > ;; > A) CRONN=${OPTARG} && [[ ${#CRONN} = 1 ]] && [[ "yn" =~ "$CRONN" ]] && \ > [[ $UID -eq 0 ]] && sed -i "s/CRON=.*/CRON=$CRONN/" /etc/remove-old-kernels.cfg && \ > CRON=$CRONN > ;; > c) MODE="A" && [[ ${#CRON} -gt 0 ]] && [[ "$CRON" == "y" ]] || exit 0 > ;; > d|t) DEBUG=1 # why two options here? > ;; > p) VISU=1 > ;; > n) [[ ${OPTARG} =~ ^[0-9]+$ ]] && NBK=${OPTARG} > ;; > N) NBKN=${OPTARG} > if [[ $NBKN =~ ^[0-9]+$ ]] && [[ $NBKN -ge $dnfNBK ]]; then > if [[ $UID -eq 0 ]]; then > sed -i "s/NBK=.*/NBK=$NBKN/" /etc/remove-old-kernels.cfg && NBK=$NBKN > else > echo -e "${Red}Must be root to edit config${Normal}" && { echo -e "\nHit spacebar\n"; read -n1; echo -en "${ClearLine}"; } > fi > else > dnfmsg=true > fi > ;; > l) tail -n1000 /var/log/remove-old-kernels.log && { echo -e "\nHit spacebar\n"; read -n1; echo -en "${ClearLine}"; } > ;; > m) Normal="";Red="";Green="";Orange="";GrBg="";RdBg="";Clearline="" > ;; > v) printf "$(rpm -q remove-old-kernels)\n" > exit 2 > ;; > ?|h) printf "${USAGE}" ${0} > exit 2 > ;; > esac > done > if (( NBK < 2 )); then > NBK=2 # Unsafe if less > fi >fi > ># Only use greeting in interactive mode >if [[ $MODE == "I" ]]; then >clear >echo -e " *** Welcome to 'remove-old-kernels' Interactive ***\n" >fi > ># Use dnf kernel 'number to keep' if installed >if [[ $dnfNBK -gt $NBK ]] || $dnfmsg; then > NBK=$dnfNBK > echo -e "${Orange}INFO: Number to keep has been 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}${RdBg}OFF${GrBg}"; 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 "${Red}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 }') > >#========================= 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 "${GrBg} System: $(cat /etc/mageia-release) | Kernels in /boot/: ${NK} | AUTO: $autostat | KEEP: $NBK ${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 > kern_rel=asdfg; return #return garbage so not empty >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 ]] && qakern="$kern_ver-$kern_rel" >} > ># Exclude 'latest' >rpmqaList=$(echo "$allkernels"|grep -v latest) > ># Loop through kernel types in LISTK >for kernelType in ${LISTK}; do > [[ $QA -eq 1 ]] && get_vbox_kern > echo -ne "${ClearLine}" > echo -ne "\r ==> ${kernelType}" > export n=0; > installedKernelCounter=0; ># Scan through installed kernels to match with kernel type in LISTK > echo "$rpmqaList"|grep "${kernelType}-[0-9]"|while read installedKernel; do ># Increment installed kernel counter > installedKernelCounter=$((${installedKernelCounter} + 1)) > #Return to the line if there exists at least one installedKernel of this kernelType > if [[ ${installedKernelCounter} -eq 1 ]] ; then echo "" ; fi > installedKernelPackage=$(echo ${installedKernel} | cut -d ' ' -f 1 ) > > if [[ $(echo ${installedKernel} | grep ${CURK} | wc -l ) -eq 1 ]] ; then > NOTA="In use now " # current kernel > REMVBL=0 # not removable > elif [[ $QA -eq 1 ]] && [[ $(echo ${installedKernel} | grep "$qakern" | wc -l ) -eq 1 ]] ; then > NOTA="(vbox)" # Required by VBox > REMVBL=0 # not removable > else > NOTA="" # not currently used > REMVBL=1 # is removable > fi > > if [[ ${installedKernelCounter} -gt $NBK ]] ; then > if [[ ${REMVBL} -ne 1 ]] ; then > echo -e "\r ${installedKernelCounter} : keep : ${Green}${installedKernel} ${Normal}${NOTA}" > else > echo -e "\r ${installedKernelCounter} : remove : ${Red}${installedKernel} ${Normal}${NOTA}" > echo ${installedKernelPackage} >>${TMPKTR} > fi > else > echo -e "\r ${installedKernelCounter} : keep : ${Green}${installedKernel} ${Normal}${NOTA}" > fi > done >done > >echo -e "${ClearLine}" > >#================================= Mode of execution =================== > >nbt=$(cat ${TMPKTR} | wc -l) >if [[ ${nbt} -ne 0 ]] ; then > if [[ $(id -u) -ne 0 ]] ; then > echo -e "${Red}Must be root to allow removal\n${Normal}" > fi > if [[ ${VISU} -eq 1 ]]; then > plural="s"; [[ ${nbt} -eq 1 ]] && plural="" > echo "Command${plural} that would be used:" > for f in $(tac ${TMPKTR}); do > echo "urpme ${f}" > done > echo -e "\nHit spacebar to exit" > read -n1 > echo -en "${ClearLine}" > exit 0 > fi > > if [[ ${MODE} != "A" ]] ; then > if [[ ${DEBUG} -eq 1 ]] ; then > echo -e "\n${Green}>> Debug/test mode is on - kernels won't be removed <<${Normal}" > fi > plural="s"; [[ ${nbt} -eq 1 ]] && plural="" > read -p "Remove ${nbt} kernel${plural} ? 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 " interactive" > ;; > *) > echo -e "\nAborted\n" > rm -f ${TMPKTR} > exit 0 > ;; > esac > fi > >#================================= Execution =========================== > > for installedKernelPackage in $(tac ${TMPKTR}) ; do > if [[ ${MODE} = "I" ]] ; then # --- interactive mode --- > read -p "Remove ${installedKernelPackage} ? y/N/q (q=quit/abort) " -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${Orange}DEBUG: Could execute: urpme ${AUTO} ${installedKernelPackage}${Normal}" > nbt=$((${nbt} - 1)) > else > urpme ${installedKernelPackage} > nbt=$((${nbt} - 1)) > fi > ;; > [qQ]) > echo -e "\nAborted" > rm -f ${TMPKTR}; > exit 0 > ;; > *) > echo " " > ;; > esac > else # --- automatic mode --- > if [[ ${DEBUG} -eq 1 ]] ; then > echo -e "${Orange}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 "${GrBg} Gain : $((OCCDISK1 - OCCDISK2)) MB - Kernels in /boot/: ${NK} ${Normal}" >fi > >[[ $MODE == "I" ]] && { echo -e "Hit spacebar to exit\n"; read -n1; echo -en "${ClearLine}"; } > >rm -f ${TMPKTR} > ># Run again if some removable kernels are left >[ $(id -u) -ne 0 ] && exit 0 # Normal 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
#!/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 - Tested on Mageia 5..8 # (c) Jean-Baptiste Biernacki 2021 # (c) Barry C Jackson 2022 # For package version: 0.99.1-6 #################################### # # Do not edit the values below unless you know exactly what you are doing, # You can pass parameters on the command line # to over-ride these. See 'man remove-old-kernels'. NBK=3 # Default number of kernels to keep. DEBUG=0 # 1 for debug/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 QA=1 USAGE=\ "Usage: %s: [-a] [-A value] [-c] [-d|t] [-n value] [-N value] [-p] [-l] [-m] [-v] [-h|?] -a = automatic, no questions. Interactive if not specified. (must be root) -A value = y or n to allow automatic weekly removal of kernels (e.g. -Ay) (must be root) -c = as automatic but also checks for CRON=y in the cfg file or exits (must be root) -d or -t = Debug or test mode, nothing is removed, urpme is simulated -n value = number of kernels to keep this time only. (-n5 or -n 5 keep 5 kernels), Min=2, Default=3 -N value = number of kernels to keep. This changes the config file setting. (e.g. -N 5) -p = show the urpme commands which would be used -l = list the last 100 lines of the log -m = no colours in screen output -v = version -? or -h = show this help. Old kernels are removed safely and cleanly using urpme.\n " # Colors Normal="\e[0m" Green="\e[92m" # Light Green Red="\e[91m" # Light Red Orange="\e[33m" GrBg="\e[102;30m" # Light Green Background RdBg="\e[101m" # Light Red Background ClearLine="\r\e[2K" # Clear the line 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 " # Source cfg file if it exists, or issue warning and abort. . /etc/remove-old-kernels.cfg || { echo -e "${Red}FATAL: Failed to read /etc/remove-old-kernels.cfg"; exit 1; } # Check for CRON variable in config or add default. (Some users may have early version without this feature) if ! grep -q -e "CRON=" /etc/remove-old-kernels.cfg; then echo -e "\n# This allows cron to run 'remove-old-kernels'. Replace 'y' with 'n' (lower case) to disable it.\nCRON=y" >> /etc/remove-old-kernels.cfg 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) # Parse arguments from command line which take precedence over script and cfg file if [[ ${#} -gt 0 ]] ; then while getopts aA:cdtplmvn:N:?h NAME ; do case ${NAME} in a) MODE="A" ;; A) CRONN=${OPTARG} && [[ ${#CRONN} = 1 ]] && [[ "yn" =~ "$CRONN" ]] && \ [[ $UID -eq 0 ]] && sed -i "s/CRON=.*/CRON=$CRONN/" /etc/remove-old-kernels.cfg && \ CRON=$CRONN ;; c) MODE="A" && [[ ${#CRON} -gt 0 ]] && [[ "$CRON" == "y" ]] || exit 0 ;; d|t) DEBUG=1 # why two options here? ;; p) VISU=1 ;; n) [[ ${OPTARG} =~ ^[0-9]+$ ]] && NBK=${OPTARG} ;; N) NBKN=${OPTARG} if [[ $NBKN =~ ^[0-9]+$ ]] && [[ $NBKN -ge $dnfNBK ]]; then if [[ $UID -eq 0 ]]; then sed -i "s/NBK=.*/NBK=$NBKN/" /etc/remove-old-kernels.cfg && NBK=$NBKN else echo -e "${Red}Must be root to edit config${Normal}" && { echo -e "\nHit spacebar\n"; read -n1; echo -en "${ClearLine}"; } fi else dnfmsg=true fi ;; l) tail -n1000 /var/log/remove-old-kernels.log && { echo -e "\nHit spacebar\n"; read -n1; echo -en "${ClearLine}"; } ;; m) Normal="";Red="";Green="";Orange="";GrBg="";RdBg="";Clearline="" ;; v) printf "$(rpm -q remove-old-kernels)\n" exit 2 ;; ?|h) printf "${USAGE}" ${0} exit 2 ;; esac done if (( NBK < 2 )); then NBK=2 # Unsafe if less fi fi # Only use greeting in interactive mode if [[ $MODE == "I" ]]; then clear echo -e " *** Welcome to 'remove-old-kernels' Interactive ***\n" fi # Use dnf kernel 'number to keep' if installed if [[ $dnfNBK -gt $NBK ]] || $dnfmsg; then NBK=$dnfNBK echo -e "${Orange}INFO: Number to keep has been 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}${RdBg}OFF${GrBg}"; 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 "${Red}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 }') #========================= 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 "${GrBg} System: $(cat /etc/mageia-release) | Kernels in /boot/: ${NK} | AUTO: $autostat | KEEP: $NBK ${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 kern_rel=asdfg; return #return garbage so not empty 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 ]] && qakern="$kern_ver-$kern_rel" } # Exclude 'latest' rpmqaList=$(echo "$allkernels"|grep -v latest) # Loop through kernel types in LISTK for kernelType in ${LISTK}; do [[ $QA -eq 1 ]] && get_vbox_kern echo -ne "${ClearLine}" echo -ne "\r ==> ${kernelType}" export n=0; installedKernelCounter=0; # Scan through installed kernels to match with kernel type in LISTK echo "$rpmqaList"|grep "${kernelType}-[0-9]"|while read installedKernel; do # Increment installed kernel counter installedKernelCounter=$((${installedKernelCounter} + 1)) #Return to the line if there exists at least one installedKernel of this kernelType if [[ ${installedKernelCounter} -eq 1 ]] ; then echo "" ; fi installedKernelPackage=$(echo ${installedKernel} | cut -d ' ' -f 1 ) if [[ $(echo ${installedKernel} | grep ${CURK} | wc -l ) -eq 1 ]] ; then NOTA="In use now " # current kernel REMVBL=0 # not removable elif [[ $QA -eq 1 ]] && [[ $(echo ${installedKernel} | grep "$qakern" | wc -l ) -eq 1 ]] ; then NOTA="(vbox)" # Required by VBox REMVBL=0 # not removable else NOTA="" # not currently used REMVBL=1 # is removable fi if [[ ${installedKernelCounter} -gt $NBK ]] ; then if [[ ${REMVBL} -ne 1 ]] ; then echo -e "\r ${installedKernelCounter} : keep : ${Green}${installedKernel} ${Normal}${NOTA}" else echo -e "\r ${installedKernelCounter} : remove : ${Red}${installedKernel} ${Normal}${NOTA}" echo ${installedKernelPackage} >>${TMPKTR} fi else echo -e "\r ${installedKernelCounter} : keep : ${Green}${installedKernel} ${Normal}${NOTA}" fi done done echo -e "${ClearLine}" #================================= Mode of execution =================== nbt=$(cat ${TMPKTR} | wc -l) if [[ ${nbt} -ne 0 ]] ; then if [[ $(id -u) -ne 0 ]] ; then echo -e "${Red}Must be root to allow removal\n${Normal}" fi if [[ ${VISU} -eq 1 ]]; then plural="s"; [[ ${nbt} -eq 1 ]] && plural="" echo "Command${plural} that would be used:" for f in $(tac ${TMPKTR}); do echo "urpme ${f}" done echo -e "\nHit spacebar to exit" read -n1 echo -en "${ClearLine}" exit 0 fi if [[ ${MODE} != "A" ]] ; then if [[ ${DEBUG} -eq 1 ]] ; then echo -e "\n${Green}>> Debug/test mode is on - kernels won't be removed <<${Normal}" fi plural="s"; [[ ${nbt} -eq 1 ]] && plural="" read -p "Remove ${nbt} kernel${plural} ? 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 " interactive" ;; *) echo -e "\nAborted\n" rm -f ${TMPKTR} exit 0 ;; esac fi #================================= Execution =========================== for installedKernelPackage in $(tac ${TMPKTR}) ; do if [[ ${MODE} = "I" ]] ; then # --- interactive mode --- read -p "Remove ${installedKernelPackage} ? y/N/q (q=quit/abort) " -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${Orange}DEBUG: Could execute: urpme ${AUTO} ${installedKernelPackage}${Normal}" nbt=$((${nbt} - 1)) else urpme ${installedKernelPackage} nbt=$((${nbt} - 1)) fi ;; [qQ]) echo -e "\nAborted" rm -f ${TMPKTR}; exit 0 ;; *) echo " " ;; esac else # --- automatic mode --- if [[ ${DEBUG} -eq 1 ]] ; then echo -e "${Orange}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 "${GrBg} Gain : $((OCCDISK1 - OCCDISK2)) MB - Kernels in /boot/: ${NK} ${Normal}" fi [[ $MODE == "I" ]] && { echo -e "Hit spacebar to exit\n"; read -n1; echo -en "${ClearLine}"; } rm -f ${TMPKTR} # Run again if some removable kernels are left [ $(id -u) -ne 0 ] && exit 0 # Normal 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
View Attachment As Raw
Actions:
View
Attachments on
bug 24403
:
10776
|
10860
|
12482
|
13031
|
13107
|
13236
|
13403
|
13467
| 13489 |
13490
|
13491
|
13505