network: Only try to restart collectd if it is running

Message ID 20240119163658.805656-1-michael.tremer@ipfire.org
State Staged
Commit b87cd867f704a5dbe1f28f448176f8a29950d709
Headers
Series network: Only try to restart collectd if it is running |

Commit Message

Michael Tremer Jan. 19, 2024, 4:36 p.m. UTC
  This updated version of this script avoids any errors if collectd is not
running (yet) which might happen during the boot process.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/networking/red.up/60-collectd | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Patch

diff --git a/src/initscripts/networking/red.up/60-collectd b/src/initscripts/networking/red.up/60-collectd
index 0e457894f..a96543354 100644
--- a/src/initscripts/networking/red.up/60-collectd
+++ b/src/initscripts/networking/red.up/60-collectd
@@ -1,6 +1,8 @@ 
 #!/bin/bash
 
 # Restart collectd because the ping plugin does not re-resolve "gateway"
-exec /etc/init.d/collectd restart
+if pgrep collectd &>/dev/null; then
+	exec /etc/init.d/collectd restart &>/dev/null
+fi
 
-exit 1
+exit 0