# Skip immediately if no configuration file has been found.
[ -e "${CONFIG_FILE}" ] || exit 0
-eval $(readhash ${CONFIG_FILE})
+eval $(/usr/local/bin/readhash ${CONFIG_FILE})
# This is start or stop.
action=${1}
-for interface in green0 blue0 orange0; do
+for interface in green0 red0 blue0 orange0; do
case "${interface}" in
green*)
PARENT_DEV=${GREEN_PARENT_DEV}
VLAN_ID=${GREEN_VLAN_ID}
MAC_ADDRESS=${GREEN_MAC_ADDRESS}
;;
+ red*)
+ PARENT_DEV=${RED_PARENT_DEV}
+ VLAN_ID=${RED_VLAN_ID}
+ MAC_ADDRESS=${RED_MAC_ADDRESS}
+ ;;
blue*)
PARENT_DEV=${BLUE_PARENT_DEV}
VLAN_ID=${BLUE_VLAN_ID}
case "${action}" in
start)
+ # If no parent device has been configured, we assume
+ # that this interface is not set up for VLANs and
+ # silently go on.
+ [ -z "${PARENT_DEV}" ] && continue
+
# Check if the interface does already exists.
# If so, we skip creating it.
if [ -d "/sys/class/net/${interface}" ]; then
- echo "Interface ${interface} already exists."
+ echo "Interface ${interface} already exists." >&2
continue
fi
# Check if the parent interface exists.
- if [ -z "${PARENT_DEV}" ] || [ ! -d "/sys/class/net/${PARENT_DEV}" ]; then
- echo "${interface}: Parent device is not set or does not exist: ${PARENT_DEV}"
+ if [ ! -d "/sys/class/net/${PARENT_DEV}" ]; then
+ echo "${interface}: Parent device is not set or does not exist: ${PARENT_DEV}" >&2
continue
fi
if [ -z "${VLAN_ID}" ]; then
- echo "${interface}: You did not set the VLAN ID."
+ echo "${interface}: You did not set the VLAN ID." >&2
continue
fi
- echo "Creating VLAN interface ${interface}..."
- vconfig add ${PARENT_DEV} ${VLAN_ID}
- ip link set ${PARENT_DEV}.${VLAN_ID} name ${interface}
-
+ # Build command line.
+ command="ip link add link ${PARENT_DEV} name ${interface}"
if [ -n "${MAC_ADDRESS}" ]; then
- ip link set ${interface} address ${MAC_ADDRESS}
+ command="${command} address ${MAC_ADDRESS}"
fi
+ command="${command} type vlan id ${VLAN_ID}"
+
+ echo "Creating VLAN interface ${interface}..."
+ ${command}
# Bring up the parent device.
ip link set ${PARENT_DEV} up
echo "Removing VLAN interface ${interface}..."
ip link set ${interface} down
- vconfig rem ${interface}
+ ip link delete ${interface}
;;
*)