install-script 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/bash
  2. set -e
  3. # This script modifies the install.sh script for domains and keys other than
  4. # those used by the primary opensource releases.
  5. #
  6. # You can provide `url`, `yum_url`, `apt_url` and optionally `gpg_fingerprint`
  7. # or `GPG_KEYID` as environment variables, or the defaults for open source are used.
  8. #
  9. # The lower-case variables are substituted into install.sh.
  10. #
  11. # gpg_fingerprint and GPG_KEYID are optional, defaulting to the opensource release
  12. # key ("releasedocker"). Other GPG_KEYIDs will require you to mount a volume with
  13. # the correct contents to /root/.gnupg.
  14. #
  15. # It outputs the modified `install.sh` file to $DOCKER_RELEASE_DIR (default: $DEST)
  16. #
  17. # Example usage:
  18. #
  19. # docker run \
  20. # --rm \
  21. # --privileged \
  22. # -e "GPG_KEYID=deadbeef" \
  23. # -e "GNUPGHOME=/root/.gnupg" \
  24. # -v $HOME/.gnupg:/root/.gnupg \
  25. # -v $(pwd):/go/src/github.com/docker/docker/bundles \
  26. # "$IMAGE_DOCKER" \
  27. # hack/make.sh install-script
  28. : ${DOCKER_RELEASE_DIR:=$DEST}
  29. : ${GPG_KEYID:=releasedocker}
  30. DEFAULT_URL="https://get.docker.com/"
  31. DEFAULT_APT_URL="https://apt.dockerproject.org"
  32. DEFAULT_YUM_URL="https://yum.dockerproject.org"
  33. DEFAULT_GPG_FINGERPRINT="58118E89F3A912897C070ADBF76221572C52609D"
  34. : ${url:=$DEFAULT_URL}
  35. : ${apt_url:=$DEFAULT_APT_URL}
  36. : ${yum_url:=$DEFAULT_YUM_URL}
  37. if [[ "$GPG_KEYID" == "releasedocker" ]] ; then
  38. : ${gpg_fingerprint:=$DEFAULT_GPG_FINGERPRINT}
  39. fi
  40. DEST_FILE="$DOCKER_RELEASE_DIR/install.sh"
  41. bundle_install_script() {
  42. mkdir -p "$DOCKER_RELEASE_DIR"
  43. if [[ -z "$gpg_fingerprint" ]] ; then
  44. # NOTE: if no key matching key is in /root/.gnupg, this will fail
  45. gpg_fingerprint=$(gpg --with-fingerprint -k "$GPG_KEYID" | grep "Key fingerprint" | awk -F "=" '{print $2};' | tr -d ' ')
  46. fi
  47. cp hack/install.sh "$DEST_FILE"
  48. sed -i.bak 's#^url=".*"$#url="'"$url"'"#' "$DEST_FILE"
  49. sed -i.bak 's#^apt_url=".*"$#apt_url="'"$apt_url"'"#' "$DEST_FILE"
  50. sed -i.bak 's#^yum_url=".*"$#yum_url="'"$yum_url"'"#' "$DEST_FILE"
  51. sed -i.bak 's#^gpg_fingerprint=".*"$#gpg_fingerprint="'"$gpg_fingerprint"'"#' "$DEST_FILE"
  52. rm "${DEST_FILE}.bak"
  53. }
  54. bundle_install_script