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.

79 lines
1.9 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. . lib/common
  11. set -e
  12. if [ -e "$HOST_CONFIG_FILE" ]; then
  13. echo > "$HOST_CONFIG_FILE"
  14. else
  15. mkdir -p "$(dirname "$HOST_CONFIG_FILE")"
  16. touch "$HOST_CONFIG_FILE"
  17. fi
  18. init-config-add "
  19. $SERVICE_NAME:
  20. volumes:
  21. - $HOST_CONFIG_FILE:$CONFIG_FILE
  22. "
  23. ini_merge <<EOF || exit 1
  24. version: 0.1
  25. storage:
  26. filesystem:
  27. rootdirectory: /var/lib/docker-registry
  28. http:
  29. addr: $SERVICE_NAME:5000
  30. net: tcp
  31. host: http://$SERVICE_NAME:5000
  32. ## XXXvlab: not used for now
  33. #secret: asecretforlocaldevelopment
  34. relativeurls: false
  35. # debug:
  36. # addr: localhost:5001
  37. # headers:
  38. # X-Content-Type-Options: [nosniff]
  39. # http2:
  40. # disabled: false
  41. EOF
  42. ##
  43. ## Merge compose options
  44. ##
  45. service_def=$(get_compose_service_def "$SERVICE_NAME") || return 1
  46. options=$(e "$service_def" | shyaml -y get-value "options") || true
  47. if [ "$options" ]; then
  48. while read-0 key value; do
  49. case "$key" in
  50. auth|storage|middleware|reporting|http|redis|version)
  51. err "You should not configure '$key' in this charm."
  52. exit 1
  53. ;;
  54. log|loglevel|notifications|health|proxy|compatibility|validation)
  55. continue
  56. ;;
  57. *)
  58. err "Unknown key '$key' in options."
  59. exit 1
  60. ;;
  61. esac
  62. done < <(e "$options" | shyaml key-values-0)
  63. e "$options" | ini_merge || exit 1
  64. fi