English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Contents of /branches/common-nfo/package/fwifupdown/lib/alias

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3427 - (show annotations) (download)
Wed Aug 8 11:08:41 2007 UTC (6 years, 6 months ago) by tg
File size: 1461 byte(s)
merge in trunk rev. 3426
1 #!/bin/sh
2 #
3 # This file is part of the FreeWRT project. FreeWRT is copyrighted
4 # material, please see the LICENCE file in the top-level directory
5 # or at http://www.freewrt.org/licence for details.
6 #
7 # Christian Fischer <spaetzle@freewrt.org>
8 #
9
10 IFACE_LOGICAL=1
11
12 iface_type() {
13 [[ $(echo $IFACE | sed 's/[^:]*//g') = : ]]
14 }
15
16 alias_exists() {
17 [[ $(ip a 2>&- | grep $IFACE | sed "s/.*[^${IFACE}]//") = $IFACE ]]
18 }
19
20 alias_get_primary() {
21 echo $IFACE | sed 's/:.*$//'
22 }
23
24 alias_is_up() {
25 alias_exists && is_up $(alias_get_primary)
26 }
27
28 prereq_preup() {
29 if [[ $METHOD != static ]]; then
30 mup
31 mstate 1
32 merr "Unsupported method $METHOD"
33 return 1
34 fi
35
36 alias_is_up || return 0
37 mup
38 mstate 1
39 minfo "Interface already up"
40 return 1
41 }
42
43 if_preup() {
44 local baseif=$(alias_get_primary)
45 is_up $baseif || ifup $baseif
46 }
47
48 prereq_up() {
49 alias_is_up
50 mstate $? || return
51 }
52
53 prereq_down() {
54 alias_exists && return
55 mdown
56 mstate 1
57 merr "No such device"
58 return 1
59 }
60
61 if_down() {
62 alias_is_up || alias_ifstate=down
63 # running busybox ifdown <alias interface name> causes primary
64 # interface shutdown
65 # overwrite main method to override busybox ifupdown.c code
66 main_bb_methods_override() {
67 eval $IF_DOWN
68 ip link set down $IFACE 1>&- || { mstate 1; exit;}
69 eval $IF_POST_DOWN
70 main_postdown
71 RT_BB_NOEXEC=1
72 }
73 }
74
75 prereq_postdown() {
76 alias_exists
77 mstate $((!$?)) || exit
78 [[ $alias_ifstate = down ]] && minfo "Interface already down"
79 return 0
80 }
81
82 # vim:ts=4

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20