aboutsummaryrefslogtreecommitdiffstats
path: root/cron-sh/functions.sh
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2010-02-10 14:32:17 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2010-02-10 14:32:17 +0000
commitbdcb84e88f1877d173d48438c14c9042f2d1744e (patch)
tree67961b40a6b36788cd4938416dad968bb1fbc047 /cron-sh/functions.sh
parent4dcecbc414d68d6222250f9a2d45fe61391e4704 (diff)
downloadmsec-bdcb84e88f1877d173d48438c14c9042f2d1744e.tar
msec-bdcb84e88f1877d173d48438c14c9042f2d1744e.tar.gz
msec-bdcb84e88f1877d173d48438c14c9042f2d1744e.tar.bz2
msec-bdcb84e88f1877d173d48438c14c9042f2d1744e.tar.xz
msec-bdcb84e88f1877d173d48438c14c9042f2d1744e.zip
find out what is the current type of check
Diffstat (limited to 'cron-sh/functions.sh')
-rw-r--r--cron-sh/functions.sh29
1 files changed, 21 insertions, 8 deletions
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?)