Skip to content

Commit e445cb1

Browse files
Add check for DockerHub authentication (#184)
Co-authored-by: Evgeniy Antonyuk <[email protected]> Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/DocSpace-buildtools/pulls/184 Co-authored-by: Vladimir Ischenko <[email protected]> Co-committed-by: Vladimir Ischenko <[email protected]>
1 parent 5601215 commit e445cb1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

install/OneClickInstall/install-Docker.sh

+16-4
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,22 @@ install_docker () {
895895
fi
896896
}
897897

898-
docker_login () {
899-
if [[ -n ${USERNAME} && -n ${PASSWORD} ]]; then
900-
docker login ${HUB} --username ${USERNAME} --password ${PASSWORD}
901-
fi
898+
docker_login() {
899+
[[ "$OFFLINE_INSTALLATION" == "true" ]] && return 0
900+
901+
if [[ -f "$HOME/.docker/config.json" ]] && \
902+
jq -r --arg key "${HUB:-https://index.docker.io/v1/}" '.auths | has($key)' "$HOME/.docker/config.json" | grep -q "true"; then
903+
return 0
904+
fi
905+
906+
if [[ "$NON_INTERACTIVE" == "true" ]]; then
907+
[[ -z "$USERNAME" || -z "$PASSWORD" ]] && return 0
908+
else
909+
[[ -z "$USERNAME" ]] && read -rp "Enter DockerHub username: " USERNAME
910+
[[ -z "$PASSWORD" ]] && read -rsp "Enter DockerHub password: " PASSWORD && echo
911+
fi
912+
913+
echo "$PASSWORD" | docker login "${HUB}" --username "$USERNAME" --password-stdin || { echo "Docker authentication failed"; exit 1; }
902914
}
903915

904916
create_network () {

0 commit comments

Comments
 (0)