This commit is contained in:
qiaofeng1227 2023-09-21 17:49:14 +08:00
parent 0933bc4f9b
commit e966a5873b

View file

@ -4,24 +4,48 @@ set -e
trap "sleep 1; continue" ERR
counter=0
while true; do
set +e
echo "copy git credential"
docker cp websoft9-git:/var/websoft9/credential /data/websoft9/credential_git
docker cp /data/websoft9/credential_git websoft9-apphub:/websoft9/credentials
echo "copy deployment credential"
docker cp websoft9-deployment:/var/websoft9/credential /data/websoft9/credential_deployment
content=$(cat /data/websoft9/credential_deployment)
username="admin"
json="{\"username\":\"$username\",\"password\":\"$content\"}"
echo "$json" > /data/websoft9/credential_deployment
docker cp /data/websoft9/credential_deployment websoft9-apphub:/websoft9/credentials
echo "wait nginx..."
docker cp websoft9-proxy:/var/websoft9/credential /data/websoft9/credential_proxy
docker cp /data/websoft9/credential_proxy websoft9-apphub:/websoft9/credentials
if [ -f "/data/websoft9/credential_git" ]; then
echo "/data/websoft9/credential_git is exist"
else
echo "copy git credential"
docker cp websoft9-git:/var/websoft9/credential /data/websoft9/credential_git
docker cp /data/websoft9/credential_git websoft9-apphub:/websoft9/credentials
fi
if [ -f "/data/websoft9/credential_deployment" ]; then
echo "/data/websoft9/credential_deployment is exist"
else
echo "copy deployment credential"
docker cp websoft9-deployment:/var/websoft9/credential /data/websoft9/credential_deployment
content=$(cat /data/websoft9/credential_deployment)
username="admin"
json="{\"username\":\"$username\",\"password\":\"$content\"}"
echo "$json" > /data/websoft9/credential_deployment
docker cp /data/websoft9/credential_deployment websoft9-apphub:/websoft9/credentials
fi
if [ -f "/data/websoft9/credential_proxy" ]; then
echo "/data/websoft9/credential_proxy is exist"
else
echo "copy nginx credential ..."
docker cp websoft9-proxy:/var/websoft9/credential /data/websoft9/credential_proxy
docker cp /data/websoft9/credential_proxy websoft9-apphub:/websoft9/credentials
fi
if [ -f "/data/websoft9/credential_git" ] && [ -f "/data/websoft9/credential_deployment" ] && [ -f "/data/websoft9/credential_proxy" ]; then
exit 0
else
if [ $counter -gt 30 ]; then
echo "Systemd can not get all credentials by excuting 30 times"
exit 1
fi
fi
set -e
sleep 3
done