#!/bin/bash 

function Validate_Agent_Installation {
	path_to_validation_rules=$1

	files_list="${path_to_validation_rules}/files.list"
        dirs_list="${path_to_validation_rules}/dirs.list"
       	services_list="${path_to_validation_rules}/services.list"

	retcode=0
	result="Validation Results:\n"
	result+="Validate files:\n"
	while read -r file
	do
		if [ -f "$file" ]
		then
			result+="[$file]: Detected"
		else
			result+="[$file]: Not detected"
			retcode=1
		fi
	done < "$files_list"
	result+="\n"

        result+="Validate directories:\n"
        while read -r dir
        do
                if [ -d "$dir" ]
                then
                        result+="[$dir]: Detected"
                else
                        result+="[$dir]: Not detected"
                        retcode=1
                fi
        done < "$dirs_list"
        result+="\n"

        result+="Validate services:\n"
        while read -r service_name
        do
                if systemctl --all --type service | grep -q "$service_name.service"
                then
                        result+="[$service_name]: Detected"
                else
                        result+="$service_name]: Not detected"
                        retcode=1
                fi
        done < "$services_list"

	echo "$result"
	return $retcode
}
