#!/bin/bash
#

file_name="$(basename "$0").$$"

find / -regextype posix-extended -regex ".+\.pac(new|save)" 2>/dev/null |grep -vi containers 1> /tmp/"${file_name}" 

if [ -s /tmp/"${file_name}" ]; then
	if [ -z "$1" ]; then
       		echo
 		echo "Running $(basename "$0")..."
		echo
		echo "Found files:"
		echo
		cat /tmp/"${file_name}"
	else
		/usr/local/bin/send-mail root@localhost systemd:timer "$(cat /tmp/"$file_name")"
		echo
                echo "Running $(basename "$0")..."
                echo
                echo "Found files:"
                echo
                cat /tmp/"${file_name}"
	fi
fi

rm /tmp/"${file_name}" 2>/dev/null
