From af62bc1c60937ee2cad5cc5a9c52ca3ba0e1da12 Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Sat, 23 Sep 2023 16:43:31 +0800 Subject: [PATCH] git --- docker/git/src/init_user.sh | 2 +- docker/git/src/s6/user/setup | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) 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