mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-13 22:50:25 +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
|
echo "${1}" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# The main code that runs by default. Arguments are the command-line options.
|
||||||
|
main() {
|
||||||
|
|
||||||
# Make the collection location
|
# Make the collection location
|
||||||
mkdir -p "${DEST}" || die "Can't make the destination directory"
|
mkdir -p "${DEST}" || die "Can't make the destination directory"
|
||||||
test -d "${DEST}" || die "${DEST} isn't a 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!';
|
echo 'Not running with root privileges!';
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# We increment this variable every time that the check is true, and set it to 0
|
# We increment this variable every time that the check is true,
|
||||||
# if it's false.
|
# and set it to 0 if it's false.
|
||||||
cycles_true=0;
|
cycles_true=0;
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
@@ -158,6 +161,13 @@ while true; do
|
|||||||
-depth -mtime +${PURGE} -exec rm -f '{}' \;
|
-depth -mtime +${PURGE} -exec rm -f '{}' \;
|
||||||
|
|
||||||
done
|
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
|
# Documentation
|
||||||
|
Reference in New Issue
Block a user