Skip to content

Commit

Permalink
Merge #418: dev: rename database driver environmental variable
Browse files Browse the repository at this point in the history
d2e3757 dev: rename database driver environmental variable (Cameron Garnham)

Pull request description:

  closes #417

  from: `TORRUST_TRACKER_DATABASE`
  to: `TORRUST_TRACKER_DATABASE_DRIVER`

ACKs for top commit:
  josecelano:
    ACK d2e3757

Tree-SHA512: 5bdbbf1e89fbb9afc9fc261596290a71504a43cc4ba6a746f456f00e42019992c438b10e8db408b3c2d7e35e21ec7a517f2460ac157038cb73d3ab7899a52be9
  • Loading branch information
da2ce7 committed Sep 12, 2023
2 parents 4ca8b58 + d2e3757 commit 7996a9d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ RUN ["/busybox/cp", "-sp", "/busybox/sh","/busybox/cat","/busybox/ls","/busybox/
COPY --from=gcc --chmod=0555 /usr/local/bin/su-exec /bin/su-exec

ARG TORRUST_TRACKER_PATH_CONFIG="/etc/torrust/tracker/tracker.toml"
ARG TORRUST_TRACKER_DATABASE="sqlite3"
ARG TORRUST_TRACKER_DATABASE_DRIVER="sqlite3"
ARG USER_ID=1000
ARG UDP_PORT=6969
ARG HTTP_PORT=7070
ARG API_PORT=1212

ENV TORRUST_TRACKER_PATH_CONFIG=${TORRUST_TRACKER_PATH_CONFIG}
ENV TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE}
ENV TORRUST_TRACKER_DATABASE_DRIVER=${TORRUST_TRACKER_DATABASE_DRIVER}
ENV USER_ID=${USER_ID}
ENV UDP_PORT=${UDP_PORT}
ENV HTTP_PORT=${HTTP_PORT}
Expand Down
2 changes: 1 addition & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
image: torrust-tracker:release
tty: true
environment:
- TORRUST_TRACKER_DATABASE=${TORRUST_TRACKER_DATABASE:-mysql}
- TORRUST_TRACKER_DATABASE_DRIVER=${TORRUST_TRACKER_DATABASE_DRIVER:-mysql}
- TORRUST_TRACKER_API_ADMIN_TOKEN=${TORRUST_TRACKER_API_ADMIN_TOKEN:-MyAccessToken}
networks:
- server_side
Expand Down
2 changes: 1 addition & 1 deletion docs/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ The following environmental variables can be set:

- `TORRUST_TRACKER_PATH_CONFIG` - The in-container path to the tracker configuration file, (default: `"/etc/torrust/tracker/tracker.toml"`).
- `TORRUST_TRACKER_API_ADMIN_TOKEN` - Override of the admin token. If set, this value overrides any value set in the config.
- `TORRUST_TRACKER_DATABASE` - The database type used for the container, (options: `sqlite3`, `mysql`, default `sqlite3`). Please Note: This dose not override the database configuration within the `.toml` config file.
- `TORRUST_TRACKER_DATABASE_DRIVER` - The database type used for the container, (options: `sqlite3`, `mysql`, default `sqlite3`). Please Note: This dose not override the database configuration within the `.toml` config file.
- `TORRUST_TRACKER_CONFIG` - Load config from this environmental variable instead from a file, (i.e: `TORRUST_TRACKER_CONFIG=$(cat tracker-tracker.toml)`).
- `USER_ID` - The user id for the runtime crated `torrust` user. Please Note: This user id should match the ownership of the host-mapped volumes, (default `1000`).
- `UDP_PORT` - The port for the UDP tracker. This should match the port used in the configuration, (default `6969`).
Expand Down
10 changes: 5 additions & 5 deletions share/container/entry_script_sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ chmod -R 2770 /var/lib/torrust /var/log/torrust /etc/torrust


# Install the database and config:
if [ -n "$TORRUST_TRACKER_DATABASE" ]; then
if cmp_lc "$TORRUST_TRACKER_DATABASE" "sqlite3"; then
if [ -n "$TORRUST_TRACKER_DATABASE_DRIVER" ]; then
if cmp_lc "$TORRUST_TRACKER_DATABASE_DRIVER" "sqlite3"; then

# Select sqlite3 empty database
default_database="/usr/share/torrust/default/database/tracker.sqlite3.db"

# Select sqlite3 default configuration
default_config="/usr/share/torrust/default/config/tracker.container.sqlite3.toml"

elif cmp_lc "$TORRUST_TRACKER_DATABASE" "mysql"; then
elif cmp_lc "$TORRUST_TRACKER_DATABASE_DRIVER" "mysql"; then

# (no database file needed for mysql)

# Select default mysql configuration
default_config="/usr/share/torrust/default/config/tracker.container.mysql.toml"

else
echo "Error: Unsupported Database Type: \"$TORRUST_TRACKER_DATABASE\"."
echo "Error: Unsupported Database Type: \"$TORRUST_TRACKER_DATABASE_DRIVER\"."
echo "Please Note: Supported Database Types: \"sqlite3\", \"mysql\"."
exit 1
fi
else
echo "Error: \"\$TORRUST_TRACKER_DATABASE\" was not set!"; exit 1;
echo "Error: \"\$TORRUST_TRACKER_DATABASE_DRIVER\" was not set!"; exit 1;
fi

install_config="/etc/torrust/tracker/tracker.toml"
Expand Down

0 comments on commit 7996a9d

Please sign in to comment.