commit:     71df601aff9104f71a0e0a2460bb4d9d69be1c66
Author:     Jory Pratt <anarchy <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 30 16:38:43 2020 +0000
Commit:     Jory Pratt <anarchy <AT> gentoo <DOT> org>
CommitDate: Thu Apr 30 16:38:43 2020 +0000
URL:        https://gitweb.gentoo.org/proj/musl.git/commit/?id=71df601a

net-misc/networkmanager: add missing files

Fixes: 7090fcd34877abca9b315684c949fbde160fabc8
Package-Manager: Portage-2.3.89, Repoman-2.3.20
Signed-off-by: Jory Pratt <anarchy <AT> gentoo.org>

 ...top.NetworkManager.settings.modify.system.rules |  7 +++
 net-misc/networkmanager/files/10-openrc-status-r4  | 35 +++++++++++++
 .../networkmanager/files/conf.d.NetworkManager     |  4 ++
 .../networkmanager/files/init.d.NetworkManager-r1  | 58 ++++++++++++++++++++++
 4 files changed, 104 insertions(+)

diff --git 
a/net-misc/networkmanager/files/01-org.freedesktop.NetworkManager.settings.modify.system.rules
 
b/net-misc/networkmanager/files/01-org.freedesktop.NetworkManager.settings.modify.system.rules
new file mode 100644
index 0000000..d00b268
--- /dev/null
+++ 
b/net-misc/networkmanager/files/01-org.freedesktop.NetworkManager.settings.modify.system.rules
@@ -0,0 +1,7 @@
+// Let users in plugdev group modify NetworkManager
+polkit.addRule(function(action, subject) {
+    if (action.id == "org.freedesktop.NetworkManager.settings.modify.system" &&
+        subject.isInGroup("plugdev") && subject.active) {
+        return "yes";
+    }
+});

diff --git a/net-misc/networkmanager/files/10-openrc-status-r4 
b/net-misc/networkmanager/files/10-openrc-status-r4
new file mode 100644
index 0000000..e195ccc
--- /dev/null
+++ b/net-misc/networkmanager/files/10-openrc-status-r4
@@ -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}:@EPREFIX@/sbin:@EPREFIX@/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:

diff --git a/net-misc/networkmanager/files/conf.d.NetworkManager 
b/net-misc/networkmanager/files/conf.d.NetworkManager
new file mode 100644
index 0000000..4a99229
--- /dev/null
+++ b/net-misc/networkmanager/files/conf.d.NetworkManager
@@ -0,0 +1,4 @@
+# If NetworkManager does not establish a connection within $INACTIVE_TIMEOUT
+# seconds after starting, the service will be marked as inactive, and it will
+# continue to wait for a connection in background mode.
+INACTIVE_TIMEOUT=1

diff --git a/net-misc/networkmanager/files/init.d.NetworkManager-r1 
b/net-misc/networkmanager/files/init.d.NetworkManager-r1
new file mode 100644
index 0000000..fad772d
--- /dev/null
+++ b/net-misc/networkmanager/files/init.d.NetworkManager-r1
@@ -0,0 +1,58 @@
+#!/sbin/openrc-run
+# Copyright (c) 2008 Saleem Abdulrasool <compn...@compnerd.org>
+# Copyright 2013-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+description="NetworkManager daemon. The service is marked as started only \
+when a network connection is established."
+
+depend() {
+       need dbus
+       use consolekit
+       provide net
+}
+
+start() {
+       # If we are re-called by a dispatcher event, we want to mark the service
+       # as started without starting the daemon again
+       yesno "${IN_BACKGROUND}" && return 0
+
+       [ -z "${INACTIVE_TIMEOUT}" ] && INACTIVE_TIMEOUT="1"
+
+       ebegin "Starting NetworkManager"
+       start-stop-daemon --start --quiet --pidfile 
/run/NetworkManager/NetworkManager.pid \
+               --exec /usr/sbin/NetworkManager -- --pid-file 
/run/NetworkManager/NetworkManager.pid
+       local _retval=$?
+       eend "${_retval}"
+       if [ "x${_retval}" = 'x0' ] && ! nm-online -t "${INACTIVE_TIMEOUT}"; 
then
+               einfo "Marking NetworkManager as inactive. It will 
automatically be marked"
+               einfo "as started after a network connection has been 
established."
+               mark_service_inactive
+       fi
+       return "${_retval}"
+}
+
+stop() {
+       # If we are re-called by a dispatcher event, we want to mark the service
+       # as inactive without stopping the daemon
+       if yesno "${IN_BACKGROUND}"; then
+               mark_service_inactive "${SVCNAME}"
+               return 0
+       fi
+
+       ebegin "Stopping NetworkManager"
+       local pidfile=/run/NetworkManager/NetworkManager.pid
+       if [ ! -e "${pidfile}" ] && [ -e /var/run/NetworkManager.pid ]; then 
+               # Try stopping the pid file used by <0.9.7
+               pidfile=/var/run/NetworkManager.pid
+               start-stop-daemon --stop --quiet --pidfile "${pidfile}"
+               ret=$?
+               [ ${ret} = 0 ] && [ -e "${pidfile}" ] && rm "${pidfile}"
+               eend ${ret}
+       else
+               start-stop-daemon --stop --quiet --pidfile "${pidfile}"
+               eend $?
+       fi
+}
+
+# vim: set ft=gentoo-init-d ts=4 :

Reply via email to