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
1 #!/bin/sh
2
3 PATH=.:/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:`dirname $0`
4
5 MAX_RETRY=10
6 RETRY_INTERVAL=10
7
8 if ! tty -s; then
9   echo `date '+%Y-%m-%d %H:%M:%S %z'`' fly prune-workers ...'
10 fi
11
12 if [ `whoami` != 'root' ]; then
13   echo 'ERROR: This script requires the root privilege.' >&2
14   exit 1
15 fi
16
17 . <%= node['concourse-ci']['docker-compose']['app_dir'] %>/.env
18
19 for num in `seq 0 ${MAX_RETRY}`; do
20   if [ $num != 0 ]; then
21     echo "Retrying ${num}/${MAX_RETRY}..."
22     sleep ${RETRY_INTERVAL}s
23   fi
24   fly login -t main -u <%= @basic_auth_username %> -p $CONCOURSE_BASIC_AUTH_PASSWORD -c <%= @external_url %>
25
26   if [ $? -eq 0 ]; then
27     break
28   fi
29   if [ $num = $MAX_RETRY ]; then
30     echo 'ERROR: Concourse server connection refused.' >&2 
31     exit 1
32   fi
33 done
34
35 fly_prune_workers -t main