OSDN Git Service

improves the utility scripts.
[metasearch/grid-chef-repo.git] / cookbooks / concourse-ci / templates / default / opt / docker-compose / app / concourse / bin / fly_prune_workers_main
index 6d0e3ab..192979b 100644 (file)
@@ -5,7 +5,9 @@ PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
 MAX_RETRY=10
 RETRY_INTERVAL=10
 
-echo `date '+%Y-%m-%d %H:%M:%S %z'`' fly prune-workers ...'
+if ! tty -s; then
+  echo `date '+%Y-%m-%d %H:%M:%S %z'`' fly prune-workers ...'
+fi
 
 if [ `whoami` != 'root' ]; then
   echo 'ERROR: This script requires the root privilege.' >&2
@@ -17,17 +19,16 @@ fi
 for num in `seq 0 ${MAX_RETRY}`; do
   if [ $num != 0 ]; then
     echo "Retrying ${num}/${MAX_RETRY}..."
+    sleep ${RETRY_INTERVAL}s
   fi
   fly login -t main -u <%= @basic_auth_username %> -p $CONCOURSE_BASIC_AUTH_PASSWORD -c <%= @external_url %>
 
   if [ $? -eq 0 ]; then
     break
-  else
-    if [ $num = $MAX_RETRY ]; then
-      echo 'ERROR: Concourse server connection refused.' >&2 
-      exit 1
-    fi
-    sleep ${RETRY_INTERVAL}s
+  fi
+  if [ $num = $MAX_RETRY ]; then
+    echo 'ERROR: Concourse server connection refused.' >&2 
+    exit 1
   fi
 done