diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2011-01-07 12:27:43 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2011-01-07 12:39:59 +0000 |
commit | 562d57023d07eae5f3a97e1df7862a6bf505a99a (patch) | |
tree | e5c095afca2d562d33a4cf1a9451c79ce0eb4d10 | |
parent | 60204f874164b38247e0d52e589dbe52c4daa178 (diff) | |
download | alpine_aports-562d57023d07eae5f3a97e1df7862a6bf505a99a.tar.bz2 alpine_aports-562d57023d07eae5f3a97e1df7862a6bf505a99a.tar.xz alpine_aports-562d57023d07eae5f3a97e1df7862a6bf505a99a.zip |
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.
(cherry picked from commit ad6c64eab47b57d8d5368a05c4c5fbef8627686a)
-rw-r--r-- | main/openrc/APKBUILD | 4 | ||||
-rw-r--r-- | main/openrc/networking.initd | 65 |
2 files changed, 55 insertions, 14 deletions
diff --git a/main/openrc/APKBUILD b/main/openrc/APKBUILD index bf7bc6969c..997d6c16f9 100644 --- a/main/openrc/APKBUILD +++ b/main/openrc/APKBUILD | |||
@@ -1,7 +1,7 @@ | |||
1 | # Maintainer: Natanael Copa <ncopa@alpinelinux.org> | 1 | # Maintainer: Natanael Copa <ncopa@alpinelinux.org> |
2 | pkgname=openrc | 2 | pkgname=openrc |
3 | pkgver=0.6.1 | 3 | pkgver=0.6.1 |
4 | pkgrel=3 | 4 | pkgrel=4 |
5 | pkgdesc="OpenRC manages the services, startup and shutdown of a host" | 5 | pkgdesc="OpenRC manages the services, startup and shutdown of a host" |
6 | url="http://roy.marples.name/openrc" | 6 | url="http://roy.marples.name/openrc" |
7 | license='BSD-2' | 7 | license='BSD-2' |
@@ -67,6 +67,6 @@ b1e64885f301166df30be3e3cf5338ff hwdrivers.initd | |||
67 | 33ca3e558c42cdd17adccbc7807298f7 keymaps.initd | 67 | 33ca3e558c42cdd17adccbc7807298f7 keymaps.initd |
68 | 098a1f16812f56fcb56eb6b6f0fa31f6 modules.initd | 68 | 098a1f16812f56fcb56eb6b6f0fa31f6 modules.initd |
69 | 408e28f247c7cc71fa104c07869417f4 modloop.initd | 69 | 408e28f247c7cc71fa104c07869417f4 modloop.initd |
70 | c05fc2ea5d771ca68cbb8d91494c9a2b networking.initd | 70 | daed2d1f6dffb0b87cc49feb53725aa2 networking.initd |
71 | 0a615d93aab691364c03539c3b496dcc local.start | 71 | 0a615d93aab691364c03539c3b496dcc local.start |
72 | c1ec888202d868710b5749f7b217d1e3 modloop.confd" | 72 | 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 @@ | |||
2 | 2 | ||
3 | # note that the spoofprotect, syncoockies and ip_forward options are set in | 3 | # note that the spoofprotect, syncoockies and ip_forward options are set in |
4 | # /etc/sysctl.conf | 4 | # /etc/sysctl.conf |
5 | |||
6 | ifconf=/etc/network/interfaces | ||
7 | ifstate=/var/run/ifstate | ||
8 | |||
9 | single_iface="${SVCNAME#*.}" | ||
10 | if [ "$single_iface" = "$SVCNAME" ]; then | ||
11 | single_iface= | ||
12 | fi | ||
13 | |||
5 | depend() { | 14 | depend() { |
6 | after bootmisc hwdrivers modules | 15 | after bootmisc hwdrivers modules |
7 | provide net | 16 | provide net |
8 | keyword nojail noprefix novserver | 17 | keyword nojail noprefix novserver |
9 | } | 18 | } |
10 | 19 | ||
11 | start() { | 20 | # find interfaces we want to start |
12 | ebegin "Configuring network interfaces" | 21 | find_ifaces() { |
13 | ifup -a >/dev/null 2>&1 | 22 | if [ -n "$single_iface" ]; then |
14 | eend $? | 23 | echo $single_iface |
24 | else | ||
25 | awk '$1 == "auto" { print $2}' $ifconf | ||
26 | fi | ||
15 | } | 27 | } |
16 | 28 | ||
17 | stop() { | 29 | # return the list of interfaces we should try stop |
18 | ebegin "Deconfiguring network interfaces" | 30 | find_running_ifaces() { |
19 | ifdown -a >/dev/null 2>&1 | 31 | if [ -n "$single_iface" ]; then |
20 | eend $? | 32 | echo $single_iface |
33 | else | ||
34 | awk -F= '{print $2}' $ifstate | ||
35 | fi | ||
21 | } | 36 | } |
22 | 37 | ||
23 | restart() { | 38 | start() { |
24 | ebegin "Reconfiguring network interfaces" | 39 | local iface= ret=1 |
25 | ifdown -a >/dev/null 2>&1 && ifup -a >/dev/null 2>&1 | 40 | ebegin "Starting networking" |
26 | eend $? | 41 | eindent |
42 | for iface in $(find_ifaces); do | ||
43 | local r=0 | ||
44 | ebegin "$iface" | ||
45 | if ! ifup $iface >/dev/null; then | ||
46 | ifdown $iface >/dev/null 2>&1 | ||
47 | r=1 | ||
48 | fi | ||
49 | # atleast one interface needs to be started for action | ||
50 | # to be success | ||
51 | eend $r && ret=0 | ||
52 | done | ||
53 | eoutdent | ||
54 | return $ret | ||
55 | } | ||
56 | |||
57 | stop() { | ||
58 | local iface= | ||
59 | ebegin "Stopping networking" | ||
60 | eindent | ||
61 | for iface in $(find_running_ifaces); do | ||
62 | ebegin "$iface" | ||
63 | ifdown -f $iface >/dev/null | ||
64 | eend $? | ||
65 | done | ||
66 | eoutdent | ||
67 | return 0 | ||
27 | } | 68 | } |
28 | 69 | ||