diff --git a/README.md b/README.md index 0637236..b5d2b04 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,5 @@ To run: ```bash docker run -d --rm -e "UNFLIPPER_TOKEN=[token]" --name unflipper ghcr.io/f13/unflipper ``` + +`UNFLIPPER_TOKEN_FILE` is also supported for use with Docker secrets. diff --git a/start.sh b/start.sh index 38da9d4..4f308d3 100755 --- a/start.sh +++ b/start.sh @@ -1,3 +1,23 @@ #!/bin/bash -/usr/bin/env python3 start.py \ No newline at end of file +file_env() { + local var="$1" + local fileVar="${var}_FILE" + local def="${2:-}" + if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then + echo >&2 "error: both $var and $fileVar are set (but are exclusive)" + exit 1 + fi + local val="$def" + if [ "${!var:-}" ]; then + val="${!var}" + elif [ "${!fileVar:-}" ]; then + val="$(< "${!fileVar}")" + fi + export "$var"="$val" + unset "$fileVar" +} + +file_env 'UNFLIPPER_TOKEN' + +/usr/bin/env python3 start.py