From 9c1bf579ec599b4cc2dcb6e403d74eb71571dad6 Mon Sep 17 00:00:00 2001 From: Christoph Galuschka Date: Nov 09 2013 10:01:45 +0000 Subject: fixed lamp test to correctly check daemon pids --- diff --git a/tests/r_lamp/1_lamp_check.sh b/tests/r_lamp/1_lamp_check.sh index 14a007d..905a7d4 100755 --- a/tests/r_lamp/1_lamp_check.sh +++ b/tests/r_lamp/1_lamp_check.sh @@ -1,21 +1,20 @@ #!/bin/bash # Author: Steve Barnes (steve@echo.id.au) -# Christoph Galuschka +# Christoph Galuschka # Filename: 1_lamp_check.sh # Version: 0.2 -# Last Updated: Saturday, 09 November 2013 +# Last Updated: Saturday, 09 November 2013 2:23 # Description: A simple Bash script to start LAMP daemons (httpd, mysqld), and confirm PHP is working. # starting with 5.10, we have to differ between mysql55 and mysql - if [ $centos_ver = 5 ] then readonly DAEMONS=( httpd mysql55-mysqld ) else readonly DAEMONS=( httpd mysqld ) fi -readonly DAEMONS_PID=( httpd mysqld ) +readonly DAEMONSPID=( httpd mysqld ) readonly SERVICE=/sbin/service readonly PHP_BIN=/usr/bin/php @@ -26,28 +25,38 @@ trap "/bin/rm -f $PHP_CHECK" EXIT t_Log "Running $0 - starting LAMP daemon startup test" -# Iterate through our daemons, start each +# Iterate through our daemons, start each and check for the presence of each process for D in "${DAEMONS[@]}" do - t_ServiceControl $D start + t_Log "Attempting startup of '$D'" + + $SERVICE $D start &>/dev/null + + RETVAL=$? + + if [ $RETVAL -ne 0 ]; then + + t_Log "FAIL: service startup for '$D' failed ($RETVAL)" + exit $FAIL + + fi done +for D in "${DAEMONSPID[@]}" +do -# Iterate through our daemons, start each and check for the presence of each process -for D in "${DAEMONS_PID[@]}" -do - # See if our process exists - PIDS=$(pidof $D) - - if [ -z "$PIDS" ]; then - - t_Log "FAIL: couldn't find '$D' in the process list." - exit $FAIL - fi - - echo "OK" + # See if our process exists + PIDS=$(pidof $D) + if [ -z "$PIDS" ]; then + + t_Log "FAIL: couldn't find '$D' in the process list." + exit $FAIL + fi + + echo "OK" done + # Finally, a basic check to see if PHP is working correctly. t_Log "Performing php script check..." @@ -62,7 +71,7 @@ RETVAL=$PHP_BIN $PHP_CHECK &>/dev/null if [ $RETVAL -ne 0 ]; then - t_Log "FAIL: php_info() check failed ($RETVAL)" + t_Log "FAIL: php_info() check failed ($RETVAL)" fi