Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.34 KB | None | 0 0
  1. #!/bin/bash
  2. # vim: set ts=8 sw=2 sts=2 et sta fileencoding=utf-8:
  3.  
  4. # Define a VLAN interface in network interfaces file.
  5. # Usage:
  6. # iface foo inet <static|manual|dhcp|...>
  7. #     vlan-master <interface>
  8. #     vlan-id <N>
  9. #     ...
  10. #
  11. # Optional:
  12. #     vlan-protocol <802.1Q|802.1ad>
  13. #     vlan-loose-binding <on|off>
  14. #     vlan-gvrp <on|off>
  15. #     vlan-mvrp <on|off>
  16. #     vlan-ingress-qos-map FROM:TO FROM:TO...
  17. #     vlan-egress-qos-map FROM:TO FROM:TO...
  18.  
  19. # No assumptions are made about the vlan-id or master from the interface name.
  20. # You need to specify both vlan-id and vlan-master.
  21.  
  22. [[ -z "${IF_VLAN_ID}" ]] && exit 0
  23. [[ -z "${IF_VLAN_MASTER}" ]] && exit 0
  24.  
  25. run() {
  26.   [[ "${VERBOSITY}" -ge 1 ]] && echo "$@"
  27.   "$@"
  28. }
  29.  
  30. case "${MODE}" in
  31.   start)
  32.     ip link add link "${IF_VLAN_MASTER}" name "${IFACE}" \
  33.       type vlan id "${IF_VLAN_ID}" \
  34.       ${IF_VLAN_PROTOCOL:+protocol ${IF_VLAN_PROTOCOL}} \
  35.       ${IF_VLAN_LOOSE_BINDING:+loose_binding ${IF_VLAN_LOOSE_BINDING}} \
  36.       ${IF_VLAN_GVRP:+gvrp ${GVRP}} \
  37.       ${IF_VLAN_MVRP:+mvrp ${MVRP}} \
  38.       ${IF_VLAN_INGRESS_QOS_MAP:+ingress-qos-map "${IF_VLAN_INGRESS_QOS_MAP}"} \
  39.      ${IF_VLAN_EGRESS_QOS_MAP:+egress-qos-map "${IF_VLAN_EGRESS_QOS_MAP}"}
  40.     ;;
  41.   stop)
  42.     ip link delete "${IFACE}"
  43.     ;;
  44.   *) echo 'Invalid mode:' "${MODE:-none}" >&2; exit 1 ;;
  45. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement