2024-08-05 12:06:20 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
main() {
|
|
|
|
|
prep_file_permissions
|
|
|
|
|
prep_storage
|
2024-08-08 16:33:01 +02:00
|
|
|
wait_for_db
|
|
|
|
|
apply_db_migrations
|
|
|
|
|
run_init_project
|
2024-08-05 12:06:20 +02:00
|
|
|
run_server "$@"
|
|
|
|
|
}
|
2024-08-08 16:33:01 +02:00
|
|
|
|
2024-08-05 12:06:20 +02:00
|
|
|
is_master() {
|
|
|
|
|
echo "$@" | grep -q php-fpm
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prep_file_permissions() {
|
|
|
|
|
chmod a+x ./artisan
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apply_db_migrations() {
|
|
|
|
|
echo "Running DB Migrations"
|
|
|
|
|
./artisan migrate
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run_init_project() {
|
|
|
|
|
echo "Running app:init-project command"
|
|
|
|
|
./artisan app:init-project
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wait_for_db() {
|
2024-08-08 16:33:01 +02:00
|
|
|
echo "Waiting for DB to be ready"
|
2024-08-05 12:06:20 +02:00
|
|
|
until ./artisan migrate:status 2>&1 | grep -q -E "(Migration table not found|Migration name)"; do
|
|
|
|
|
sleep 1
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
run_server() {
|
2024-08-08 16:33:01 +02:00
|
|
|
echo "Starting server $@"
|
2024-08-05 12:06:20 +02:00
|
|
|
/usr/local/bin/docker-php-entrypoint "$@"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prep_storage() {
|
2024-08-28 15:38:55 +02:00
|
|
|
mkdir -p /etc/initial-storage
|
|
|
|
|
if [ ! -d /etc/initial-storage/app ]; then
|
2024-08-05 12:06:20 +02:00
|
|
|
echo "Backing up initial storage directory"
|
2024-08-28 15:38:55 +02:00
|
|
|
cp -a ./storage/* /etc/initial-storage/
|
|
|
|
|
fi
|
2024-08-05 12:06:20 +02:00
|
|
|
|
2024-08-28 15:38:55 +02:00
|
|
|
mkdir -p /persist/storage
|
|
|
|
|
if [ ! -d /persist/storage/app ]; then
|
2024-08-05 12:06:20 +02:00
|
|
|
echo "Initialising blank storage dir"
|
2024-08-28 15:38:55 +02:00
|
|
|
cp -a /etc/initial-storage/* /persist/storage/
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
chmod -R 777 /persist/storage
|
2024-08-05 12:06:20 +02:00
|
|
|
|
|
|
|
|
touch /var/log/opnform.log
|
|
|
|
|
chown www-data /var/log/opnform.log
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 16:33:01 +02:00
|
|
|
main "$@"
|