Blame tests/r_lamp/40_basic_lamp.sh

Karanbir Singh 43deec
#!/bin/bash
Karanbir Singh 43deec
Christoph Galuschka f3562a
# Author: Karanbir Singh <kbsingh@karan.org>
Christoph Galuschka f3562a
#	  Athmane Madjoudj <athmanem@gmail.com>
Christoph Galuschka f3562a
#	  Christoph Galuschka <tigalch@tigalch.org>
Christoph Galuschka f3562a
Karanbir Singh 2dd0be
t_Log "Running $0 - install a minimal lamp stack, and test it"
Karanbir Singh 43deec
Christoph Galuschka 269271
# MySQL
Christoph Galuschka 269271
# starting with 5.10, we have to differ between mysql55 and mysql
Christoph Galuschka 269271
if [ $centos_ver = 5 ]
Christoph Galuschka 269271
then
Christoph Galuschka 269271
  t_InstallPackage mysql55-mysql-server httpd mysql55-mysql php php-mysql wget
Christoph Galuschka a76c03
  t_ServiceControl mysql55-mysqld stop
7a357b
elif [ $centos_ver = 6 ]
7a357b
then
Christoph Galuschka 269271
  t_InstallPackage httpd mysql mysql-server php php-mysql wget
Pablo Greco 578a73
elif [ $centos_ver = 7 ]
Pablo Greco 578a73
then
7a357b
  t_InstallPackage httpd mysql mysql-server php php-mysqlnd wget
Pablo Greco 578a73
else
Pablo Greco 578a73
  t_InstallPackage httpd mariadb mariadb-server php php-mysqlnd wget
Christoph Galuschka 269271
fi
Christoph Galuschka a76c03
t_ServiceControl mysqld restart
Christoph Galuschka 8dfc95
t_ServiceControl httpd restart
Karanbir Singh 43deec
Karanbir Singh 43deec
# Initializing a small MySQL db
Athmane Madjoudj 27fc06
cat >/tmp/mysql-QA.sql <
Karanbir Singh 43deec
create database qatests;
Karanbir Singh 43deec
use qatests;
Karanbir Singh 43deec
create table tests (name varchar(20)) ;
Karanbir Singh 43deec
grant all on qatests.* to 'centos'@'localhost' identified by 'qa';
Karanbir Singh 43deec
flush privileges;
Karanbir Singh 43deec
EOF
Karanbir Singh 43deec
Karanbir Singh 43deec
mysql 
Karanbir Singh 43deec
/bin/rm /tmp/mysql-QA.sql
Karanbir Singh 43deec
Karanbir Singh 43deec
# Creating a simple php query page to insert Data in the MySQL DB
Karanbir Singh 43deec
Athmane Madjoudj 27fc06
cat >/var/www/html/mysql.php <
Karanbir Singh 43deec
Pablo Greco 221065
\$dbconnect = mysqli_connect("localhost","centos","qa");
Karanbir Singh 43deec
if (!\$dbconnect)
Karanbir Singh 43deec
  {
Pablo Greco 221065
  die('Could not connect: ' . mysqli_error());
Karanbir Singh 43deec
  }
Karanbir Singh 43deec
Pablo Greco 221065
mysqli_select_db(\$dbconnect, "qatests");
Karanbir Singh 43deec
Pablo Greco 221065
mysqli_query(\$dbconnect, "INSERT INTO tests (name)
Karanbir Singh 43deec
VALUES ('mysqltest')");
Karanbir Singh 43deec
Pablo Greco 221065
mysqli_close(\$dbconnect);
Karanbir Singh 43deec
?> 
Karanbir Singh 43deec
EOF
Karanbir Singh 43deec
Karanbir Singh 43deec
####################################################
Karanbir Singh 43deec
# testing
Karanbir Singh 43deec
####################################################
Karanbir Singh 43deec
Athmane Madjoudj 27fc06
curl -s  http://localhost/mysql.php 
Karanbir Singh 43deec
Karanbir Singh 2dd0be
t_Log "Performing basic LAMP test"
Karanbir Singh 43deec
content=`echo "select * from qatests.tests where name='mysqltest'"|mysql -B --skip-column-names`
Athmane Madjoudj d110e2
Athmane Madjoudj d110e2
# Clean up
Athmane Madjoudj d110e2
mysql -u root -e 'drop database qatests;'
Athmane Madjoudj b16a15
service httpd stop
Athmane Madjoudj d110e2
Karanbir Singh 43deec
if [ "$content" = "mysqltest" ] ; then
Christoph Galuschka 2e276f
	ret_val=0;
Karanbir Singh 43deec
else
Christoph Galuschka 2e276f
	ret_val=1;
Karanbir Singh 43deec
fi
Christoph Galuschka 2e276f
Christoph Galuschka 2e276f
t_CheckExitStatus $ret_val