Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
ipw
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2014-02-25 15:21:55 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
Artyom A Anikeev
2014-02-25 15:21:55 +0400
Commit
a96e53526e5fbeea407069ba94b173e2c2cd514d
a96e5352
0 parents
Initial commit
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
180 additions
and
0 deletions
README
ipw
ipw-configsample
README
0 → 100644
View file @
a96e535
File mode changed
ipw
0 → 100755
View file @
a96e535
#!/bin/bash
CONFIG_PATH
=
"./ipw-configsample"
source
"
$CONFIG_PATH
"
NEWCONFIG_TMPPATH
=
"/tmp/.~ipw"
CMD
=
"
$1
"
;
shift
;
NEWCONFIG
=
0
case
"
$CMD
"
in
add1qif
)
NEWCONFIG
=
1
# we need to update the config after the command
D1Q_IFACES[
${#
D1Q_IFACES
}
]
;;
addbrif
)
NEWCONFIG
=
1
# we need to update the config after the command
BRNAME
=
"
$1
"
;
shift
SLAVE
=
"
$1
"
;
shift
# TODO: implement this
#bond0_SLAVES[ ${#bond0_SLAVES[@]} ]="eth2"
;;
fix
)
#brctl addif bond0 eth2
;;
*
)
;;
esac
newconfig_open
()
{
echo
-n >
"
$NEWCONFIG_TMPPATH
"
}
newconfig_write
()
{
LINE
=
"
$1
"
;
shift
;
[[
$NEWCONFIG
-eq 0
]]
&&
return
echo
"
$LINE
"
>>
"
$NEWCONFIG_TMPPATH
"
}
newconfig_commit
()
{
rm -f
"
$CONFIG_PATH
"
mv
"
$NEWCONFIG_TMPPATH
"
"
$CONFIG_PATH
"
}
newconfig_push
()
{
BUFNUM
=
"
$1
"
;
shift
;
LINE
=
"
$1
"
;
shift
;
BUF[
$BUFNUM
]=
"
${
BUF
[
$BUFNUM
]
}
$LINE
"
}
newconfig_popall
()
{
BUFNUM
=
"
$1
"
;
shift
;
BUF[
$BUFNUM
]=
""
}
newconfig_popallwrite
()
{
BUFNUM
=
"
$1
"
;
shift
;
newconfig_write
"
${
BUF
[
$BUFNUM
]
}
"
BUF[
$BUFNUM
]=
""
}
newconfig_open
newconfig_write
"#"
newconfig_write
""
newconfig_write
"D1Q_IFACES=("
for
D1Q_IFACE
in
${
D1Q_IFACES
[@]
}
;
do
newconfig_write
"
$D1Q_IFACE
"
newconfig_push 1
"
${
D1Q_IFACE
}
_SLAVES=("
SLAVES_VARIABLE
=
"
${
D1Q_IFACE
}
_SLAVES"
SLAVES_VARIABLE
=
"
${
SLAVES_VARIABLE
//[.]/_
}
[@]"
for
SLAVE
in
"
${
!SLAVES_VARIABLE
}
"
;
do
newconfig_push 1
"
$SLAVE
"
;
done
newconfig_push 1
")"
# If there're no slaves then don't write anything about them
[[
$SLAVE_i
-eq 0
]]
&&
newconfig_popall 1
VLAN_N_BRIDGE_VARIABLE
=
"
${
D1Q_IFACE
}
_VLAN_N_BRIDGES"
VLAN_N_BRIDGE_VARIABLE
=
"
${
VLAN_N_BRIDGE_VARIABLE
//[.]/_
}
[@]"
for
VLANS_N_BRIDGE
in
"
${
!VLAN_N_BRIDGE_VARIABLE
}
"
;
do
# Checking if no "vlan(.subvlan)?" is set
if
[[
"
${
VLANS_N_BRIDGE
:0:1
}
"
=
":"
]]
;
then
VLAN
=
""
BRNAME
=
"
${
VLANS_N_BRIDGE
:1
}
"
else
# Splitting by ":"
WORDS
=(
${
VLANS_N_BRIDGE
//[
:]/
}
)
# The second word defines interface name. If it's empty, "vlan$VLAN.$SUBVLAN" is used.
VLAN
=
"
${
WORDS
[0]
}
"
BRNAME
=
"
${
WORDS
[1]
}
"
# Splitting by "."
WORDS
=(
${
VLAN
//[.]/
}
)
# The second word defines subvlan (1q-in-1q) if it's used. It's empty if no subvlan is used.
VLAN
=
"
${
WORDS
[0]
}
"
SUBVLAN
=
"
${
WORDS
[1]
}
"
fi
# Checking if no "vlan(.subvlan)?" is set
if
!
[[
"
${
VLANS_N_BRIDGE
:
-1
}
"
=
":"
]]
;
then
# Setting default values
[[
"
$SUBVLAN
"
=
""
]]
&&
BRNAME
=
"
${
BRNAME
:-
vlan
${
VLAN
}}
"
||
BRNAME
=
"
${
BRNAME
:-
vlan
${
VLAN
}
.
${
SUBVLAN
}}
"
# Getting commands for "ip"
IP_CMDS_VARIABLE
=
"
${
BRNAME
}
_IP"
IP_CMDS_VARIABLE
=
"
${
IP_CMDS_VARIABLE
//[.]/_
}
[@]"
for
IP_CMD
in
"
${
!IP_CMDS_VARIABLE
}
"
;
do
echo
ip
$IP_CMD
dev
$BRNAME
((
IP_CMD_i++
))
done
fi
printf
"br: %-10s vlan:%4s subvlan:%4s
\n
"
"
$BRNAME
"
"
$VLAN
"
"
$SUBVLAN
"
((
VLAN_N_BRIDGE_i++
))
done
done
newconfig_write
")"
newconfig_write
""
newconfig_popallwrite 1
newconfig_popallwrite 2
newconfig_popallwrite 3
echo
${
D1Q_IFACES
[@]
}
#[[ $NEWCONFIG -ne 0 ]] && newconfig_commit
exit
0
...
...
ipw-configsample
0 → 100755
View file @
a96e535
#
D1Q_IFACES=(bond0)
bond0_SLAVES=(eth0 eth1)
# vlan.subvlan:bridge-name
# if vlan.subvlan is set to "" then bridge is created without creating (and enslaving) the vlan interface
# if bridge is set to "" then vlan interface is created without creating the bridge (to be enslaved by)
# if bridge is not set then "vlan$VLAN.$SUBVLAN"/"vlan$VLAN" is used
bond0_VLAN_N_BRIDGES=(
10.2:thor.ext
10.3:cps
10.4
50
12:
55
85
433
441
:cps.int
)
thor_ext_IP=(
"addr add 10.10.2.2/24"
"route add default gw 10.10.2.1"
)
...
...
Please
register
or
login
to post a comment