summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorErmine <mustela@erminea.space>2024-08-22 18:48:37 +0000
committerZach van Rijn <me@zv.io>2024-08-22 18:48:37 +0000
commit9f039c94ce8ab9ac44b541e1d7ae8fdf04686486 (patch)
treec01f20f3ce228f87726e03f22d6c80c1a6ece343 /user
parente44842c7c4a2047159efaa31e3bc6f9614ee3938 (diff)
downloadpackages-9f039c94ce8ab9ac44b541e1d7ae8fdf04686486.tar.gz
packages-9f039c94ce8ab9ac44b541e1d7ae8fdf04686486.tar.bz2
packages-9f039c94ce8ab9ac44b541e1d7ae8fdf04686486.tar.xz
packages-9f039c94ce8ab9ac44b541e1d7ae8fdf04686486.zip
user/ifupdown-ng: new package
Diffstat (limited to 'user')
-rw-r--r--user/ifupdown-ng/APKBUILD110
-rw-r--r--user/ifupdown-ng/ifupdown-ng.initd91
2 files changed, 201 insertions, 0 deletions
diff --git a/user/ifupdown-ng/APKBUILD b/user/ifupdown-ng/APKBUILD
new file mode 100644
index 000000000..8ac58f0e1
--- /dev/null
+++ b/user/ifupdown-ng/APKBUILD
@@ -0,0 +1,110 @@
+# Contributor: Ermine <mustela@erminea.space>
+# Contributor: Ariadne Conill <ariadne@dereferenced.org>
+# Maintainer: Ermine <mustela@erminea.space>
+pkgname=ifupdown-ng
+pkgver=0.12.1
+pkgrel=0
+pkgdesc="Tools for managing network configuration"
+url="https://github.com/ifupdown-ng/ifupdown-ng"
+arch="all"
+license="ISC AND BSD-2-Clause"
+depends="kyua atf"
+makedepends="scdoc"
+subpackages="$pkgname-doc $pkgname-openrc $pkgname-iproute2 $pkgname-ppp
+ $pkgname-wireguard $pkgname-ethtool $pkgname-wifi"
+source="https://distfiles.ariadne.space/ifupdown-ng/ifupdown-ng-$pkgver.tar.xz
+ ifupdown-ng.initd
+ "
+
+# We only install the core executors right now. The other executors are
+# still being ported to run under ifupdown-ng natively, and so we will
+# use the ifupdown scripts for now for those cases. However, it is nice
+# to make the automatic dependency resolution work, and ifupdown-ng
+# provides some stubs to enable that.
+_executor_stubs="bridge bond"
+
+# These are optional executors which do not conflict with what we are
+# presently shipping. These executors require iproute2.
+_executor_iproute2="vrf gre vxlan mpls"
+
+# These are all optional executors we plan to use.
+_executor_opt="ppp wireguard wireguard-quick ethtool wifi $_executor_iproute2"
+
+build() {
+ make
+ make docs
+}
+
+check() {
+ make check
+}
+
+package() {
+ make DESTDIR="$pkgdir" EXECUTOR_SCRIPTS_OPT="$_executor_opt" \
+ EXECUTOR_SCRIPTS_STUB="$_executor_stubs" install install_docs
+ install -Dm755 "$srcdir"/ifupdown-ng.initd "$pkgdir"/etc/init.d/ifupdown-ng
+}
+
+iproute2() {
+ pkgdesc="ifupdown-ng integration for iproute2"
+ depends="iproute2"
+ install_if="$pkgname=$pkgver-r$pkgrel $depends"
+
+ mkdir -p "$subpkgdir"/usr/libexec/ifupdown-ng
+ for exec in $_executor_iproute2; do
+ mv "$pkgdir"/usr/libexec/ifupdown-ng/$exec \
+ "$subpkgdir"/usr/libexec/ifupdown-ng/$exec
+ done
+}
+
+ppp() {
+ pkgdesc="ifupdown-ng integration for ppp"
+ depends="ppp"
+ install_if="$pkgname=$pkgver-r$pkgrel $depends"
+
+ mkdir -p "$subpkgdir"/usr/libexec/ifupdown-ng
+ mv "$pkgdir"/usr/libexec/ifupdown-ng/ppp \
+ "$subpkgdir"/usr/libexec/ifupdown-ng/ppp
+}
+
+wireguard() {
+ pkgdesc="ifupdown-ng integration for wireguard"
+ depends="wireguard-tools"
+ install_if="$pkgname=$pkgver-r$pkgrel $depends"
+
+ mkdir -p "$subpkgdir"/usr/libexec/ifupdown-ng
+ mv "$pkgdir"/usr/libexec/ifupdown-ng/wireguard \
+ "$subpkgdir"/usr/libexec/ifupdown-ng/wireguard
+ mv "$pkgdir"/usr/libexec/ifupdown-ng/wireguard-quick \
+ "$subpkgdir"/usr/libexec/ifupdown-ng/wireguard-quick
+}
+
+ethtool() {
+ pkgdesc="ifupdown-ng integration for ethtool"
+ depends="ethtool"
+ install_if="$pkgname=$pkgver-r$pkgrel $depends"
+
+ mkdir -p "$subpkgdir"/usr/libexec/ifupdown-ng
+ mv "$pkgdir"/usr/libexec/ifupdown-ng/ethtool \
+ "$subpkgdir"/usr/libexec/ifupdown-ng/ethtool
+}
+
+wifi() {
+ pkgdesc="ifupdown-ng integration for wifi"
+ depends="wpa_supplicant"
+ install_if="$pkgname=$pkgver-r$pkgrel $depends"
+
+ mkdir -p "$subpkgdir"/usr/libexec/ifupdown-ng
+ mv "$pkgdir"/usr/libexec/ifupdown-ng/wifi \
+ "$subpkgdir"/usr/libexec/ifupdown-ng/wifi
+}
+
+doc() {
+ default_doc
+
+ mkdir -p "$subpkgdir"/etc/network
+ mv "$pkgdir"/etc/network/ifupdown-ng.conf.example \
+ "$subpkgdir"/etc/network/ifupdown-ng.conf.example
+}
+sha512sums="c2c1e27fbd53eeb4150e544a893352f13845b491850e982a5880160c3be03b628794f7989c802ff823ac3e8c6c34dc4ab97c0abcefdda85f06fcd64ced8ac60c ifupdown-ng-0.12.1.tar.xz
+aa1dd3d31872d7ec308b534044e490136de47a3e72575a96522f60c5740ee3b953a17e05013359d27985ac16b048ff8fff76e8ac1103802a4fb75a31d2185d45 ifupdown-ng.initd"
diff --git a/user/ifupdown-ng/ifupdown-ng.initd b/user/ifupdown-ng/ifupdown-ng.initd
new file mode 100644
index 000000000..adae1b66c
--- /dev/null
+++ b/user/ifupdown-ng/ifupdown-ng.initd
@@ -0,0 +1,91 @@
+#!/sbin/openrc-run
+
+# Copyright (c) Natanael Copa
+# This code is licensed under BSD-2-Clause
+#
+# note that the spoofprotect, syncoockies and ip_forward options are set in
+# /etc/sysctl.conf
+
+: ${cfgfile:="/etc/network/interfaces"}
+: ${ifquery:="ifquery"}
+: ${ifstate:="/run/ifstate"}
+
+single_iface="${RC_SVCNAME#*.}"
+if [ "$single_iface" = "$RC_SVCNAME" ]; then
+ single_iface=
+fi
+
+depend() {
+ need localmount hostname
+ want dev-settle
+ after bootmisc hwdrivers modules
+ provide net
+ keyword -jail -prefix -vserver -docker
+}
+
+# find interfaces we want to start
+find_ifaces() {
+ if [ -n "$single_iface" ]; then
+ echo $single_iface
+ return 0
+ fi
+
+ if command -v "$ifquery" >/dev/null; then
+ $ifquery -i "$cfgfile" --list -a
+ return
+ fi
+
+ # fallback in case ifquery does not exist
+ awk '$1 == "auto" {for (i = 2; i <= NF; i = i + 1) printf("%s ", $i)}' "$cfgfile"
+}
+
+# return the list of interfaces we should try stop
+find_running_ifaces() {
+ if [ -n "$single_iface" ]; then
+ echo $single_iface
+ return 0
+ fi
+
+ if command -v "$ifquery" >/dev/null; then
+ $ifquery --state-file $ifstate -i "$cfgfile" --running
+ return
+ fi
+
+ # fallback
+ awk -F= '{print $2}' $ifstate
+}
+
+start() {
+ local iface= ret=1
+ ebegin "Starting networking"
+ eindent
+ for iface in $(find_ifaces); do
+ local r=0
+ ebegin "$iface"
+ if ! ifup -i "$cfgfile" $iface >/dev/null; then
+ ifdown -i "$cfgfile" $iface >/dev/null 2>&1
+ r=1
+ fi
+ # atleast one interface needs to be started for action
+ # to be success
+ eend $r && ret=0
+ done
+ eoutdent
+ return $ret
+}
+
+stop() {
+ local iface=
+ # Don't stop the network at shutdown.
+ yesno ${keep_network:-YES} && yesno $RC_GOINGDOWN && return 0
+
+ ebegin "Stopping networking"
+ eindent
+ for iface in $(find_running_ifaces); do
+ ebegin "$iface"
+ ifdown -i "$cfgfile" -f $iface >/dev/null
+ eend $?
+ done
+ eoutdent
+ return 0
+}