Commit 04dd8c42 authored by Luc Didry's avatar Luc Didry

Use checkrestart if available for need-to-restart services

Checkrestart is faster than needrestart for that, so why not using it?
parent 354be0bc
......@@ -3,7 +3,7 @@
. /etc/update-motd.d/colors
if [[ -x /usr/sbin/needrestart ]]; then
n=$(DEBIAN_FRONTEND=noninteractive echo "" | needrestart -k -v -n 2>/dev/null | grep -c "Pending kernel upgrade\!")
n=$(DEBIAN_FRONTEND=noninteractive echo "" | /usr/sbin/needrestart -k -v -n 2>/dev/null | grep -c "Pending kernel upgrade\!")
if [[ $n -gt 0 ]]; then
printf $LIGHT_RED
printf " Pending kernel upgrade! "
......
......@@ -2,8 +2,19 @@
. /etc/update-motd.d/colors
if [[ -x /usr/sbin/needrestart ]]; then
n=$(needrestart -l -v -n -r l 2>/dev/null | grep -c "Skipping")
if [[ -x /usr/sbin/checkrestart ]]; then
n=$(/usr/sbin/checkrestart | grep "Found .* processes using old versions of upgraded files")
re='Found (.*) processes using old versions of upgraded files'
if [[ $n =~ $re ]]; then
if [[ ${BASH_REMATCH[1]} -gt 0 ]]; then
printf $LIGHT_RED
printf " %s services need to be restarted.\n" "${BASH_REMATCH[1]}"
printf $NONE
printf " Use needrestart to list and restart them.\n\n"
fi
fi
elif [[ -x /usr/sbin/needrestart ]]; then
n=$(/usr/sbin/needrestart -l -v -n -r l 2>/dev/null | grep -c "Skipping")
if [[ $n -gt 0 ]]; then
printf $LIGHT_RED
printf " %s services need to be restarted.\n" $n
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment