diff --git a/docker/git/src/init_user.sh b/docker/git/src/init_user.sh index ee82b8d2..675b281b 100644 --- a/docker/git/src/init_user.sh +++ b/docker/git/src/init_user.sh @@ -25,7 +25,7 @@ admin_email="help@websoft9.com" if [ -e "$cred_path" ]; then echo "File $cred_path exists. Exiting script." - exit 1 + exit 0 fi echo "create diretory" diff --git a/docker/git/src/s6/user/setup b/docker/git/src/s6/user/setup index 56925515..675b281b 100644 --- a/docker/git/src/s6/user/setup +++ b/docker/git/src/s6/user/setup @@ -1,25 +1,36 @@ #!/bin/bash -echo "start create user shell" - +echo "start create user shell" >> /tmp/user set -e +# Confirm gitea is running +count=1 +response="" +while [ "$response" != "200" ]; do + response=$(curl -s -o /dev/null -w "%{http_code}" localhost:3000) + if [ "$response" = "200" ]; then + echo "gitea is runing" + break + fi + count=$((count+1)) + if [ $count -gt 10 ]; then + echo "gitea is not runing" + break + fi +done + cred_path="/var/websoft9/credential" admin_username="websoft9" admin_email="help@websoft9.com" if [ -e "$cred_path" ]; then echo "File $cred_path exists. Exiting script." - exit 1 + exit 0 fi echo "create diretory" mkdir -p "$(dirname "$cred_path")" - -# TODO IF admin is exists, echo it to cred_path -# TODO wait culr localhost:3000 - echo "Create admin credential by admin cli" su -c " gitea admin user create --admin --username '$admin_username' --random-password --email '$admin_email' > /tmp/credential