Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
FROM python:2.7-slim
FROM python:3.7-slim

MAINTAINER Andrea Usuelli <[email protected]>

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

Expand Down
31 changes: 3 additions & 28 deletions files/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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
$@