diff --git a/Dockerfile b/Dockerfile index 30bc1f5..98eb16d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,10 @@ -FROM python:2.7-slim +FROM python:3.7-slim MAINTAINER Andrea Usuelli -ENV VERSION=0.5.6 \ - AUTHORIZATION_FAIL_MAX_RETRIES=3 +ARG VERSION=1.4.2 + +ENV AUTHORIZATION_FAIL_MAX_RETRIES=3 #B2_ACCOUNT_ID if set at runtime, (re)authorization is performed automatically by this docker image #B2_APPLICATION_KEY if set at runtime, (re)authorization is performed automatically by this docker image diff --git a/files/entrypoint.sh b/files/entrypoint.sh index b3643ee..c297c30 100755 --- a/files/entrypoint.sh +++ b/files/entrypoint.sh @@ -1,32 +1,7 @@ #!/bin/bash -# Add b2 as base command if needed -if [ "${1:0:2}" != 'b2' ]; then - if [ "${1}" = "upload_file_replace" ]; then - set -- python /usr/bin/b2_upload_file_replace "$@" - else - set -- b2 "$@" - fi +if [ "${1}" == 'b2' ] && [ "${2}" != 'version' ] && [ "${2}" != 'help' ]; then + b2 authorize_account "$B2_ACCOUNT_ID" "$B2_APPLICATION_KEY" fi -EXIT_CODE=1 -AUTH_FAILED=1 -RETRY=0 - -if [ -n "$B2_ACCOUNT_ID" ] && [ -n "$B2_APPLICATION_KEY" ]; then - while [ $AUTH_FAILED -ne 0 ] && [ $RETRY -lt $AUTHORIZATION_FAIL_MAX_RETRIES ]; do - # Exclude on first run only if /root/.b2_account_info exists - if [ $RETRY -gt 0 ] || [ ! -f /root/.b2_account_info ]; then - b2 authorize_account "$B2_ACCOUNT_ID" "$B2_APPLICATION_KEY" - fi - OUTPUT=`$@` - if [[ $OUTPUT != *"bad_auth_token"* ]] && [[ $OUTPUT != *"expired_auth_token"* ]]; then - AUTH_FAILED=0 - fi - EXIT_CODE=$? - RETRY=$((RETRY+1)) - done - echo $OUTPUT -else - $@ -fi +$@