1
+ #! /bin/bash
2
+
3
+ echo " - Starting MySQL 5.7"
4
+ # make sure mysql can create socket and lock
5
+ mkdir /var/run/mysqld && chmod 777 /var/run/mysqld
6
+ # run mysql server
7
+ nohup mysqld > /root/mysql.log 2>&1 &
8
+ # wait for mysql to become available
9
+ while ! mysqladmin ping -hlocalhost > /dev/null 2>&1 ; do
10
+ sleep 1
11
+ done
12
+ # create database and user on mysql
13
+ mysql -u root > /dev/null << 'EOF '
14
+ CREATE DATABASE `php-crud-api` CHARACTER SET utf8 COLLATE utf8_general_ci;
15
+ CREATE USER 'php-crud-api'@'localhost' IDENTIFIED BY 'php-crud-api';
16
+ GRANT ALL PRIVILEGES ON `php-crud-api`.* TO 'php-crud-api'@'localhost' WITH GRANT OPTION;
17
+ FLUSH PRIVILEGES;
18
+ EOF
19
+
20
+ echo " - Starting PostgreSQL 9.5"
21
+ # run postgres server
22
+ nohup su - -c " /usr/lib/postgresql/9.5/bin/postgres -D /etc/postgresql/9.5/main" postgres > /root/postgres.log 2>&1 &
23
+ # wait for postgres to become available
24
+ until su - -c " psql -U postgres -c '\q'" postgres > /dev/null 2>&1 ; do
25
+ sleep 1;
26
+ done
27
+ # create database and user on postgres
28
+ su - -c " psql -U postgres >/dev/null" postgres << 'EOF '
29
+ CREATE USER "php-crud-api" WITH PASSWORD 'php-crud-api';
30
+ CREATE DATABASE "php-crud-api";
31
+ GRANT ALL PRIVILEGES ON DATABASE "php-crud-api" to "php-crud-api";
32
+ \c "php-crud-api";
33
+ CREATE EXTENSION IF NOT EXISTS postgis;
34
+ \q
35
+ EOF
36
+
37
+ echo " - Starting SQLServer 2017"
38
+ # run sqlserver server
39
+ nohup /opt/mssql/bin/sqlservr --accept-eula > /root/mysql.log 2>&1 &
40
+ # create database and user on postgres
41
+ /opt/mssql-tools/bin/sqlcmd -l 10 -S localhost -U SA -P sapwd123! > /dev/null << 'EOF '
42
+ CREATE DATABASE [php-crud-api]
43
+ GO
44
+ CREATE LOGIN [php-crud-api] WITH PASSWORD=N'php-crud-api', DEFAULT_DATABASE=[php-crud-api], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
45
+ GO
46
+ USE [php-crud-api]
47
+ GO
48
+ CREATE USER [php-crud-api] FOR LOGIN [php-crud-api] WITH DEFAULT_SCHEMA=[dbo]
49
+ exec sp_addrolemember 'db_owner', 'php-crud-api';
50
+ GO
51
+ exit
52
+ EOF
53
+
54
+ echo " - Cloning PHP-CRUD-API"
55
+ # install software
56
+ git clone --quiet https://github.com/mevdschee/php-crud-api2.git
57
+
58
+ echo " - Running all tests"
59
+ # run the tests
60
+ cd php-crud-api2
61
+ php test.php
0 commit comments