Skip to content

Commit

Permalink
Add support for UNFLIPPER_TOKEN_FILE
Browse files Browse the repository at this point in the history
  • Loading branch information
F13 committed Jun 7, 2024
1 parent b21620b commit 52b0ef7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
22 changes: 21 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
#!/bin/bash

/usr/bin/env python3 start.py
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

0 comments on commit 52b0ef7

Please sign in to comment.