# along with IPFire; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# #
-# Copyright (C) 2012 IPFire Team <info@ipfire.org> #
+# Copyright (C) 2015 IPFire Team <info@ipfire.org> #
# #
############################################################################
+[ -n "${INTERFACE}" ] || exit 2
+
CONFIG_FILE="/var/ipfire/ethernet/vlans"
# Skip immediately if no configuration file has been found.
eval $(/usr/local/bin/readhash ${CONFIG_FILE})
-# This is start or stop.
-action=${1}
-
for interface in green0 red0 blue0 orange0; do
case "${interface}" in
green*)
;;
esac
- 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." >&2
- continue
- fi
-
- # Check if the parent interface exists.
- 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." >&2
- continue
- fi
+ # If the parent device does not match the interface that
+ # has just come up, we will go on for the next one.
+ [ "${PARENT_DEV}" = "${INTERFACE}" ] || continue
- # Build command line.
- command="ip link add link ${PARENT_DEV} name ${interface}"
- if [ -n "${MAC_ADDRESS}" ]; then
- command="${command} address ${MAC_ADDRESS}"
- fi
- command="${command} type vlan id ${VLAN_ID}"
+ # 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." >&2
+ continue
+ fi
- echo "Creating VLAN interface ${interface}..."
- ${command}
+ if [ -z "${VLAN_ID}" ]; then
+ echo "${interface}: You did not set the VLAN ID." >&2
+ continue
+ fi
- # Bring up the parent device.
- ip link set ${PARENT_DEV} up
- ;;
+ # Build command line.
+ command="ip link add link ${PARENT_DEV} name ${interface}"
+ if [ -n "${MAC_ADDRESS}" ]; then
+ command="${command} address ${MAC_ADDRESS}"
+ fi
+ command="${command} type vlan id ${VLAN_ID}"
- stop)
- if [ ! -e "/proc/net/vlan/${interface}" ]; then
- echo "${interface} is not a VLAN interface. Skipping."
- continue
- fi
+ echo "Creating VLAN interface ${interface}..."
+ ${command}
- echo "Removing VLAN interface ${interface}..."
- ip link set ${interface} down
- ip link delete ${interface}
- ;;
-
- *)
- echo "Invalid action: ${action}"
- exit 1
- ;;
- esac
+ # Bring up the parent device.
+ ip link set ${PARENT_DEV} up
done
+
+exit 0