fork 0k-charms
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.

63 lines
1.5 KiB

  1. #!/bin/bash
  2. ## Init is run on host
  3. ## For now it is run every time the script is launched, but
  4. ## it should be launched only once after build.
  5. ## Accessible variables are:
  6. ## - SERVICE_NAME Name of current service
  7. ## - DOCKER_BASE_IMAGE Base image from which this service might be built if any
  8. ## - SERVICE_DATASTORE Location on host of the DATASTORE of this service
  9. ## - SERVICE_CONFIGSTORE Location on host of the CONFIGSTORE of this service
  10. set -e
  11. . lib/common
  12. mode="$(options-get mode)" || exit 1
  13. case "$mode" in
  14. single)
  15. capacity="$(options-get capacity)" || exit 1
  16. init-config-add "\
  17. $MASTER_BASE_SERVICE_NAME:
  18. environment:
  19. DRONE_RUNNER_CAPACITY: $capacity
  20. volumes:
  21. - /var/run/docker.sock:/var/run/docker.sock
  22. "
  23. ;;
  24. multi)
  25. secret="$(options-get secret)" || {
  26. err "In 'multi' mode, you must set a 'secret' in $DARKYELLOW$SERVICE_NAME$NORMAL service's" \
  27. "options to share with slave drones."
  28. echo " You can use: 'openssl rand -hex 16' to create one." >&2
  29. exit 1
  30. }
  31. init-config-add "\
  32. $MASTER_BASE_SERVICE_NAME:
  33. environment:
  34. DRONE_RPC_SECRET: $secret
  35. "
  36. ;;
  37. esac
  38. admin="$(options-get admin)" || exit 1
  39. if [ "$admin" ]; then
  40. init-config-add "\
  41. $MASTER_BASE_SERVICE_NAME:
  42. environment:
  43. DRONE_USER_CREATE: \"username:$admin,admin:true\"
  44. "
  45. fi
  46. init-config-add "\
  47. $MASTER_BASE_SERVICE_NAME:
  48. environment:
  49. DRONE_SERVER_HOST: $MASTER_BASE_SERVICE_NAME
  50. DRONE_SERVER_PROTO: http
  51. "