]> git.pld-linux.org Git - packages/lxc.git/blame - lxc_macvlan
- up to 3.0.2; lua/python bindings now as separate packages
[packages/lxc.git] / lxc_macvlan
CommitLineData
1dd4bfdd
LG
1#!/bin/bash
2
3# additional macvlan interface for lxc
4
1dd4bfdd
LG
5macvlan_test_config(){
6
7 # check if all required configurations have been set
8 # Source any configurable options
9 test ! -r /etc/sysconfig/lxc_macvlan ||
10 . /etc/sysconfig/lxc_macvlan
11
12 # Tests for data provided in /etc/sysconfig/lxc_macvlan
13 if [ -z "$MACVLAN_DEV" ]; then
14 echo "MACVLAN_DEV not set is /etc/sysconfig/lxc_macvlan"
15 exit 6
16 fi
17
18 if [ -z "$MACVLAN_NAME" ]; then
19 echo "MACVLAN_NAME not set is /etc/sysconfig/lxc_macvlan"
20 exit 6
21 fi
22
23 if [ -z "$MACVLAN_ADDRESS" ]; then
24 echo "MACVLAN_ADDRESS not set is /etc/sysconfig/lxc_macvlan"
25 exit 6
26 fi
27}
28
29macvlan_gen_default_hwaddr(){
30 # If not defined MACVLAN_HWADDRESS, calculate it from MACVLAN_ADDRESS
31 echo $MACVLAN_ADDRESS | awk -F "/" '{print $1}' | awk -F "." '{ printf "00:16:3e:%x:%x:%x\n", $2, $3, $4 }'
32}
33
34macvlan_start() {
35 echo "LXC macvlan interface start"
1dd4bfdd
LG
36 macvlan_test_config
37
38 set -e
39 if [ -z "$MACVLAN_HWADDRESS" ]; then
40 MACVLAN_HWADDRESS=`macvlan_gen_default_hwaddr`
41 fi
42 ip link add link $MACVLAN_DEV name $MACVLAN_NAME address $MACVLAN_HWADDRESS type macvlan mode bridge
43 ip link set $MACVLAN_NAME up
44 ip address add $MACVLAN_ADDRESS brd + dev $MACVLAN_NAME
45}
46
47macvlan_stop() {
48 echo "LXC macvlan interface stop"
49 macvlan_test_config
50
51 set -e
52 ip link set $MACVLAN_NAME down
53 ip link del $MACVLAN_NAME
54}
55
56macvlan_status() {
57 echo "LXC macvlan interface status"
58 macvlan_test_config
59
60 set -e
61 ip addr show $MACVLAN_NAME
9def5ac8 62}
This page took 0.106051 seconds and 4 git commands to generate.