blob: a3533fa789b52137461f8fd992b0efda6b6c0d37 [file] [log] [blame]
Andy Bavieraeaebe52015-05-18 15:15:06 -04001#!/bin/bash
2
Andy Bavier4c7e76d2015-09-09 18:06:30 -04003function mac_to_iface {
4 MAC=$1
5 ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
6}
7
Andy Bavieraeaebe52015-05-18 15:15:06 -04008iptables -L > /dev/null
9ip6tables -L > /dev/null
10
Andy Bavier6d0a9be2015-07-02 15:00:58 -040011VCPE=vcpe-{{ vlan_ids[0] }}
12
13docker inspect $VCPE > /dev/null 2>&1
Andy Bavieraeaebe52015-05-18 15:15:06 -040014if [ "$?" == 1 ]
15then
Andy Bavier7af6fa02015-06-08 15:10:57 -040016 docker pull andybavier/docker-vcpe
Andy Bavier6d0a9be2015-07-02 15:00:58 -040017 docker run -d --name=$VCPE --privileged=true --net=none -v /etc/$VCPE/dnsmasq.d:/etc/dnsmasq.d andybavier/docker-vcpe
Andy Bavieraeaebe52015-05-18 15:15:06 -040018else
Andy Bavier6d0a9be2015-07-02 15:00:58 -040019 docker start $VCPE
Andy Bavieraeaebe52015-05-18 15:15:06 -040020fi
21
22# Set up networking via pipework
Andy Bavier4c7e76d2015-09-09 18:06:30 -040023WAN_IFACE=$( mac_to_iface {{ wan_mac }} )
Andy Bavier733733d2015-10-29 14:01:47 -040024docker exec $VCPE ifconfig eth0 >> /dev/null || pipework $WAN_IFACE -i eth0 $VCPE {{ wan_ip }}/24@{{ wan_next_hop }} {{ wan_container_mac }}
Andy Bavier4c7e76d2015-09-09 18:06:30 -040025
26LAN_IFACE=$( mac_to_iface {{ lan_mac }} )
27docker exec $VCPE ifconfig eth1 >> /dev/null || pipework $LAN_IFACE -i eth1 $VCPE 192.168.0.1/24 @{{ vlan_ids[0] }}
28
29HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
30docker exec $VCPE ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VCPE {{ hpc_client_ip }}/24
Andy Bavieraeaebe52015-05-18 15:15:06 -040031
Scott Baker6b73d1b2015-06-23 17:01:01 -070032# Make sure VM's eth0 (hpc_client) has no IP address
Andy Bavier4c7e76d2015-09-09 18:06:30 -040033ifconfig $HPC_IFACE 0.0.0.0
Scott Baker6b73d1b2015-06-23 17:01:01 -070034
Andy Bavieraeaebe52015-05-18 15:15:06 -040035# Now can start up dnsmasq
Andy Bavier6d0a9be2015-07-02 15:00:58 -040036docker exec $VCPE service dnsmasq start
Andy Bavieraeaebe52015-05-18 15:15:06 -040037
38# Attach to container
Andy Bavier6d0a9be2015-07-02 15:00:58 -040039docker start -a $VCPE