| 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 |
mkdir -p "$RUNDIR" |
| 21 |
|
| 22 |
touched=0 |
| 23 |
errored=0 |
| 24 |
|
| 25 |
while read -r tag p0 p1 p2 p3 p4 pp; do |
| 26 |
if [ "$tag" = 'status:' ] && [ "$p1" = 'unpacked' ]; then |
| 27 |
if [ "$touched" = 0 ]; then |
| 28 |
touch "$RUNDIR/unpacked" |
| 29 |
touched=1 |
| 30 |
fi |
| 31 |
else |
| 32 |
if [ "$tag" = 'status:' ] && \ |
| 33 |
[ "$p1" = ':' ] && \ |
| 34 |
[ "$p2" = 'error' ] && \ |
| 35 |
[ "$p3" = ':' ]; then |
| 36 |
if [ "$errored" = 0 ]; then |
| 37 |
touch "$RUNDIR/errored" |
| 38 |
errored=1 |
| 39 |
fi |
| 40 |
fi |
| 41 |
fi |
| 42 |
done |