|
| 1 | +#!/bin/bash |
| 2 | +echo "================================================" |
| 3 | +echo " Ubuntu 20.04 (PHP 7.3)" |
| 4 | +echo "================================================" |
| 5 | + |
| 6 | +echo -n "[1/4] Starting MySQL 8.0 ........ " |
| 7 | +# make sure mysql can create socket and lock |
| 8 | +mkdir /var/run/mysqld && chmod 777 /var/run/mysqld |
| 9 | +# run mysql server |
| 10 | +nohup mysqld > /root/mysql.log 2>&1 & |
| 11 | +# wait for mysql to become available |
| 12 | +while ! mysqladmin ping -hlocalhost >/dev/null 2>&1; do |
| 13 | + sleep 1 |
| 14 | +done |
| 15 | +# create database and user on mysql |
| 16 | +mysql -u root >/dev/null << 'EOF' |
| 17 | +CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci; |
| 18 | +CREATE USER 'php-crud-api'@'localhost' IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY 'php-crud-api'; |
| 19 | +GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION; |
| 20 | +FLUSH PRIVILEGES; |
| 21 | +EOF |
| 22 | +echo "done" |
| 23 | + |
| 24 | +echo -n "[2/4] Starting PostgreSQL 12 .... " |
| 25 | +# ensure statistics can be written |
| 26 | +mkdir /var/run/postgresql/10-main.pg_stat_tmp/ && chmod 777 /var/run/postgresql/10-main.pg_stat_tmp/ |
| 27 | +# run postgres server |
| 28 | +nohup su - -c "/usr/lib/postgresql/12/bin/postgres -D /etc/postgresql/12/main" postgres > /root/postgres.log 2>&1 & |
| 29 | +# wait for postgres to become available |
| 30 | +until su - -c "psql -U postgres -c '\q'" postgres >/dev/null 2>&1; do |
| 31 | + sleep 1; |
| 32 | +done |
| 33 | +# create database and user on postgres |
| 34 | +su - -c "psql -U postgres >/dev/null" postgres << 'EOF' |
| 35 | +CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api'; |
| 36 | +CREATE DATABASE "php-crud-api"; |
| 37 | +GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api"; |
| 38 | +\c "php-crud-api"; |
| 39 | +CREATE EXTENSION IF NOT EXISTS postgis; |
| 40 | +\q |
| 41 | +EOF |
| 42 | +echo "done" |
| 43 | + |
| 44 | +echo -n "[3/4] Starting SQLServer 2017 ... " |
| 45 | +echo "skipped" |
| 46 | + |
| 47 | +echo -n "[4/4] Cloning PHP-CRUD-API v2 ... " |
| 48 | +# install software |
| 49 | +if [ -d /php-crud-api ]; then |
| 50 | + echo "skipped" |
| 51 | +else |
| 52 | + git clone --quiet https://github.com/mevdschee/php-crud-api.git |
| 53 | + echo "done" |
| 54 | +fi |
| 55 | + |
| 56 | +echo "------------------------------------------------" |
| 57 | + |
| 58 | +# run the tests |
| 59 | +cd php-crud-api |
| 60 | +php test.php |
0 commit comments