2021-08-04 17:03:28 +02:00
|
|
|
#!/bin/sh
|
2021-07-29 23:44:30 +02:00
|
|
|
|
2021-07-29 23:52:11 +02:00
|
|
|
set -e
|
2021-07-29 23:44:30 +02:00
|
|
|
|
2021-08-04 16:19:24 +02:00
|
|
|
echo "Running version ${VERSION} commit ${COMMIT} built on ${CREATED}"
|
|
|
|
|
2021-08-02 17:28:03 +02:00
|
|
|
# Show versions
|
|
|
|
echo "supervisord version: $(supervisord version)"
|
2024-05-15 09:10:47 +02:00
|
|
|
php-fpm82 -v | head -n 1
|
2021-08-02 17:28:03 +02:00
|
|
|
nginx -v
|
|
|
|
|
2024-03-23 18:54:19 +01:00
|
|
|
# Database creation
|
2021-07-29 23:44:30 +02:00
|
|
|
if [ "${DB_CONNECTION}" = "sqlite" ]; then
|
2024-03-23 18:54:19 +01:00
|
|
|
# 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"
|
2021-07-29 23:44:30 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-07-31 15:51:44 +02:00
|
|
|
# Inject storage in /2fauth and use it with a symlink
|
|
|
|
if [ ! -d /2fauth/storage ]; then
|
|
|
|
mv /srv/storage /2fauth/storage
|
|
|
|
else
|
|
|
|
rm -r /srv/storage
|
|
|
|
fi
|
2021-08-04 17:03:28 +02:00
|
|
|
ln -s /2fauth/storage /srv/storage
|
2021-07-31 15:51:44 +02:00
|
|
|
|
2021-08-03 15:31:59 +02:00
|
|
|
# Note: ${COMMIT} is set by the CI
|
2021-07-29 23:44:30 +02:00
|
|
|
if [ -f /2fauth/installed ]; then
|
2021-08-03 15:31:59 +02:00
|
|
|
INSTALLED_COMMIT="$(cat /2fauth/installed)"
|
|
|
|
if [ "${INSTALLED_COMMIT}" != "${COMMIT}" ]; then
|
|
|
|
echo "Installed commit ${INSTALLED_COMMIT} is different from program commit ${COMMIT}, we are migrating..."
|
2024-03-23 18:54:19 +01:00
|
|
|
php artisan cache:clear
|
|
|
|
php artisan config:clear
|
2024-02-19 11:00:38 +01:00
|
|
|
php artisan migrate --force
|
2021-08-03 15:31:59 +02:00
|
|
|
fi
|
2021-07-29 23:44:30 +02:00
|
|
|
else
|
2024-02-19 11:00:38 +01:00
|
|
|
php artisan migrate:refresh --force
|
2021-07-29 23:44:30 +02:00
|
|
|
php artisan passport:install
|
|
|
|
fi
|
|
|
|
|
2021-08-03 15:31:59 +02:00
|
|
|
echo "${COMMIT}" > /2fauth/installed
|
2023-07-06 10:19:04 +02:00
|
|
|
php artisan storage:link --quiet
|
2024-03-23 18:54:19 +01:00
|
|
|
php artisan optimize:clear
|
2021-08-02 18:35:01 +02:00
|
|
|
php artisan config:cache
|
2024-03-03 22:46:29 +01:00
|
|
|
php artisan route:cache
|
|
|
|
php artisan view:cache
|
2021-08-02 18:35:01 +02:00
|
|
|
|
2021-08-02 17:27:21 +02:00
|
|
|
supervisord
|