diff --git a/gitea/gitea.yaml b/gitea/gitea.yaml index 17f2730..7c00d4b 100644 --- a/gitea/gitea.yaml +++ b/gitea/gitea.yaml @@ -125,6 +125,7 @@ metadata: data: startup.sh: | #!/bin/sh + set -eu echo "startup..." if test ! -f "/data/startup.ran"; then echo "waiting 60s for startup..." @@ -140,7 +141,10 @@ data: su git -c 'ARGOCD_PW=`cat /data/argocd.pw` && gitea admin user create --username argocd --password $ARGOCD_PW --email argocd@undercloud.local --must-change-password=false' su git -c 'GITEA_PW=`cat /data/gitea.pw` && gitea admin auth add-ldap --name ldap --security-protocol StartTLS --host ldap.undercloud.local. --port 389 --user-search-base "ou=users,dc=undercloud,dc=cf" --user-filter "(&(objectClass=person)(uid=%s))" --admin-filter "(&(memberOf=cn=gitea-admins,ou=groups,dc=undercloud,dc=cf))" --email-attribute mail --avatar-attribute jpegPhoto --synchronize-users --skip-tls-verify --username-attribute uid --bind-dn "cn=gitea,ou=serviceaccounts,ou=users,dc=undercloud,dc=cf" --bind-password $GITEA_PW --attributes-in-bind --firstname-attribute cn --surname-attribute sn' - sleep 30s + echo "waiting for gitea http..." + until curl -fsS http://127.0.0.1:3000/api/v1/version >/dev/null; do + sleep 2 + done echo "wget tea..." wget http://git.undercloud.local:3000/Undercloud/undercloud-infrastructure/raw/branch/main/k8s-binaries/tea #echo "wget ctea..." @@ -153,7 +157,10 @@ data: #./tea login default localhost:3000 echo "creating Undercloud organisation" - sleep 30s + echo "waiting for gitea http..." + until curl -fsS http://127.0.0.1:3000/api/v1/version >/dev/null; do + sleep 2 + done #./tea organization create Undercloud #./ctea --username shodan --password $SHODAN_PW --url http://localhost:3000 CreateOrg Undercloud curl -s -u "shodan:$SHODAN_PW" \ @@ -170,12 +177,16 @@ data: sleep 5s # create team "Undercloud" in org "undercloud" - curl -s -u "shodan:$SHODAN_PW" -H 'Content-Type: application/json' \ + curl -fs -u "shodan:$SHODAN_PW" -H 'Content-Type: application/json' \ -X POST http://localhost:3000/api/v1/orgs/undercloud/teams \ -d '{"name":"Undercloud","permission":"write","includes_all_repositories":false, "units":["repo.code","repo.issues","repo.pulls","repo.releases","repo.wiki","repo.projects"]}' # get team id without jq + echo "waiting for gitea http..." + until curl -fsS http://127.0.0.1:3000/api/v1/version >/dev/null; do + sleep 2 + done TEAM_ID=$( curl -s -u "shodan:$SHODAN_PW" \ "http://localhost:3000/api/v1/orgs/undercloud/teams/search?q=Undercloud&limit=1" | @@ -190,6 +201,10 @@ data: echo "cloning k8s-apps" + echo "waiting for gitea http..." + until curl -fsS http://127.0.0.1:3000/api/v1/version >/dev/null; do + sleep 2 + done #execline-cd /data git clone http://git.undercloud.local:3000/undercloud/k8s-apps.git execline-cd /data git clone "http://shodan:${SHODAN_PW}@git.undercloud.local:3000/Undercloud/k8s-apps.git" @@ -217,7 +232,11 @@ data: # curl -sS -u "shodan:${SHODAN_PW}" -X POST http://localhost:3000/api/v1/repos/Undercloud/k8s-apps/push_mirrors-sync - echo "cloning assets" + echo "cloning assets" + echo "waiting for gitea http..." + until curl -fsS http://127.0.0.1:3000/api/v1/version >/dev/null; do + sleep 2 + done execline-cd /data git clone "http://shodan:${SHODAN_PW}@git.undercloud.local:3000/Undercloud/assets.git" execline-cd /data/assets rm -Rf .git @@ -231,6 +250,10 @@ data: echo "delete local copy..." #execline-cd /data rm -Rf assets + echo "waiting for gitea http..." + until curl -fsS http://127.0.0.1:3000/api/v1/version >/dev/null; do + sleep 2 + done echo "create PushMirror.." # Add push mirror to Undercloud/assets curl -sS -u "shodan:${SHODAN_PW}" \