mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Make main() in pt-stalk.
This commit is contained in:
14
bin/pt-stalk
14
bin/pt-stalk
@@ -99,6 +99,9 @@ log() {
|
||||
echo "${1}" >&2
|
||||
}
|
||||
|
||||
# The main code that runs by default. Arguments are the command-line options.
|
||||
main() {
|
||||
|
||||
# Make the collection location
|
||||
mkdir -p "${DEST}" || die "Can't make the destination directory"
|
||||
test -d "${DEST}" || die "${DEST} isn't a directory"
|
||||
@@ -109,8 +112,8 @@ if [ "$(id -u)" != "0" ]; then
|
||||
echo 'Not running with root privileges!';
|
||||
fi
|
||||
|
||||
# We increment this variable every time that the check is true, and set it to 0
|
||||
# if it's false.
|
||||
# We increment this variable every time that the check is true,
|
||||
# and set it to 0 if it's false.
|
||||
cycles_true=0;
|
||||
|
||||
while true; do
|
||||
@@ -158,6 +161,13 @@ while true; do
|
||||
-depth -mtime +${PURGE} -exec rm -f '{}' \;
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
# Execute the program if it was not included from another file.
|
||||
# This makes it possible to include without executing, and thus test.
|
||||
if [ "$(basename "$0")" = "pt-stalk" ] || [ "$(basename "$0")" = "bash" -a "$_" = "$0" ]; then
|
||||
main "$@"
|
||||
fi
|
||||
|
||||
# ############################################################################
|
||||
# Documentation
|
||||
|
Reference in New Issue
Block a user