| 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 |
RUNDIR=/run/needrestart |
| 19 |
|
| 20 |
# dpkg had an error... exit (silently) |
| 21 |
if [ -e "$RUNDIR/errored" ]; then |
| 22 |
[ -e "$RUNDIR/unpacked" ] && echo "needrestart is being skipped since dpkg has failed" |
| 23 |
rm -f "$RUNDIR/errored" |
| 24 |
exit 0 |
| 25 |
fi |
| 26 |
|
| 27 |
if [ -e "$RUNDIR/unpacked" ]; then |
| 28 |
# check if system is shutting down, see also Debian Bug#914753 |
| 29 |
if [ -d '/run/systemd/system' ]; then |
| 30 |
sd=$(dbus-send --system --dest=org.freedesktop.login1 \ |
| 31 |
--print-reply \ |
| 32 |
/org/freedesktop/login1 \ |
| 33 |
org.freedesktop.DBus.Properties.Get \ |
| 34 |
string:org.freedesktop.login1.Manager \ |
| 35 |
string:PreparingForShutdown 2> /dev/null) |
| 36 |
|
| 37 |
if [ "$sd" != "${sd% true}" ]; then |
| 38 |
echo "skipping needrestart since system is preparing for shutdown" |
| 39 |
exit 0 |
| 40 |
fi |
| 41 |
fi |
| 42 |
|
| 43 |
if [ -n "$NEEDRESTART_SUSPEND" ]; then |
| 44 |
echo "packages have been installed but needrestart is suspended" |
| 45 |
exit 0 |
| 46 |
fi |
| 47 |
|
| 48 |
rm -f "$RUNDIR/unpacked" |
| 49 |
exec /usr/sbin/needrestart "$@" |
| 50 |
fi |