prepare_build_linux_rc 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # Copyright 2017 gRPC authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Source this rc script to prepare the environment for linux builds
  16. # Need to increase open files limit for c tests
  17. ulimit -n 32768
  18. # 1. Move docker's storage location to scratch disk so we don't run out of space.
  19. # 2. Use container registry mirror for pulling docker images (should make downloads faster)
  20. # See https://cloud.google.com/container-registry/docs/using-dockerhub-mirroring
  21. GRPC_DOCKER_OPTS="--data-root=/tmpfs/docker --registry-mirror=https://mirror.gcr.io"
  22. # Update global docker configuration to have GRPC_DOCKER_OPTS
  23. P1NAME=$(ps -p 1 -o comm=)
  24. if [[ $P1NAME == *"systemd"* ]]; then
  25. # https://stackoverflow.com/questions/27763340
  26. sudo sed -i -E "s|ExecStart=(.*)//|EnvironmentFile=/etc/default/docker\nExecStart=\nExecStart=\1// \$DOCKER_OPTS|" /lib/systemd/system/docker.service
  27. sudo systemctl daemon-reload
  28. echo "DOCKER_OPTS=\"${GRPC_DOCKER_OPTS}\"" | sudo tee --append /etc/default/docker
  29. sudo systemctl restart docker.service
  30. else
  31. echo "DOCKER_OPTS=\"\${DOCKER_OPTS} ${GRPC_DOCKER_OPTS}\"" | sudo tee --append /etc/default/docker
  32. sudo service docker restart
  33. fi
  34. # Download Docker images from DockerHub
  35. export DOCKERHUB_ORGANIZATION=grpctesting
  36. git submodule update --init
  37. python3 -m pip install six