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.

37 lines
1.2 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. PASSWORD_SET_CONTROL="$SERVICE_CONFIGSTORE/.password-set-control"
  11. set -e
  12. if [ -e "$PASSWORD_SET_CONTROL" ]; then
  13. exit 0
  14. fi
  15. containers=($(get_running_containers_for_service "$SERVICE_NAME"))
  16. if [ "${#containers[@]}" == 0 ]; then
  17. err "no containers found for service ${DARKYELLOW}$SERVICE_NAME${NORMAL}"
  18. exit 1
  19. fi
  20. ## It is not possible at first glance to reset password, so we decided
  21. ## to set to admin/admin. This means it is important to change the
  22. ## admin password as soon as possible.
  23. ## XXXvlab: taking the first container
  24. container_id="${containers[0]}"
  25. docker exec "$container_id" \
  26. /opt/jboss/keycloak/bin/add-user-keycloak.sh \
  27. -u "admin" -p "admin"
  28. docker restart "$container_id"
  29. mkdir -p "${PASSWORD_SET_CONTROL%/*}" && touch "$PASSWORD_SET_CONTROL"