vlubnt |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/sh
# vlubnt 0.0.1
# Vojtech Pavlik
if ! HOST=`grep -- "resolv.host.1.name=.*-VLAN" /tmp/system.cfg`; then exit 0; fi
if ! BRIDGE=`ip addr show br0 | grep inet`; then exit 0; fi
if ! DEFAULT=`ip r | grep default`; then exit 0; fi
IP=`echo $BRIDGE | sed -e "s/^.*inet //" -e "s/ scope.*$//"`
if test -z "${IP}"; then exit 0; fi
VLAN=`echo $HOST | sed -e "s/^.*-VLAN//"`
if test -z "${VLAN}"; then exit 0; fi
DR=`echo $DEFAULT | sed -e "s/dev.*$//"`
if test -z "${DR}"; then exit 0; fi
# Move IP address to eth0_real
ip addr del ${IP} dev br0
brctl delif br0 eth0_real
ip addr add ${IP} dev eth0_real
# Add new default route
ip r add ${DR}
# Move AP to VLAN
vconfig add eth0_real ${VLAN}
ip link set eth0_real.${VLAN} up
brctl addif br0 eth0_real.${VLAN}