source: freewrt/package/fwifupdown/lib/alias@ 4624b5d

Last change on this file since 4624b5d was 4624b5d, checked in by Christian Fischer <spaetzle@…>, 19 years ago

Added package fwifupdown, added busybox ifupdown patch

git-svn-id: svn://www.freewrt.org/trunk/freewrt@2373 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 1.1 KB
Line 
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
10CFG_PREUP_IFUP_CHECK_OFF=1
11CFG_UP_IFUP_CHECK_OFF=1
12CFG_DOWN_IFUP_CHECK_OFF=1
13
14iface_type() {
15 [ "$(echo $IFACE | sed 's/[^:]*//g')" = ":" ]
16}
17
18alias_exists() {
19 [ "$(ip a 2>&- | grep $IFACE | sed "s/.*[^${IFACE}]//")" = "$IFACE" ]
20}
21
22get_primary() {
23 echo $IFACE | sed 's/:.*$//'
24}
25
26if_preup() {
27 if alias_exists
28 then
29 mstate 1
30 merr "Alias already created, run ifdown $IFACE first"
31 return 1
32 fi
33 is_up $(get_primary) || ifup $(get_primary) || return 1
34}
35
36if_up() {
37 if alias_exists && is_up $(get_primary)
38 then
39 mstate 0
40 else
41 mstate 1
42 fi
43}
44
45if_down() {
46 if ! alias_exists
47 then
48 mdown
49 mstate 1
50 merr "Alias doesn't exist, run ifup $IFACE first"
51 return 1
52 fi
53
54 ### busybox ifdown workaround ###
55 # running busybox ifdown <alias interface name> causes primary interface shutdown
56
57 mdown
58 ip link set down $IFACE >/dev/null 2>&1
59 mstate $?
60 builtin exit 1
61}
62
63if_postdown() {
64:
65}
66
67# vim:ts=4
Note: See TracBrowser for help on using the repository browser.