install.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #! /bin/bash
  2. # Copyright 2016 The Kubernetes 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. # This volume is assumed to exist and is shared with parent of the init
  16. # container. It contains the zookeeper installation.
  17. INSTALL_VOLUME="/opt"
  18. # This volume is assumed to exist and is shared with the peer-finder
  19. # init container. It contains on-start/change configuration scripts.
  20. WORKDIR_VOLUME="/work-dir"
  21. # As of April-2016 is 3.4.8 is the latest stable, but versions 3.5.0 onward
  22. # allow dynamic reconfiguration.
  23. VERSION="3.5.0-alpha"
  24. for i in "$@"
  25. do
  26. case $i in
  27. -i=*|--install-into=*)
  28. INSTALL_VOLUME="${i#*=}"
  29. shift
  30. ;;
  31. -w=*|--work-dir=*)
  32. WORKDIR_VOLUME="${i#*=}"
  33. shift
  34. ;;
  35. *)
  36. # unknown option
  37. ;;
  38. esac
  39. done
  40. echo installing config scripts into "${WORKDIR_VOLUME}"
  41. mkdir -p "${WORKDIR_VOLUME}"
  42. cp /on-start.sh "${WORKDIR_VOLUME}"/
  43. cp /peer-finder "${WORKDIR_VOLUME}"/
  44. echo installing zookeeper-"${VERSION}" into "${INSTALL_VOLUME}"
  45. mkdir -p "${INSTALL_VOLUME}"
  46. mv /zookeeper "${INSTALL_VOLUME}"/zookeeper
  47. cp "${INSTALL_VOLUME}"/zookeeper/conf/zoo_sample.cfg "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
  48. # TODO: Should dynamic config be tied to the version?
  49. IFS="." read -ra RELEASE <<< "${VERSION}"
  50. if [ "$(("${RELEASE[1]}"))" -gt 4 ]; then
  51. echo zookeeper-"${VERSION}" supports dynamic reconfiguration, enabling it
  52. echo "standaloneEnabled=false" >> "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
  53. echo "dynamicConfigFile=${INSTALL_VOLUME}/zookeeper/conf/zoo.cfg.dynamic" >> "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
  54. fi
  55. # TODO: This is a hack, netcat is convenient to have in the zookeeper container
  56. # I want to avoid using a custom zookeeper image just for this. So copy it.
  57. NC=$(which nc)
  58. if [ "${NC}" != "" ]; then
  59. echo copying nc into "${INSTALL_VOLUME}"
  60. cp "${NC}" "${INSTALL_VOLUME}"
  61. fi