Skip to content
Closed
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
18 changes: 13 additions & 5 deletions images/yourls/container-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ if [[ "$1" == apache2* ]] || [ "$1" = 'php-fpm' ]; then
cp /usr/src/yourls/user/config-container.php user/config.php

: "${YOURLS_USER:=}"
: "${YOURLS_PASS:=}"
if [ -n "${YOURLS_USER}" ] && [ -n "${YOURLS_PASS}" ]; then
result=$(sed "s/ getenv_container('YOURLS_USER') => getenv_container('YOURLS_PASS'),/ \'${YOURLS_USER}\' => \'${YOURLS_PASS//&/\\&}\',/g" user/config.php)
echo "$result" > user/config.php
fi
: "${YOURLS_PASS:=}"
: "${YOURLS_PASS_FILE:=}"
if [ -n "${YOURLS_USER}" ] && [ -n "${YOURLS_PASS}${YOURLS_PASS_FILE}" ]; then
if [ -n "${YOURLS_PASS_FILE}" ]; then
# This should retrieve the secret contents while removing any
# pesky whitespace/newlines...
YOURLS_PASS="$(cat "$YOURLS_PASS_FILE" | tr -d '[:space:]')"
fi

result=$(sed "s/ getenv_container('YOURLS_USER') => getenv_container('YOURLS_PASS'),/ \'${YOURLS_USER}\' => \'${YOURLS_PASS//&/\\&}\',/g" user/config.php)

echo "$result" > user/config.php
fi

if [ "$uid" = '0' ]; then
# attempt to ensure that user/config.php is owned by the run user
Expand Down