Blame tests/r_lamp/1_lamp_check.sh

Karanbir Singh 2dd0be
#!/bin/bash
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
# Author: Steve Barnes (steve@echo.id.au)
Christoph Galuschka 9c1bf5
#	  Christoph Galuschka <tigalch@tigalch.org>
Karanbir Singh 2dd0be
# Filename: 1_lamp_check.sh
Christoph Galuschka c04e6a
# Version: 0.2
Christoph Galuschka 9c1bf5
# Last Updated: Saturday, 09 November 2013 2:23
Karanbir Singh 2dd0be
# Description: A simple Bash script to start LAMP daemons (httpd, mysqld), and confirm PHP is working.
Karanbir Singh 2dd0be
f49232
if [ "$centos_ver" -ge "7" ] ; then
b31ec9
  readonly DAEMONS=( httpd mariadb )
b31ec9
else
b31ec9
 readonly DAEMONS=( httpd mysqld )
b31ec9
fi
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
readonly SERVICE=/sbin/service
Karanbir Singh 2dd0be
readonly PHP_BIN=/usr/bin/php
Karanbir Singh 2dd0be
readonly PHP_CHECK=/tmp/check.php
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
# Make sure we cleanup after ourselves.
Karanbir Singh 2dd0be
trap "/bin/rm -f $PHP_CHECK" EXIT
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
t_Log "Running $0 - starting LAMP daemon startup test"
Karanbir Singh 2dd0be
Christoph Galuschka 9c1bf5
# Iterate through our daemons, start each and check for the presence of each process
Karanbir Singh 2dd0be
for D in "${DAEMONS[@]}"
Karanbir Singh 2dd0be
do
b31ec9
  t_ServiceControl $D restart
Karanbir Singh 2dd0be
done
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
# Finally, a basic check to see if PHP is working correctly.
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
t_Log "Performing php script check..."
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
cat <<EOL > $PHP_CHECK
Karanbir Singh 2dd0be
Karanbir Singh 2dd0be
return phpinfo();
Karanbir Singh 2dd0be
?>
Karanbir Singh 2dd0be
EOL
Karanbir Singh 2dd0be
b31ec9
$PHP_BIN $PHP_CHECK &>/dev/null
b31ec9
RETVAL="$?"
Karanbir Singh 2dd0be
b31ec9
if [ "$RETVAL" -ne "0" ]; then
Karanbir Singh 2dd0be
Christoph Galuschka 9c1bf5
        t_Log "FAIL: php_info() check failed ($RETVAL)"
Karanbir Singh 2dd0be
Christoph Galuschka 2e276f
fi
Christoph Galuschka 2e276f
Christoph Galuschka 2e276f
t_CheckExitStatus $RETVAL