diff options
author | freaj <freaj@riseup.net> | 2015-03-30 11:08:25 +0200 |
---|---|---|
committer | freaj <freaj@riseup.net> | 2015-03-30 11:08:25 +0200 |
commit | cec37e643f4889b4b8652bdfce886b1e5e81f2bd (patch) | |
tree | c992d8325923324f5d318f57b4c05dd5fe494988 /pcr/openrc-misc/10-openrc-status-r4 | |
parent | 7385c6143c1b587bca68deade6e5989d11879767 (diff) |
openrc-misc: add new package to [pcr]
Diffstat (limited to 'pcr/openrc-misc/10-openrc-status-r4')
-rw-r--r-- | pcr/openrc-misc/10-openrc-status-r4 | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pcr/openrc-misc/10-openrc-status-r4 b/pcr/openrc-misc/10-openrc-status-r4 new file mode 100644 index 000000000..e195ccc19 --- /dev/null +++ b/pcr/openrc-misc/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: |