diff options
author | Alexandre Rostovtsev <tetromino@gentoo.org> | 2012-02-02 00:34:59 +0000 |
---|---|---|
committer | Alexandre Rostovtsev <tetromino@gentoo.org> | 2012-02-02 00:34:59 +0000 |
commit | 01a351c0f5ba5929f374cb4b0e987ac7d1c823a0 (patch) | |
tree | 7f0152c7abc9594d3be3475898e8f8016dd64f44 /net-misc/networkmanager/files | |
parent | unmask postfix-2.9 version (diff) | |
download | gentoo-2-01a351c0f5ba5929f374cb4b0e987ac7d1c823a0.tar.gz gentoo-2-01a351c0f5ba5929f374cb4b0e987ac7d1c823a0.tar.bz2 gentoo-2-01a351c0f5ba5929f374cb4b0e987ac7d1c823a0.zip |
Change the NetworkManager OpenRC service to provide net; the service's status is set to 'inactive' when NetworkManager is running but has no connections up, and to 'started' when NetworkManager is connected (bug #252137, thanks to Xake). Do not keepdir /var/run/NetworkManager, it's not needed in Gentoo (bug #401019, thanks to Maxim Kammerer). Correctly parse single-quoted hostnames in /etc/conf.d/hostname.
(Portage version: 2.2.0_alpha84/cvs/Linux x86_64)
Diffstat (limited to 'net-misc/networkmanager/files')
-rw-r--r-- | net-misc/networkmanager/files/10-openrc-status | 27 | ||||
-rw-r--r-- | net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net.patch | 61 |
2 files changed, 88 insertions, 0 deletions
diff --git a/net-misc/networkmanager/files/10-openrc-status b/net-misc/networkmanager/files/10-openrc-status new file mode 100644 index 000000000000..b3c5bc1340d8 --- /dev/null +++ b/net-misc/networkmanager/files/10-openrc-status @@ -0,0 +1,27 @@ +#!/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. + +# Exit if no valid interface name given +if [ -z "$1" -o "x$1" = "xnone" ]; then + exit +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|vpn-up) exec rc-service NetworkManager start ;; + down|vpn-down) exec rc-service NetworkManager stop ;; +esac diff --git a/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net.patch b/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net.patch new file mode 100644 index 000000000000..886fe1a74614 --- /dev/null +++ b/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net.patch @@ -0,0 +1,61 @@ +From dbb1ed70eca25d57da3c12534c241cd38134627b Mon Sep 17 00:00:00 2001 +From: Alexandre Rostovtsev <tetromino@gentoo.org> +Date: Wed, 1 Feb 2012 05:51:20 -0500 +Subject: [PATCH] gentoo: provide net and use inactive status when not + connected + +The status will be reset to started via a dispatcher script on up/down +events. See https://bugs.gentoo.org/show_bug.cgi?id=252137 +--- + initscript/Gentoo/NetworkManager.in | 24 +++++++++++++++++++++++- + 1 files changed, 23 insertions(+), 1 deletions(-) + +diff --git a/initscript/Gentoo/NetworkManager.in b/initscript/Gentoo/NetworkManager.in +index 7db410b..d26996d 100755 +--- a/initscript/Gentoo/NetworkManager.in ++++ b/initscript/Gentoo/NetworkManager.in +@@ -3,18 +3,40 @@ + # Distributed under the terms of the GNU General Purpose License v2 + # $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager/files/networkmanager-0.9.2.0-init-provide-net.patch,v 1.1 2012/02/02 00:34:59 tetromino Exp $ + ++description="NetworkManager daemon. The service is marked as started only \ ++when a network connection is established." ++ + depend() { + need dbus ++ provide net ++} ++ ++_is_connected() { ++ [ "x$(LC_ALL=C nmcli -t -f state nm 2> /dev/null)" = "xconnected" ] ++ return $? + } + + start() { ++ if yesno "${IN_BACKGROUND}"; then ++ _is_connected && mark_service_started ++ return ++ fi + ebegin "Starting NetworkManager" + start-stop-daemon --start --quiet --pidfile /var/run/NetworkManager.pid \ + --exec /usr/sbin/NetworkManager -- --pid-file /var/run/NetworkManager.pid +- eend $? ++ local _retval=$? ++ eend "${_retval}" ++ if [ "x${_retval}" = 'x0' ]; then ++ _is_connected || mark_service_inactive ++ fi ++ return "${_retval}" + } + + stop() { ++ if yesno "${IN_BACKGROUND}"; then ++ _is_connected || mark_service_inactive ++ return ++ fi + ebegin "Stopping NetworkManager" + start-stop-daemon --stop --quiet --pidfile /var/run/NetworkManager.pid + eend $? +-- +1.7.8.4 + |