summaryrefslogtreecommitdiff
path: root/nonsystemd/networkmanager-openrc/10-openrc-status
diff options
context:
space:
mode:
authorDavid P <megver83@parabola.nu>2022-07-18 22:40:04 -0400
committerDavid P <megver83@parabola.nu>2022-07-18 22:40:04 -0400
commitc92203b32e1e69c76a3939d4a5d71c0e7254e655 (patch)
tree168222582a549b67e4f500e0894f239cd70712d5 /nonsystemd/networkmanager-openrc/10-openrc-status
parent905728e4e1fdc1db2d09a97e0b94ab7fb59b4369 (diff)
downloadabslibre-c92203b32e1e69c76a3939d4a5d71c0e7254e655.tar.gz
abslibre-c92203b32e1e69c76a3939d4a5d71c0e7254e655.tar.bz2
abslibre-c92203b32e1e69c76a3939d4a5d71c0e7254e655.zip
addpkg: nonsystemd/networkmanager-openrc 20210505-6
Signed-off-by: David P <megver83@parabola.nu>
Diffstat (limited to 'nonsystemd/networkmanager-openrc/10-openrc-status')
-rw-r--r--nonsystemd/networkmanager-openrc/10-openrc-status36
1 files changed, 36 insertions, 0 deletions
diff --git a/nonsystemd/networkmanager-openrc/10-openrc-status b/nonsystemd/networkmanager-openrc/10-openrc-status
new file mode 100644
index 000000000..f04658621
--- /dev/null
+++ b/nonsystemd/networkmanager-openrc/10-openrc-status
@@ -0,0 +1,36 @@
+#!/bin/sh
+# Copyright (c) 2012 Alexandre Rostovtsev
+# Released under the 2-clause BSD license.
+
+# Ensures that the NetworkManager OpenRC service is marked as started and
+# providing net only when it has a successful connection.
+
+if [ ! -e "/run/openrc/softlevel" ]; then
+ # OpenRC is not running
+ exit 0
+fi
+
+# Ensure rc-service is in PATH
+PATH="${PATH}:/usr/bin:/usr/sbin"
+
+# Exit if the NetworkManager OpenRC service is not running
+rc-service NetworkManager status 2>&1 | grep -Eq "status: (starting|started|inactive|stopping)" || exit 0
+
+# Call rc-service in background mode so that the start/stop functions update
+# NetworkManager service status to started or inactive instead of actually
+# starting or stopping the daemon
+
+export IN_BACKGROUND=YES
+
+case "$2" in
+ up) nm-online -t 0 -x &&
+ ! rc-service NetworkManager status 2>&1 | grep -q started &&
+ exec rc-service NetworkManager start ;;
+ down) nm-online -t 0 -x ||
+ rc-service NetworkManager status 2>&1 | grep -q stopped ||
+ exec rc-service NetworkManager stop ;;
+ pre-sleep) rc-service NetworkManager status 2>&1 | grep -q stopped ||
+ exec rc-service NetworkManager stop ;;
+esac
+exit 0
+# vim: set ts=4: