aboutsummaryrefslogtreecommitdiffstats
path: root/main/openrc
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-01-07 12:27:43 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-01-07 12:27:43 +0000
commitad6c64eab47b57d8d5368a05c4c5fbef8627686a (patch)
tree9457f649207cbbf61a6ccdb8bbe3b8a3ca1aac58 /main/openrc
parent910fb344b544b458905a41a5782b3d7d1dda3adb (diff)
downloadaports-ad6c64eab47b57d8d5368a05c4c5fbef8627686a.tar.bz2
aports-ad6c64eab47b57d8d5368a05c4c5fbef8627686a.tar.xz
main/openrc: improve networking script
We start interfaces one by one so we get a report which interface fails if any. We consider networking service as 'running' if any interface starts.
Diffstat (limited to 'main/openrc')
-rw-r--r--main/openrc/APKBUILD4
-rw-r--r--main/openrc/networking.initd65
2 files changed, 55 insertions, 14 deletions
diff --git a/main/openrc/APKBUILD b/main/openrc/APKBUILD
index 5f89236352..e98445749e 100644
--- a/main/openrc/APKBUILD
+++ b/main/openrc/APKBUILD
@@ -1,7 +1,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=openrc
pkgver=0.6.1
-pkgrel=3
+pkgrel=4
pkgdesc="OpenRC manages the services, startup and shutdown of a host"
url="http://roy.marples.name/openrc"
arch="x86 x86_64"
@@ -68,6 +68,6 @@ b1e64885f301166df30be3e3cf5338ff hwdrivers.initd
33ca3e558c42cdd17adccbc7807298f7 keymaps.initd
098a1f16812f56fcb56eb6b6f0fa31f6 modules.initd
408e28f247c7cc71fa104c07869417f4 modloop.initd
-c05fc2ea5d771ca68cbb8d91494c9a2b networking.initd
+daed2d1f6dffb0b87cc49feb53725aa2 networking.initd
0a615d93aab691364c03539c3b496dcc local.start
c1ec888202d868710b5749f7b217d1e3 modloop.confd"
diff --git a/main/openrc/networking.initd b/main/openrc/networking.initd
index 0d22582ea9..c37be9956d 100644
--- a/main/openrc/networking.initd
+++ b/main/openrc/networking.initd
@@ -2,27 +2,68 @@
# note that the spoofprotect, syncoockies and ip_forward options are set in
# /etc/sysctl.conf
+
+ifconf=/etc/network/interfaces
+ifstate=/var/run/ifstate
+
+single_iface="${SVCNAME#*.}"
+if [ "$single_iface" = "$SVCNAME" ]; then
+ single_iface=
+fi
+
depend() {
after bootmisc hwdrivers modules
provide net
keyword nojail noprefix novserver
}
-start() {
- ebegin "Configuring network interfaces"
- ifup -a >/dev/null 2>&1
- eend $?
+# find interfaces we want to start
+find_ifaces() {
+ if [ -n "$single_iface" ]; then
+ echo $single_iface
+ else
+ awk '$1 == "auto" { print $2}' $ifconf
+ fi
}
-stop() {
- ebegin "Deconfiguring network interfaces"
- ifdown -a >/dev/null 2>&1
- eend $?
+# return the list of interfaces we should try stop
+find_running_ifaces() {
+ if [ -n "$single_iface" ]; then
+ echo $single_iface
+ else
+ awk -F= '{print $2}' $ifstate
+ fi
}
-restart() {
- ebegin "Reconfiguring network interfaces"
- ifdown -a >/dev/null 2>&1 && ifup -a >/dev/null 2>&1
- eend $?
+start() {
+ local iface= ret=1
+ ebegin "Starting networking"
+ eindent
+ for iface in $(find_ifaces); do
+ local r=0
+ ebegin "$iface"
+ if ! ifup $iface >/dev/null; then
+ ifdown $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=
+ ebegin "Stopping networking"
+ eindent
+ for iface in $(find_running_ifaces); do
+ ebegin "$iface"
+ ifdown -f $iface >/dev/null
+ eend $?
+ done
+ eoutdent
+ return 0
}