2023-09-19 15:40:14 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
trap "sleep 1; continue" ERR
|
|
|
|
|
2023-09-22 10:16:52 +08:00
|
|
|
try_times=30
|
2023-09-21 18:06:35 +08:00
|
|
|
counter=1
|
2023-09-22 10:16:52 +08:00
|
|
|
|
2023-09-20 14:44:46 +08:00
|
|
|
while true; do
|
2023-09-20 15:08:31 +08:00
|
|
|
|
2023-09-21 17:49:14 +08:00
|
|
|
set +e
|
2023-09-20 15:08:31 +08:00
|
|
|
|
2023-09-21 18:06:35 +08:00
|
|
|
echo Try to get credentia for $counter times
|
2023-09-21 17:49:14 +08:00
|
|
|
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
|
2023-09-21 18:06:35 +08:00
|
|
|
break
|
2023-09-21 17:49:14 +08:00
|
|
|
else
|
2023-09-22 10:16:52 +08:00
|
|
|
if [ $counter -gt $try_times ]; then
|
2023-09-21 17:49:14 +08:00
|
|
|
echo "Systemd can not get all credentials by excuting 30 times"
|
2023-09-21 18:06:35 +08:00
|
|
|
break
|
2023-09-21 17:49:14 +08:00
|
|
|
fi
|
|
|
|
fi
|
2023-09-20 14:44:46 +08:00
|
|
|
sleep 3
|
2023-09-22 10:16:52 +08:00
|
|
|
set -e
|
|
|
|
|
2023-09-21 18:06:35 +08:00
|
|
|
done
|
|
|
|
tail -f /dev/null
|