Ignore recently-created temporary files (in the event that Ansible is doing shenanigans or something
This commit is contained in:
parent
edf1588c27
commit
8822bfad31
@ -11,6 +11,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
tmpdir="/tmp"
|
tmpdir="/tmp"
|
||||||
|
minfileage="3600"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Compile a list of executables found in /tmp
|
# Compile a list of executables found in /tmp
|
||||||
@ -23,6 +24,15 @@ tmpdir="/tmp"
|
|||||||
#
|
#
|
||||||
executables=""
|
executables=""
|
||||||
while read line; do
|
while read line; do
|
||||||
|
# Ignore recently-created files
|
||||||
|
# This is so things like Ansible plays don't trigger us
|
||||||
|
filetimestamp="$(stat -c %Y -- "$line")"
|
||||||
|
now="$(date +%s)"
|
||||||
|
age="$(( now - filetimestamp ))"
|
||||||
|
if (( age <= minfileage )); then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Add it to the list
|
||||||
if [ -z "$executables" ]; then
|
if [ -z "$executables" ]; then
|
||||||
executables="$line"
|
executables="$line"
|
||||||
else
|
else
|
||||||
@ -36,6 +46,6 @@ if [ -n "$executables" ]; then
|
|||||||
echo "CRITICAL: Found executables in $tmpdir: $executables"
|
echo "CRITICAL: Found executables in $tmpdir: $executables"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
echo "OK: No executables in $tmpdir"
|
echo "OK: No executables in $tmpdir older than ${minfileage}s"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user