|
Christoph Galuschka |
a76c03 |
#!/bin/bash
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
# Author: Karanbir Singh <kbsingh@karan.org>
|
|
Christoph Galuschka |
a76c03 |
# Athmane Madjoudj <athmanem@gmail.com>
|
|
Christoph Galuschka |
a76c03 |
# Christoph Galuschka <tigalch@tigalch.org>
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
t_Log "Running $0 - install a minimal lamp stack, and test it"
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
# MySQL
|
|
Christoph Galuschka |
a76c03 |
# starting with 5.10, we have to differ between mysql55 and mysql
|
|
Christoph Galuschka |
a76c03 |
if [ $centos_ver = 5 ]
|
|
Christoph Galuschka |
a76c03 |
then
|
|
Christoph Galuschka |
a76c03 |
t_ServiceControl mysqld stop
|
|
Christoph Galuschka |
a76c03 |
t_ServiceControl mysql55-mysqld start
|
|
Pablo Greco |
39ae8c |
else
|
|
Pablo Greco |
39ae8c |
exit 0
|
|
Christoph Galuschka |
a76c03 |
fi
|
|
Christoph Galuschka |
a76c03 |
t_ServiceControl httpd restart
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
# Initializing a small MySQL db
|
|
Christoph Galuschka |
a76c03 |
cat >/tmp/mysql-QA.sql <
|
|
Christoph Galuschka |
a76c03 |
create database qatests;
|
|
Christoph Galuschka |
a76c03 |
use qatests;
|
|
Christoph Galuschka |
a76c03 |
create table tests (name varchar(20)) ;
|
|
Christoph Galuschka |
a76c03 |
grant all on qatests.* to 'centos'@'localhost' identified by 'qa';
|
|
Christoph Galuschka |
a76c03 |
flush privileges;
|
|
Christoph Galuschka |
a76c03 |
EOF
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
mysql
|
|
Christoph Galuschka |
a76c03 |
/bin/rm /tmp/mysql-QA.sql
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
# Creating a simple php query page to insert Data in the MySQL DB
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
cat >/var/www/html/mysql.php <
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
\$dbconnect = mysql_connect("localhost","centos","qa");
|
|
Christoph Galuschka |
a76c03 |
if (!\$dbconnect)
|
|
Christoph Galuschka |
a76c03 |
{
|
|
Christoph Galuschka |
a76c03 |
die('Could not connect: ' . mysql_error());
|
|
Christoph Galuschka |
a76c03 |
}
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
mysql_select_db("qatests", \$dbconnect);
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
mysql_query("INSERT INTO tests (name)
|
|
Christoph Galuschka |
a76c03 |
VALUES ('mysqltest')");
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
mysql_close(\$dbconnect);
|
|
Christoph Galuschka |
a76c03 |
?>
|
|
Christoph Galuschka |
a76c03 |
EOF
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
####################################################
|
|
Christoph Galuschka |
a76c03 |
# testing
|
|
Christoph Galuschka |
a76c03 |
####################################################
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
curl -s http://localhost/mysql.php
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
t_Log "Performing basic LAMP test"
|
|
Christoph Galuschka |
a76c03 |
content=`echo "select * from qatests.tests where name='mysqltest'"|mysql -B --skip-column-names`
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
# Clean up
|
|
Christoph Galuschka |
a76c03 |
mysql -u root -e 'drop database qatests;'
|
|
Christoph Galuschka |
a76c03 |
service httpd stop
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
if [ "$content" = "mysqltest" ] ; then
|
|
Christoph Galuschka |
a76c03 |
ret_val=0;
|
|
Christoph Galuschka |
a76c03 |
else
|
|
Christoph Galuschka |
a76c03 |
ret_val=1;
|
|
Christoph Galuschka |
a76c03 |
fi
|
|
Christoph Galuschka |
a76c03 |
|
|
Christoph Galuschka |
a76c03 |
t_CheckExitStatus $ret_val
|