X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=docker-build%2Fregistry%2Fcommon_scripts%2Fwait-for-files;fp=docker-build%2Fregistry%2Fcommon_scripts%2Fwait-for-files;h=7d59ec3bb6733ae9396534b4b8a67ab6653e8c48;hb=2ed671c54dad28dd81763928b28cd17d5c76df66;hp=0000000000000000000000000000000000000000;hpb=2c8d12e674aa66af96cd6d2d750f061092db95df;p=ta%2Fcaas-registry.git diff --git a/docker-build/registry/common_scripts/wait-for-files b/docker-build/registry/common_scripts/wait-for-files new file mode 100755 index 0000000..7d59ec3 --- /dev/null +++ b/docker-build/registry/common_scripts/wait-for-files @@ -0,0 +1,46 @@ +#!/bin/sh +# Copyright 2019 Nokia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +file_names=$1 +retry_counter=${2:-12} +echo ${retry_counter} +I=0 +Err_Flag=1 + +while [ $Err_Flag -ne 0 ] && [ $I -lt ${retry_counter} ] +do + Err_Flag=0 + for i in ${file_names}; + do + if [ ! -e "${i}" ] + then + Err_Flag=$((Err_Flag+1)) + fi + done + if [ $Err_Flag -ne 0 ] + then + I=$((I+1)) + sleep 5 + fi +done + +if [ $I -ge ${retry_counter} ] +then + echo "WARNING: At least one of the following file not found: ${file_names} !" + echo "WARNING: Exiting!" + exit 1 +else + echo "INFO: ${file_names} files found." +fi