blob: dfdce0a8f1aee56ae0d5624d2aa9aa80cded859f [file] [log] [blame]
Scott Baker761e1062016-06-20 17:18:17 -07001#!/bin/bash
2
3function mac_to_iface {
4 MAC=$1
5 ifconfig|grep $MAC| awk '{print $1}'|grep -v '\.'
6}
7
8iptables -L > /dev/null
9ip6tables -L > /dev/null
10
11STAG={{ s_tags[0] }}
12CTAG={{ c_tags[0] }}
13VCPE=vcpe-$STAG-$CTAG
14
15docker inspect $VCPE > /dev/null 2>&1
16if [ "$?" == 1 ]
17then
18 docker pull andybavier/docker-vcpe
19 docker run -d --name=$VCPE --privileged=true --net=none \
20 -v /var/container_volumes/$VCPE/mount:/mount:ro \
21 -v /var/container_volumes/$VCPE/etc/dnsmasq.d:/etc/dnsmasq.d:ro \
22 -v /var/container_volumes/$VCPE/etc/service/message:/etc/service/message \
23 -v /var/container_volumes/$VCPE/usr/local/sbin:/usr/local/sbin:ro \
24 andybavier/docker-vcpe
25else
26 docker start $VCPE
27fi
28
29# Set up networking via pipework
30WAN_IFACE=br-wan
31docker exec $VCPE ifconfig eth0 >> /dev/null || pipework $WAN_IFACE -i eth0 $VCPE {{ wan_container_ip }}/{{ wan_container_netbits }}@{{ wan_container_gateway_ip }} {{ wan_container_mac }}
32
33LAN_IFACE=eth0
34ifconfig $LAN_IFACE >> /dev/null
35if [ "$?" == 0 ]
36then
37 ifconfig $LAN_IFACE.$STAG >> /dev/null || ip link add link $LAN_IFACE name $LAN_IFACE.$STAG type vlan id $STAG
38 ifconfig $LAN_IFACE.$STAG up
39 docker exec $VCPE ifconfig eth1 >> /dev/null || pipework $LAN_IFACE.$STAG -i eth1 $VCPE 192.168.0.1/24 @$CTAG
40fi
41
42#HPC_IFACE=$( mac_to_iface {{ hpc_client_mac }} )
43#docker exec $VCPE ifconfig eth2 >> /dev/null || pipework $HPC_IFACE -i eth2 $VCPE {{ hpc_client_ip }}/24
44
45# Make sure VM's eth0 (hpc_client) has no IP address
46#ifconfig $HPC_IFACE 0.0.0.0
47
48# Attach to container
49docker start -a $VCPE