build.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/sh
  2. set -e -x
  3. rm -rf ./build
  4. mkdir ./build
  5. if [ "$SMOKE_OVERLAY_IPV6" ]
  6. then
  7. LIGHTHOUSE_NIP="fd00:4242:0:0:0:ffff:c0a8:6401"
  8. HOST2_NIP="fd00:4242:0:0:0:ffff:c0a8:6402"
  9. HOST3_NIP="fd00:4242:0:0:0:ffff:c0a8:6403"
  10. HOST4_NIP="fd00:4242:0:0:0:ffff:c0a8:6404"
  11. else
  12. LIGHTHOUSE_NIP="192.168.100.1"
  13. HOST2_NIP="192.168.100.2"
  14. HOST3_NIP="192.168.100.3"
  15. HOST4_NIP="192.168.100.4"
  16. fi
  17. # Smoke containers run on a dedicated docker network whose subnet is allocated
  18. # at smoke time, not known at build time. Configs are written with TEST-NET-3
  19. # placeholder IPs (RFC 5737) and smoke.sh / smoke-vagrant.sh / smoke-relay.sh
  20. # sed the real container IPs in before starting nebula.
  21. #
  22. # Placeholder mapping (last octet == fixed container slot):
  23. # 203.0.113.2 -> lighthouse1, 203.0.113.3 -> host2,
  24. # 203.0.113.4 -> host3, 203.0.113.5 -> host4.
  25. LIGHTHOUSE_IP="203.0.113.2"
  26. (
  27. cd build
  28. cp ../../../../build/linux-amd64/nebula .
  29. cp ../../../../build/linux-amd64/nebula-cert .
  30. if [ "$1" ]
  31. then
  32. cp "../../../../build/$1/nebula" "$1-nebula"
  33. fi
  34. HOST="lighthouse1" \
  35. AM_LIGHTHOUSE=true \
  36. ../genconfig.sh >lighthouse1.yml
  37. HOST="host2" \
  38. LIGHTHOUSES="$LIGHTHOUSE_NIP $LIGHTHOUSE_IP:4242" \
  39. ../genconfig.sh >host2.yml
  40. HOST="host3" \
  41. LIGHTHOUSES="$LIGHTHOUSE_NIP $LIGHTHOUSE_IP:4242" \
  42. INBOUND='[{"port": "any", "proto": "icmp", "group": "lighthouse"}]' \
  43. ../genconfig.sh >host3.yml
  44. HOST="host4" \
  45. LIGHTHOUSES="$LIGHTHOUSE_NIP $LIGHTHOUSE_IP:4242" \
  46. OUTBOUND='[{"port": "any", "proto": "icmp", "group": "lighthouse"}]' \
  47. ../genconfig.sh >host4.yml
  48. ../../../../nebula-cert ca -curve "${CURVE:-25519}" -name "Smoke Test"
  49. ../../../../nebula-cert sign -name "lighthouse1" -groups "lighthouse,lighthouse1" -ip "$LIGHTHOUSE_NIP/24"
  50. ../../../../nebula-cert sign -name "host2" -groups "host,host2" -ip "$HOST2_NIP/24"
  51. ../../../../nebula-cert sign -name "host3" -groups "host,host3" -ip "$HOST3_NIP/24"
  52. ../../../../nebula-cert sign -name "host4" -groups "host,host4" -ip "$HOST4_NIP/24"
  53. )
  54. docker build -t "nebula:${NAME:-smoke}" .