summaryrefslogtreecommitdiff
path: root/user/networkmanager/10-openrc-status
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-10 07:42:39 +0000
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-05-10 07:42:39 +0000
commit3414b29fd004f414436615878c67169c0a475d69 (patch)
tree23fafff6d83690f2b80b1a921007ae187f973d50 /user/networkmanager/10-openrc-status
parentc19e6e14e481d80cb91b9e76719ba63326c847d5 (diff)
downloadpackages-3414b29fd004f414436615878c67169c0a475d69.tar.gz
packages-3414b29fd004f414436615878c67169c0a475d69.tar.bz2
packages-3414b29fd004f414436615878c67169c0a475d69.tar.xz
packages-3414b29fd004f414436615878c67169c0a475d69.zip
user/networkmanager: new package
Diffstat (limited to 'user/networkmanager/10-openrc-status')
-rw-r--r--user/networkmanager/10-openrc-status35
1 files changed, 35 insertions, 0 deletions
diff --git a/user/networkmanager/10-openrc-status b/user/networkmanager/10-openrc-status
new file mode 100644
index 000000000..06b22bd77
--- /dev/null
+++ b/user/networkmanager/10-openrc-status
@@ -0,0 +1,35 @@
+#!/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}:/sbin:/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: