#! /bin/sh # Required script variables APP_NAME=${APP_NAME:-'streamline'} export MYSQL_DATABASE=${DB_DATABASE:-'streamline'} export MYSQL_USER=${DB_USERNAME:-'root'} export MYSQL_PASSWORD=${DB_PASSWORD:-'streamline'} export MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD:-'streamline'} # execute run.sh script for MySQL initialisation chmod +x .docker/mysql/mysql-init.sh # run the MariaDB initilisation script ./.docker/mysql/mysql-init.sh if [ $? -eq 0 ]; then echo "[info] MySQL server started. checking for '$MYSQL_DATABASE' database. " mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "use streamline;" # Guard condition to re-check existence of database schema # If it doesnt exist, create it and import streamline_initial.sql file if [ $? -eq 1 ]; then mysql -u $MYSQL_USER -p$MYSQL_PASSWORD -e "CREATE DATABASE $MYSQL_DATABASE;" if [ $? -eq 0 ]; then echo "[info] Database: $MYSQL_DATABASE created." mysql -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE < ./.docker/mysql/scripts/streamline_initial.sql if [ $? -eq 0 ]; then echo "[info] populated database." else echo "[error] database not populated." fi else echo "[error] database not created." fi else echo "[info] Database: $MYSQL_DATABASE exists. " fi echo "[info] starting $APP_NAME ..." php /var/www/html/artisan migrate php /var/www/html/artisan db:seed --class=PermissionTableSeeder php /var/www/html/artisan db:seed --class=PermissionsCategoryTableSeeder php /var/www/html/artisan serve --host=0.0.0.0 --port=80 else echo "[error] MariaDB server couldnt be started." # terminate script if database isnt running exit 1; fi