1 | 1 | simandl | #!/bin/sh |
2 | | | # vlubnt 0.0.1 |
3 | | | # Vojtech Pavlik |
4 | | | |
5 | | | if ! HOST=`grep -- "resolv.host.1.name=.*-VLAN" /tmp/system.cfg`; then exit 0; fi |
6 | | | if ! BRIDGE=`ip addr show br0 | grep inet`; then exit 0; fi |
7 | | | if ! DEFAULT=`ip r | grep default`; then exit 0; fi |
8 | | | IP=`echo $BRIDGE | sed -e "s/^.*inet //" -e "s/ scope.*$//"` |
9 | | | if test -z "${IP}"; then exit 0; fi |
10 | | | VLAN=`echo $HOST | sed -e "s/^.*-VLAN//"` |
11 | | | if test -z "${VLAN}"; then exit 0; fi |
12 | | | DR=`echo $DEFAULT | sed -e "s/dev.*$//"` |
13 | | | if test -z "${DR}"; then exit 0; fi |
14 | | | |
15 | | | # Move IP address to eth0_real |
16 | | | ip addr del ${IP} dev br0 |
17 | | | brctl delif br0 eth0_real |
18 | | | ip addr add ${IP} dev eth0_real |
19 | | | |
20 | | | # Add new default route |
21 | | | ip r add ${DR} |
22 | | | |
23 | | | # Move AP to VLAN |
24 | | | vconfig add eth0_real ${VLAN} |
25 | | | ip link set eth0_real.${VLAN} up |
26 | | | brctl addif br0 eth0_real.${VLAN} |
27 | | | |