k8s.io/kubernetes@v1.29.3/test/images/pets/zookeeper-installer/install.sh (about)

     1  #! /bin/bash
     2  
     3  # Copyright 2016 The Kubernetes Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  # This volume is assumed to exist and is shared with parent of the init
    18  # container. It contains the zookeeper installation.
    19  INSTALL_VOLUME="/opt"
    20  
    21  # This volume is assumed to exist and is shared with the peer-finder
    22  # init container. It contains on-start/change configuration scripts.
    23  WORKDIR_VOLUME="/work-dir"
    24  
    25  # As of April-2016 is 3.4.8 is the latest stable, but versions 3.5.0 onward
    26  # allow dynamic reconfiguration.
    27  VERSION="3.5.0-alpha"
    28  
    29  for i in "$@"
    30  do
    31  case $i in
    32      -i=*|--install-into=*)
    33      INSTALL_VOLUME="${i#*=}"
    34      shift
    35      ;;
    36      -w=*|--work-dir=*)
    37      WORKDIR_VOLUME="${i#*=}"
    38      shift
    39      ;;
    40      *)
    41      # unknown option
    42      ;;
    43  esac
    44  done
    45  
    46  echo installing config scripts into "${WORKDIR_VOLUME}"
    47  mkdir -p "${WORKDIR_VOLUME}"
    48  cp /on-start.sh "${WORKDIR_VOLUME}"/
    49  cp /peer-finder "${WORKDIR_VOLUME}"/
    50  
    51  echo installing zookeeper-"${VERSION}" into "${INSTALL_VOLUME}"
    52  mkdir -p "${INSTALL_VOLUME}"
    53  mv /zookeeper "${INSTALL_VOLUME}"/zookeeper
    54  cp "${INSTALL_VOLUME}"/zookeeper/conf/zoo_sample.cfg "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
    55  
    56  # TODO: Should dynamic config be tied to the version?
    57  IFS="." read -ra RELEASE <<< "${VERSION}"
    58  if [ "$(("${RELEASE[1]}"))" -gt 4 ]; then
    59      echo zookeeper-"${VERSION}" supports dynamic reconfiguration, enabling it
    60      echo "standaloneEnabled=false" >> "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
    61      echo "dynamicConfigFile=${INSTALL_VOLUME}/zookeeper/conf/zoo.cfg.dynamic" >> "${INSTALL_VOLUME}"/zookeeper/conf/zoo.cfg
    62  fi
    63  
    64  # TODO: This is a hack, netcat is convenient to have in the zookeeper container
    65  # I want to avoid using a custom zookeeper image just for this. So copy it.
    66  NC=$(which nc)
    67  if [ "${NC}" != "" ]; then
    68      echo copying nc into "${INSTALL_VOLUME}"
    69      cp "${NC}" "${INSTALL_VOLUME}"
    70  fi