1#!/bin/bash
2
3dir=$(dirname "$0")
4. "$dir/xen-hotplug-common.sh"
5. "$dir/xen-network-common.sh"
6
7bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
8if [ -z "$bridge" ]
9    then
10    if which brctl >&/dev/null; then
11        nr_bridges=$(($(brctl show | cut -f 1 | grep -v "^$" | wc -l) - 1))
12    else
13        nr_bridges=$(bridge link | wc -l)
14    fi
15    if [ "$nr_bridges" != 1 ]
16	then
17	fatal "no bridge specified, and don't know which one to use ($nr_bridges found)"
18    fi
19    if which brctl >&/dev/null; then
20        bridge=$(brctl show | cut -d "
21" -f 2 | cut -f 1)
22    else
23        bridge=$(bridge link | cut -d" " -f6)
24    fi
25fi
26
27command="$1"
28shift
29
30case "$command" in
31    "online")
32	if [ "$bridge" != "-" ]
33	    then
34	    setup_virtual_bridge_port "$vif"
35	    add_to_bridge "$bridge" "$vif"
36	else
37	    # Just let the normal udev rules for interfaces handle it.
38	    true
39	fi
40	success
41	;;
42
43    "add")
44	success
45	;;
46
47    "remove")
48	;;
49
50    *)
51	echo "Unknown command: $command"
52	echo 'Valid commands are: add, remove, online'
53	exit 1
54esac
55