3 # ============LICENSE_START====================================================
5 # ===========================================================================
6 # Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
7 # ===========================================================================
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
19 # ============LICENSE_END====================================================
22 # A Script for use in Pods... Check for status files, and validate before moving on.
24 DIR="/opt/app/aaf/status"
29 if [ -d "$DIR" ]; then
30 echo "$@" > $DIR/$APP-$HOSTNAME
36 if [ -d "$DIR" ]; then
37 if [ -z "$(ls $DIR/$OTHER* 2> /dev/null)" ]; then
38 echo "$DIR/$OTHER does not exist"
40 echo "$(cat $DIR/$OTHER*)"
43 echo "$DIR does not exist"
49 while [ $n -lt 40 ]; do
52 if [ -z "$(echo $rv | grep "ready")" ]; then
54 echo "Sleep 10 (iteration $n)"
65 while [ $n -lt 40 ]; do
66 echo "Waiting for Network Access to $@"
67 status "Waiting for Network Access to $1 $2"
68 rv="$(nc -zvw 5 $1 $2 2>&1 | grep -e "[open|succeed]")"
71 if [[ "$rv" == *open* ]] || [[ "$rv" == *succeeded* ]]; then
72 status "Network Connectable to $1 $2"
76 echo "Sleep 10 (iteration $n)"
84 while [ $n -lt 40 ]; do
87 if [ -z "$(echo $rv | grep "ready")" ]; then
89 echo "Sleep 10 (iteration $n)"
92 # This is critical. Until status is literally "ready" in the status directory, no processes will start
100 while [ ! -z "$1" ]; do
127 echo "Removing $DIR/$APP-$HOSTNAME"
128 rm -f $DIR/$APP-$HOSTNAME
136 echo "App $APP is waiting to start until $OTHER is ready"
137 status "waiting for $OTHER"