LAR_Maintenance/start.sh
Jonatan Rek d2ea5ab548 Docker
2024-08-06 16:30:02 +02:00

51 lines
1.1 KiB
Bash

# Install project dependencies
composer install --quiet --prefer-dist --no-dev -o
npm install
init=false
if ! test -f /config/.env; then
# Create Env File
cp .env.example .env
php artisan key:generate
cp .env /config/.env
init=true
echo "Initialization"
else
cp /config/.env .env
fi
if [ $(grep -ic "DB_CONNECTION=sqlite" /var/www/html/.env) -gt 0 ] || [ "${DEPLOY_ENV}" == "sqlite"]; then
if ! test -f "/var/www/html/database/database.sqlite" ; then
echo " DB Initialization"
init=true
fi
fi
# Migrate Database
php artisan migrate --force --no-interaction
# Link storage and create default user
if [ "$init" = true ]; then
echo "Initialization of Laravel"
php artisan db:seed --force --class=DatabaseSeeder
php artisan storage:link
fi
# Clear Cashes
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
# fix permissions
chown -R www-data:www-data /var/www/html
find /var/www/html -type f -not -name "*.sh" -exec chmod 664 {} +
find /var/www/html -type d -exec chmod 775 {} +
# Start Apache
apache2-foreground