2008 setup ap.sh scripts
From MelbLCAWiki
startup
Initial startup with:
wget -q -O - http://169.222.8.1/$(ip addr show eth0.1|grep inet|cut -d " " -f 6|cut -d "/" -f 1).sh > /tmp/setup_ap.sh . /tmp/setup_ap.sh > /setup_ap.log 2>&1
Update with:
wget -q -O - http://169.222.8.1/$(ip addr show br-lan|grep inet|cut -d " " -f 6|cut -d "/" -f 1).sh > /tmp/setup_ap.sh . /tmp/setup_ap.sh > /setup_ap.log 2>&1
Changelog
- Version: 20080111
- Comment: Updated the VLAN config to add port 1 as a trunked port with tagged packets, for both the management and wireless traffic VLANs
- Who: adhoc
#!/bin/sh
export PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
#ip=$1
MGMT_VLAN=14
WIRELESS_VLAN=8
PASSWORD=matt7john7james7
BR_INT=br-lan
WL_INT=wl0
WR_INT=eth0
CHANNEL=6
ESSID=2008.linux.conf.au
############################################################
#
# here is our environment, debug me harder! - adhoc
#
echo "Local variables;"
echo " MGMT_VLAN = $MGMT_VLAN"
echo "WIRELESS_VLAN = $WIRELESS_VLAN"
echo " PASSWORD = $PASSWORD"
echo " BR_INT = $BR_INT"
echo " WL_INT = $WL_INT"
echo " WR_INT = $WR_INT"
echo " CHANNEL = $CHANNEL"
echo " ESSID = $ESSID"
echo ""
# Set the password
echo "reset the password"
(
echo "$PASSWORD"
sleep 1
echo "$PASSWORD"
) | passwd root 2>&1
echo ""
############################################################
#
# Get any files we need before we break the network
#
# we're not using any dhcp arp action, commented out - adhoc
# Download the dhcp-relay config
#wget -q -O - http://$ip/lca-ap/dhcp-fwd.conf > /tmp/dhcp-fwd.conf
#wget -q -O - http://$ip/lca-ap/dhcparpd.conf > /tmp/dhcparpd.conf
#wget -q -O - http://$ip/lca-ap/dhcparpd.sh > /tmp/dhcparpd.sh
#wget -q -O - http://$ip/lca-ap/tcpdump > /tmp/tcpdump
#wget -q -O - http://$ip/lca-ap/strace > /tmp/strace
#chmod +x /tmp/dhcparpd.sh
#chmod +x /tmp/strace /tmp/tcpdump
############################################################
#
# Setup the network
# Old network breaks here
#
# Turn off Native VLANs
echo "clear VLANs on ports"
echo "" > /proc/switch/eth0/vlan/0/ports
echo "" > /proc/switch/eth0/vlan/1/ports
echo ""
# Remove the bridge so it has no IP
echo "bridge"
echo "- going down"
ifconfig $BR_INT down
brctl delbr $BR_INT
echo "- comming up"
brctl addbr $BR_INT
brctl addif $BR_INT $WL_INT
ifconfig $BR_INT up
echo ""
# Shut down unneeded interfaces
echo "remove the old VLANs and create the new ones"
echo "- vlan0 going down"
ifconfig vlan0 down
echo "- vlan1 going down"
ifconfig vlan1 down
############################################################
#
# Mangle VLANs - adhoc
# port 0 is the wan port
# ports 1,2,3,4 are the LAN ports
# port 5 is the internal eth0
# Create Management VLAN
echo "- add the MGMT_VLAN"
vconfig add $WR_INT $MGMT_VLAN
echo "- tag its ports"
echo "0 1t 5t" > /proc/switch/eth0/vlan/$MGMT_VLAN/ports
#echo "0t 5t" > /proc/switch/eth0/vlan/$MGMT_VLAN/ports
# Create Wireless VLAN
echo "- add the WIRELESS_VLAN"
vconfig add $WR_INT $WIRELESS_VLAN
echo "- tag its ports"
echo "1t 2 3 4 5t" > /proc/switch/eth0/vlan/$WIRELESS_VLAN/ports
#echo "0t 5t" > /proc/switch/eth0/vlan/$WIRELESS_VLAN/ports
echo ""
echo "show VLAN config"
echo "- MGMT_VLAN"
cat /proc/switch/eth0/vlan/$MGMT_VLAN/ports
echo "- WIRELESS_VLAN"
cat /proc/switch/eth0/vlan/$WIRELESS_VLAN/ports
echo ""
# Bridge the wireless lan
echo "bridge the wireless lan to the wireless interface"
echo "- WIRELESS_LAN comming up"
ifconfig $WR_INT.$WIRELESS_VLAN up
echo "- WIRELESS_LAN adding to bridge"
brctl addif $BR_INT $WR_INT.$WIRELESS_VLAN
echo "- WL_INT comming up"
ifconfig $WR_INT.$WIRELESS_VLAN up
echo "- WL_INT adding to bridge"
brctl addif $BR_INT $WL_INT
echo ""
ip addr show
echo ""
############################################################
#
# Setup services
#
echo "purge iptables"
/etc/init.d/firewall stop
# Run the DHCP forwarder
#mkdir -p /var/lib/dhcp-fwd
#dhcp-fwd -c /tmp/dhcp-fwd.conf
echo "dropbear - killing"
killall dropbear
# Kill the old dhcp client
echo "dhcp client"
echo "- killing"
killall udhcpc
# Start DHCP client on management interface
echo "- starting new instance Management interface $WR_INT.$MGMT_VLAN"
udhcpc -i $WR_INT.$MGMT_VLAN -r 0.0.0.0 -b
echo "- i has sleeps now"
sleep 10
echo "- i wakes"
ip addr show
ifconfig
echo ""
echo "dropbear - starting"
/usr/sbin/dropbear -p 22
echo ""
ps
echo ""
############################################################
#
# Mangle the wireless - adhoc
#
# Set the channel
#channel=`cat /tmp/boot_file`
echo "Changing the channel to $CHANNEL"
iwconfig $WL_INT channel $CHANNEL
echo "- down"
ifconfig $WL_INT down
echo "- up"
ifconfig $WL_INT up
echo ""
# Set the ESSID
echo "Changing ESSID of $WL_INT to $ESSID"
/usr/sbin/iwconfig $WL_INT essid $ESSID
echo ""
/usr/sbin/iwconfig $WL_INT
echo ""

