#!/bin/bash
#
# by: Brian Butler (20100907)
# Modified for RHCE-RT by: Forrest (20101103)
#
# Grading script for the system logging lab
# This script is to be installed and run on both 
# desktopX.exmaple.com and serverX.example.com
# Output is logged to syslog

# Set environment and declare global variables
. /usr/local/lib/labtool.shlib
trap on_exit EXIT
LOG_FACILITY=local0
LOG_PRIORITY=info
LOG_TAG=blossoms
DEBUG=false
ERROR_MESSAGE="FAILED."
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
userInput="no"
set -o pipefail

# Check to make sure we are running as root
check_root

# Determine which host we are running on
stationNum="$(hostname -s | grep -o "[0-9]*")"
if (hostname -s | grep -q "^server$stationNum$"); then 
# aide coverage removed from RHCE-RT
# Send log event to syslog for testing on desktopX
    echo "REMOTE LOG TEST" | log
    echo "Sending test message. Now run this on desktop$stationNum"
elif (hostname -s | grep -q "^desktop$stationNum$"); then
# Check /var/log/messages for log messages from serverX
    echo -n "Checking that rsyslogd is receiving remote logs... "
    (grep -q "server$stationNum" /var/log/messages) && echo "PASSED." || exit 1
fi
