mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-02-16 18:31:49 +01:00
Fix DB_DATABASE path not respected by entrypoint script - Fixes #192
This commit is contained in:
parent
2e296ba3c1
commit
dd7d3d95df
31
docker/entrypoint.sh
vendored
31
docker/entrypoint.sh
vendored
@ -9,12 +9,31 @@ echo "supervisord version: $(supervisord version)"
|
||||
php-fpm81 -v | head -n 1
|
||||
nginx -v
|
||||
|
||||
# Database creation
|
||||
if [ "${DB_CONNECTION}" = "sqlite" ]; then
|
||||
if [ ! -f /2fauth/database.sqlite ]; then
|
||||
touch /2fauth/database.sqlite
|
||||
# DB_DATABASE is trimmed if necessary
|
||||
if [[ $DB_DATABASE == \"* ]] && [[ $DB_DATABASE == *\" ]] ; then
|
||||
dbpath=${DB_DATABASE:1:${#DB_DATABASE}-2}
|
||||
else
|
||||
dbpath=${DB_DATABASE}
|
||||
fi
|
||||
if [ $dbpath != "/srv/database/database.sqlite" ]; then
|
||||
echo "DB_DATABASE sets with custom path: ${dbpath}"
|
||||
if [ ! -f ${dbpath} ]; then
|
||||
echo "${dbpath} does not exist, we create it"
|
||||
touch ${dbpath}
|
||||
fi
|
||||
else
|
||||
echo "DB_DATABASE sets with default path, we will use a symlink"
|
||||
echo "Actual db file will be /2fauth/database.sqlite"
|
||||
if [ ! -f /2fauth/database.sqlite ]; then
|
||||
echo "/2fauth/database.sqlite does not exist, we create it"
|
||||
touch /2fauth/database.sqlite
|
||||
fi
|
||||
rm -f /srv/database/database.sqlite
|
||||
ln -s /2fauth/database.sqlite /srv/database/database.sqlite
|
||||
echo "/srv/database/database.sqlite is now a symlink to /2fauth/database.sqlite"
|
||||
fi
|
||||
rm -f /srv/database/database.sqlite
|
||||
ln -s /2fauth/database.sqlite /srv/database/database.sqlite
|
||||
fi
|
||||
|
||||
# Inject storage in /2fauth and use it with a symlink
|
||||
@ -30,7 +49,8 @@ if [ -f /2fauth/installed ]; then
|
||||
INSTALLED_COMMIT="$(cat /2fauth/installed)"
|
||||
if [ "${INSTALLED_COMMIT}" != "${COMMIT}" ]; then
|
||||
echo "Installed commit ${INSTALLED_COMMIT} is different from program commit ${COMMIT}, we are migrating..."
|
||||
php artisan optimize:clear
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan migrate --force
|
||||
fi
|
||||
else
|
||||
@ -40,6 +60,7 @@ fi
|
||||
|
||||
echo "${COMMIT}" > /2fauth/installed
|
||||
php artisan storage:link --quiet
|
||||
php artisan optimize:clear
|
||||
php artisan config:cache
|
||||
php artisan route:cache
|
||||
php artisan view:cache
|
||||
|
Loading…
Reference in New Issue
Block a user