From bdcb84e88f1877d173d48438c14c9042f2d1744e Mon Sep 17 00:00:00 2001 From: Eugeni Dodonov Date: Wed, 10 Feb 2010 14:32:17 +0000 Subject: find out what is the current type of check --- cron-sh/functions.sh | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'cron-sh/functions.sh') diff --git a/cron-sh/functions.sh b/cron-sh/functions.sh index 61a54ec..a95dd91 100644 --- a/cron-sh/functions.sh +++ b/cron-sh/functions.sh @@ -37,20 +37,33 @@ FILTER="\(`echo $EXCLUDEDIR | sed -e 's/ /\\\|/g'`\)" ### Functions ### +function current_check_type() { + # determines current check type by matching the directory from where + # the main script is executed against possible check values. Currently, + # the following checks are supported: daily, weekly, monthly + # if nothing matches those directories, it is assumed that the check is "manual" + SCRIPT_DIR=$(dirname $0) + for check in daily weekly monthly; do + echo $SCRIPT_DIR | grep -q $check + ret=$? + if [ $ret = "0" ]; then + echo $check + return + fi + done + # nothing matches, so assuming a manual check + echo "manual" + return +} + function check_is_enabled() { # checks if a periodic check should run by matching the directory from where # the main script is run against check value. E.g., daily checks will work if # executed from /etc/cron.daily or any directory containing 'daily'; weekly checks # will run if run withing a directory containing 'weekly', and so on check=$1 - SCRIPT_DIR=$(dirname $0) - if [ "a$check" = "ano" ]; then - return 1 - fi - # check if the test is supposed to be executed on this run - echo $SCRIPT_DIR | grep -q $check - val=$? - if [ "$val" = "0" ]; then + current_check=$(current_check_type) + if [ "$check" = "$current_check" ]; then return 0 fi # is the check being run manually (e.g., it is not a crontab symlink?) -- cgit v1.2.1