Skip to content

Commit

Permalink
Merge pull request #1 from ashley-abbott/hotfix/IFS-wreaking-havoc
Browse files Browse the repository at this point in the history
added in a lock file to use the fd, included local var inside functions
  • Loading branch information
Karl Baillie authored Nov 28, 2019
2 parents 8fd11b4 + 5aeec10 commit a3ddc2a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions check_last_yum
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ while [[ -n "$1" ]]; do
done

function ok() {
echo "OK - $1"
local MESSAGE="$*"
echo "OK - $MESSAGE"
exit 0
}

function warn() {
echo "WARNING - $1"
local MESSAGE="$*"
echo "WARNING - $MESSAGE"
exit 1
}

Expand All @@ -46,6 +48,9 @@ function unknown() {

command -v yum >/dev/null 2>&1 || unknown "YUM Command Not Defined"

LOCK=/tmp/$(basename $0)
exec 100>$LOCK

flock -w 10 100 || unknown "Another \"check_last_yum\" check is running, could not obtain lock"

warning=${warning:=60}
Expand All @@ -69,4 +74,5 @@ else
unknown
fi

# EOF
# EOF

0 comments on commit a3ddc2a

Please sign in to comment.