| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# needrestart - Restart daemons after library updates. |
| 4 |
# |
| 5 |
# Authors: |
| 6 |
# Thomas Liske <[email protected]> |
| 7 |
# |
| 8 |
# Copyright Holder: |
| 9 |
# 2013 - 2025 (C) Thomas Liske <[email protected]> |
| 10 |
# |
| 11 |
# License: |
| 12 |
# This program is free software; you can redistribute it and/or modify |
| 13 |
# it under the terms of the GNU General Public License as published by |
| 14 |
# the Free Software Foundation; either version 2 of the License, or |
| 15 |
# (at your option) any later version. |
| 16 |
# |
| 17 |
|
| 18 |
# Use /usr/bin/mail to notify a user via e-mail. |
| 19 |
|
| 20 |
MAILX='/usr/bin/mail' |
| 21 |
test -x "$MAILX" || exit 1 |
| 22 |
|
| 23 |
. /usr/lib/needrestart/notify.d.sh |
| 24 |
|
| 25 |
if [ "$NR_NOTIFYD_DISABLE_MAIL" = '1' ]; then |
| 26 |
echo "[$0] disabled in global config" 1>&2 |
| 27 |
exit 1 |
| 28 |
fi |
| 29 |
|
| 30 |
# Skip system users |
| 31 |
NR_USERID=$(id -u "$NR_USERNAME") |
| 32 |
if [ "0$NR_USERID" -gt 0 ] && [ "0$NR_USERID" -lt 1000 ]; then |
| 33 |
echo "[$0] do not notify system-user $NR_USERNAME via mail" 1>&2 |
| 34 |
exit 1 |
| 35 |
fi |
| 36 |
|
| 37 |
echo "[$0] notify user $NR_USERNAME on $NR_SESSION via mail" 1>&2 |
| 38 |
|
| 39 |
{ |
| 40 |
_NR_FQDN=$(hostname -f) |
| 41 |
eval_gettext 'Your session on host $_NR_FQDN ($NR_SESSION) is running obsolete binaries or libraries as listed below.' |
| 42 |
echo |
| 43 |
echo |
| 44 |
gettext "Please consider a relogin or restart of the affected processes!" |
| 45 |
echo |
| 46 |
echo |
| 47 |
cat |
| 48 |
} | fold -s -w 72 | "$MAILX" -s "Relogin or restarts on host $(hostname) required!" "$NR_USERNAME" |