aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.org>2010-02-08 14:05:07 +0000
committerEugeni Dodonov <eugeni@mandriva.org>2010-02-08 14:05:07 +0000
commit8b1cc778159c690f4ea1e140ffe547a9e5b462b5 (patch)
tree237ddae2884c93ef4305b830c65c5f0d2ff4b206
parentcbf363eddb0e2acfe8e7ed038905e0c33ccfaad6 (diff)
downloadmsec-8b1cc778159c690f4ea1e140ffe547a9e5b462b5.tar
msec-8b1cc778159c690f4ea1e140ffe547a9e5b462b5.tar.gz
msec-8b1cc778159c690f4ea1e140ffe547a9e5b462b5.tar.bz2
msec-8b1cc778159c690f4ea1e140ffe547a9e5b462b5.tar.xz
msec-8b1cc778159c690f4ea1e140ffe547a9e5b462b5.zip
Add support for periodic checks with variable periodicity
-rw-r--r--cron-sh/functions.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/cron-sh/functions.sh b/cron-sh/functions.sh
index 4be3f7f..9592e36 100644
--- a/cron-sh/functions.sh
+++ b/cron-sh/functions.sh
@@ -37,6 +37,36 @@ FILTER="\(`echo $EXCLUDEDIR | sed -e 's/ /\\\|/g'`\)"
### Functions ###
+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
+ echo no
+ return 0
+ fi
+ # check if the test is supposed to be executed on this run
+ echo $SCRIPT_DIR | grep -q $check
+ val=$?
+ if [ "$val" = "0" ]; then
+ echo yes
+ return 1
+ fi
+ # is it a manual check?
+ istty=$(tty -s)
+ if $istty && [ "$check" = "manual" ]; then
+ echo yes
+ return 1
+ fi
+ echo no
+ return 0
+}
+
+
+
Diffcheck() {
TODAY="$1"
YESTERDAY="$2"