Blame tests/r_lamp/50_lamp_check_mysql55.sh

Christoph Galuschka a76c03
#!/bin/bash
Christoph Galuschka a76c03
Christoph Galuschka a76c03
# Author: Steve Barnes (steve@echo.id.au)
Christoph Galuschka a76c03
#	  Christoph Galuschka <tigalch@tigalch.org>
Christoph Galuschka a76c03
# Filename: 1_lamp_check.sh
Christoph Galuschka a76c03
# Version: 0.2
Christoph Galuschka a76c03
# Last Updated: Saturday, 09 November 2013 2:23
Christoph Galuschka a76c03
# Description: A simple Bash script to start LAMP daemons (httpd, mysqld), and confirm PHP is working.
Christoph Galuschka a76c03
Christoph Galuschka a76c03
# starting with 5.10, we have to differ between mysql55 and mysql
b31ec9
b31ec9
if [ "$centos_ver" = "7" ] ; then
Christoph Galuschka 017f57
  t_Log "no mysql55 on CentOS 7 ... SKIP"
b31ec9
  exit 0
b31ec9
fi
b31ec9
b31ec9
Christoph Galuschka a76c03
if [ $centos_ver = 5 ]
Christoph Galuschka a76c03
then
Christoph Galuschka a76c03
  readonly DAEMONS=( httpd mysql55-mysqld )
Christoph Galuschka a76c03
else
Christoph Galuschka a76c03
  readonly DAEMONS=( httpd mysqld )
Christoph Galuschka a76c03
fi
Christoph Galuschka a76c03
readonly DAEMONSPID=( httpd mysqld )
Christoph Galuschka a76c03
Christoph Galuschka a76c03
readonly SERVICE=/sbin/service
Christoph Galuschka a76c03
readonly PHP_BIN=/usr/bin/php
Christoph Galuschka a76c03
readonly PHP_CHECK=/tmp/check.php
Christoph Galuschka a76c03
Christoph Galuschka a76c03
# Make sure we cleanup after ourselves.
Christoph Galuschka a76c03
trap "/bin/rm -f $PHP_CHECK" EXIT
Christoph Galuschka a76c03
Christoph Galuschka a76c03
t_Log "Running $0 - starting LAMP daemon startup test"
Christoph Galuschka a76c03
Christoph Galuschka a76c03
# Iterate through our daemons, start each and check for the presence of each process
Christoph Galuschka a76c03
for D in "${DAEMONS[@]}"
Christoph Galuschka a76c03
do
Christoph Galuschka a76c03
        t_Log "Attempting startup of '$D'"
Christoph Galuschka a76c03
Christoph Galuschka a76c03
        $SERVICE $D start &>/dev/null
Christoph Galuschka a76c03
a78f80
        RETVAL=$?
a78f80
a78f80
        if [ $RETVAL -ne 0 ]; then
a78f80
a78f80
                t_Log "FAIL: service startup for '$D' failed ($RETVAL)"
a78f80
                exit $FAIL
a78f80
a78f80
        fi
Christoph Galuschka a76c03
done
Christoph Galuschka a76c03
for D in "${DAEMONSPID[@]}"
Christoph Galuschka a76c03
do
Christoph Galuschka a76c03
Christoph Galuschka a76c03
        # See if our process exists
Christoph Galuschka a76c03
        PIDS=$(pidof $D)
Christoph Galuschka a76c03
Christoph Galuschka a76c03
        if [ -z "$PIDS" ]; then
Christoph Galuschka a76c03
Christoph Galuschka a76c03
                t_Log "FAIL: couldn't find '$D' in the process list."
Christoph Galuschka a76c03
                exit $FAIL
Christoph Galuschka a76c03
        fi
Christoph Galuschka a76c03
Christoph Galuschka a76c03
        echo "OK"
Christoph Galuschka a76c03
done
Christoph Galuschka a76c03
Christoph Galuschka a76c03
Christoph Galuschka a76c03
# Finally, a basic check to see if PHP is working correctly.
Christoph Galuschka a76c03
Christoph Galuschka a76c03
t_Log "Performing php script check..."
Christoph Galuschka a76c03
Christoph Galuschka a76c03
cat <<EOL > $PHP_CHECK
Christoph Galuschka a76c03
Christoph Galuschka a76c03
return phpinfo();
Christoph Galuschka a76c03
?>
Christoph Galuschka a76c03
EOL
Christoph Galuschka a76c03
Christoph Galuschka a76c03
RETVAL=$PHP_BIN $PHP_CHECK &>/dev/null
Christoph Galuschka a76c03
Christoph Galuschka a76c03
if [ $RETVAL -ne 0 ]; then
Christoph Galuschka a76c03
Christoph Galuschka a76c03
        t_Log "FAIL: php_info() check failed ($RETVAL)"
Christoph Galuschka a76c03
Christoph Galuschka a76c03
fi
Christoph Galuschka a76c03
Christoph Galuschka a76c03
t_CheckExitStatus $RETVAL