github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/ci/cli-dev-bosh-lite/tasks/check-pool-size.sh (about) 1 #!/bin/bash 2 3 set -eu 4 5 # ENV 6 : "${MIN_UNCLAIMED_COUNT:?}" 7 : "${POOL_NAME:="bosh-lites"}" 8 : "${BUILDING_POOL_NAME:="building-bosh-lites"}" 9 : "${GIT_USERNAME:="CLI CI"}" 10 : "${GIT_EMAIL:="cf-cli-eng+ci@pivotal.io"}" 11 : "${TRIGGER_FILE_NAME:=".trigger-bosh-lites-create"}" 12 13 # INPUTS 14 script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 15 workspace_dir="$( cd "${script_dir}/../../../../" && pwd )" 16 pool_dir="${workspace_dir}/env-pool" 17 18 # OUTPUTS 19 output_dir="${workspace_dir}/updated-env-pool" 20 21 git clone "${pool_dir}" "${output_dir}" 22 23 pushd "${output_dir}" > /dev/null 24 echo "Searching for bosh-lites..." 25 26 ready_count="$(find "${POOL_NAME}/unclaimed" -not -path '*/\.*' -type f | wc -l)" 27 echo "Ready bosh-lites: ${ready_count}" 28 building_count="$(find "${BUILDING_POOL_NAME}/claimed" -not -path '*/\.*' -type f | wc -l)" 29 echo "Building bosh-lites: ${building_count}" 30 31 env_count=$((ready_count + building_count)) 32 echo "Total count: ${env_count}" 33 34 if [ "${env_count}" -lt "${MIN_UNCLAIMED_COUNT}" ]; then 35 echo "Fewer than ${MIN_UNCLAIMED_COUNT} bosh-lites, going to trigger creation" 36 # The create-bosh-lite job watches this file for changes 37 date +%s > $TRIGGER_FILE_NAME 38 39 git config user.name "${GIT_USERNAME}" 40 git config user.email "${GIT_EMAIL}" 41 git add $TRIGGER_FILE_NAME 42 git commit -m "Not enough unclaimed envs in ${POOL_NAME} or ${BUILDING_POOL_NAME} pools, updating trigger." 43 fi 44 popd > /dev/null 45 46 echo "DONE"