1
0

build.sh 1.8 KB

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