mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-25 09:00:26 +00:00
51 lines
No EOL
1.7 KiB
Bash
51 lines
No EOL
1.7 KiB
Bash
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
trap "sleep 1; continue" ERR
|
|
|
|
counter=0
|
|
while true; do
|
|
|
|
set +e
|
|
|
|
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 |