GNS3 Docker Images
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7KB

  1. #!/bin/sh
  2. #
  3. # Startup script for Open vSwitch
  4. #
  5. # Copyright (C) 2015 GNS3 Technologies Inc.
  6. # Copyright (C) 2019 Bernhard Ehlers
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. cust_init="/etc/openvswitch/init.sh"
  21. export PATH="$PATH:/usr/share/openvswitch/scripts"
  22. if [ ! -f "/etc/openvswitch/conf.db" ]; then
  23. # init database and start the daemons
  24. cat /proc/sys/kernel/random/uuid > /etc/openvswitch/system-id.conf
  25. ovs-ctl --system-id=random start
  26. # add bridges br0..br3
  27. x=0
  28. while [ $x -lt 4 ]; do
  29. ovs-vsctl add-br br$x
  30. ovs-vsctl set bridge br$x datapath_type=netdev
  31. x=$((x+1))
  32. done
  33. # add eth interfaces without network configuration to br0
  34. sed -n 's/^ *\(eth[0-9]*\):.*/\1/p' /proc/net/dev | while read -r if; do
  35. grep -q -s "^iface *${if}[. ]" /etc/network/interfaces || \
  36. ovs-vsctl add-port br0 "$if"
  37. done
  38. else
  39. # use existing database and start the daemons
  40. ovs-ctl --system-id=random start
  41. fi
  42. # activate internal bridge interfaces
  43. ovs-vsctl --bare -f table --columns=name find interface type=internal | while read -r if; do
  44. ip link set dev "$if" up
  45. done
  46. # run custom initialization script
  47. [ -f "$cust_init" ] && [ -x "$cust_init" ] && "$cust_init"