blob: ba8cf24b46ba19ca8710c196c453e84f8c52b86a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/sh
set -eu
# guessing parameters
case "$IFACE" in
*:*) exit 0 ;;
*.*) exit 0 ;;
vlan*) exit 0 ;;
*#[0-9]*) GUESSED_RAW_DEVICE="${IFACE%#*}" ;;
*) [ -n "${IF_MVLAN_RAW_DEVICE:-}" ] || exit 0 ;;
esac
RAW_DEVICE="${IF_MVLAN_RAW_DEVICE:-${GUESSED_RAW_DEVICE:-}}"
device_creation_error() {
echo "Failed to create vlan device $IFACE on device $RAW_DEVICE with tag $VLAN_ID"
exit 1
}
if [ -z "$RAW_DEVICE" ]; then
echo "RAW_DEVICE for $IFACE is not set"
exit 1
fi
if ! ip link show "$RAW_DEVICE" >/dev/null; then
echo "Device $RAW_DEVICE for $IFACE does not exist"
exit 1
fi
if ! ip link show "$IFACE" >/dev/null 2>&1; then
ip link add link "$RAW_DEVICE" name "$IFACE" type macvlan || \
device_creation_error
fi
|