Blame tests/r_lamp/40_basic_lamp.sh

Karanbir Singh 43deec
#!/bin/bash
Karanbir Singh 43deec
Karanbir Singh 43deec
# purpose : install a minimal lamp stack, and test it
Karanbir Singh 43deec
Karanbir Singh 43deec
# Installing required bits
Karanbir Singh 43deec
Karanbir Singh 43deec
yum install -y httpd mysql mysql-server php php-mysql wget > /dev/null 2>&1
Karanbir Singh 43deec
service mysqld start
Karanbir Singh 43deec
service httpd start
Karanbir Singh 43deec
Karanbir Singh 43deec
# Initializing a small MySQL db
Karanbir Singh 43deec
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
Karanbir Singh 43deec
cat >>/var/www/html/mysql.php <
Karanbir Singh 43deec
Karanbir Singh 43deec
\$dbconnect = mysql_connect("localhost","centos","qa");
Karanbir Singh 43deec
if (!\$dbconnect)
Karanbir Singh 43deec
  {
Karanbir Singh 43deec
  die('Could not connect: ' . mysql_error());
Karanbir Singh 43deec
  }
Karanbir Singh 43deec
Karanbir Singh 43deec
mysql_select_db("qatests", \$dbconnect);
Karanbir Singh 43deec
Karanbir Singh 43deec
mysql_query("INSERT INTO tests (name)
Karanbir Singh 43deec
VALUES ('mysqltest')");
Karanbir Singh 43deec
Karanbir Singh 43deec
Karanbir Singh 43deec
mysql_close(\$dbconnect);
Karanbir Singh 43deec
?> 
Karanbir Singh 43deec
EOF
Karanbir Singh 43deec
Karanbir Singh 43deec
Karanbir Singh 43deec
Karanbir Singh 43deec
Karanbir Singh 43deec
####################################################
Karanbir Singh 43deec
# testing
Karanbir Singh 43deec
####################################################
Karanbir Singh 43deec
Karanbir Singh 43deec
wget http://localhost/mysql.php
Karanbir Singh 43deec
Karanbir Singh 43deec
echo "Basic LAMP test ..."
Karanbir Singh 43deec
content=`echo "select * from qatests.tests where name='mysqltest'"|mysql -B --skip-column-names`
Karanbir Singh 43deec
if [ "$content" = "mysqltest" ] ; then
Karanbir Singh 43deec
	echo PASS;
Karanbir Singh 43deec
	exit 0;
Karanbir Singh 43deec
else
Karanbir Singh 43deec
	echo Fail;
Karanbir Singh 43deec
	exit 1;
Karanbir Singh 43deec
fi