#!/bin/bash

# Author: Steve Barnes (steve@echo.id.au)
# Filename: 0_lamp_install.sh
# Version: 0.1.1
# Last Updated: Saturday, 30 April 2011 3:52 PM AEST
# Description: A simple Bash script to install a LAMP stack (Apache, MySQL (server + client) and PHP)) via yum.

readonly PASS=0
readonly FAIL=1

readonly YUM=/usr/bin/yum

readonly PACKAGES=( httpd mysql-server php )

echo "[+] Starting LAMP test install"

# Iterate through our package list and install
for P in "${PACKAGES[@]}"
do
	echo -n "[+] Attempting yum install of '$P'..."
	
	$YUM -y -d0 install $P &>/dev/null
	
	RETVAL=$?
	
	if [ $RETVAL -ne 0 ]; then
	
		echo "FAIL: yum install of '$P' failed ($RETVAL)"
		exit $FAIL
		
	fi
	
	echo "OK"

done

echo "[+] Finished"