summaryrefslogtreecommitdiff
path: root/nonsystemd
diff options
context:
space:
mode:
Diffstat (limited to 'nonsystemd')
-rw-r--r--nonsystemd/networkmanager-openrc/10-openrc-status36
-rw-r--r--nonsystemd/networkmanager-openrc/NetworkManager.confd4
-rw-r--r--nonsystemd/networkmanager-openrc/NetworkManager.initd64
-rw-r--r--nonsystemd/networkmanager-openrc/PKGBUILD26
4 files changed, 130 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:
diff --git a/nonsystemd/networkmanager-openrc/NetworkManager.confd b/nonsystemd/networkmanager-openrc/NetworkManager.confd
new file mode 100644
index 000000000..4a9922965
--- /dev/null
+++ b/nonsystemd/networkmanager-openrc/NetworkManager.confd
@@ -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/nonsystemd/networkmanager-openrc/NetworkManager.initd b/nonsystemd/networkmanager-openrc/NetworkManager.initd
new file mode 100644
index 000000000..4829618da
--- /dev/null
+++ b/nonsystemd/networkmanager-openrc/NetworkManager.initd
@@ -0,0 +1,64 @@
+#!/usr/bin/openrc-run
+# Copyright (c) 2008 Saleem Abdulrasool <compnerd@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."
+# supervisor="supervise-daemon"
+# command="/usr/bin/NetworkManager"
+# command_args="-n"
+# pidfile="/run/NetworkManager/NetworkManager.pid"
+
+depend() {
+ need dbus
+ use logind
+ provide net
+}
+
+start_pre() {
+ checkpath -q -d -m 0755 /run/NetworkManager
+}
+
+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
+}
diff --git a/nonsystemd/networkmanager-openrc/PKGBUILD b/nonsystemd/networkmanager-openrc/PKGBUILD
new file mode 100644
index 000000000..be97bce62
--- /dev/null
+++ b/nonsystemd/networkmanager-openrc/PKGBUILD
@@ -0,0 +1,26 @@
+# Maintainer: artoo <artoo@artixlinux.org>
+
+pkgname=networkmanager-openrc
+pkgver=20210505
+pkgrel=6
+pkgdesc="OpenRC networkmanager init script"
+arch=('any')
+url="https://gitea.artixlinux.org/artixlinux/packages-openrc"
+license=('GPL2')
+groups=('openrc-world')
+provides=('init-networkmanager')
+depends=('openrc' 'networkmanager')
+conflicts=('init-networkmanager')
+backup=('etc/conf.d/NetworkManager')
+source=("NetworkManager".{initd,confd}
+ '10-openrc-status')
+sha256sums=('eaf7d210540ed9f4c6b4ba81ddbb30a2aa5ce8b528057f7d64ce3478981f88e4'
+ '4594573f01fe5e04b6dde4525796acf909158591bdcefd662ec23fe0d1c3e1bd'
+ 'd32a21c0683cf7a09370b35b7e3d3b3f28f5d4d242ecde2c866cfb400b94bcbe')
+
+package() {
+ install -Dm755 "${srcdir}"/NetworkManager.initd "${pkgdir}"/etc/init.d/NetworkManager
+ install -Dm644 "${srcdir}"/NetworkManager.confd "${pkgdir}"/etc/conf.d/NetworkManager
+
+ install -Dm755 "${srcdir}"/10-openrc-status "${pkgdir}"/etc/NetworkManager/dispatcher.d/10-openrc-status
+}