From 927299b3bd7bd96e79f6ebac44e3a86a8d29a705 Mon Sep 17 00:00:00 2001
From: kohleman <kohleman>
Date: Wed, 20 Jan 2010 09:29:58 +0000
Subject: [PATCH] initial checkin. Used for Basysbio to automatically send an
 email when somebody logged into openBIS, uses the logins.sh script located in
 basysbio:/localhome/openbis/logs

SVN: 14348
---
 openbis_all/source/bash/check_logins.sh | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 openbis_all/source/bash/check_logins.sh

diff --git a/openbis_all/source/bash/check_logins.sh b/openbis_all/source/bash/check_logins.sh
new file mode 100644
index 00000000000..bb000c9da27
--- /dev/null
+++ b/openbis_all/source/bash/check_logins.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+export DATE=`/bin/date +%Y-%m-%d_%H%M`
+export MAIL_LIST="manuel.kohler@bsse.ethz.ch claus.hultschig@bsse.ethz.ch"
+export DIR=/localhome/openbis/logs/checks
+export MAILX=/bin/mailx
+
+/localhome/openbis/logs/logins.sh > $DIR/logins_$DATE.txt
+
+export SECOND_LATEST=`ls -t1 $DIR | tail -n 1`
+export LATEST=`ls -t1 $DIR | head -n 1`
+
+#echo "diff -q $DIR/$SECOND_LATEST $DIR/$LATEST"
+diff -q $DIR/$SECOND_LATEST $DIR/$LATEST
+
+if [ $? -ne 0 ]; then
+        export LAST_6_LINES=`tail -n 6 $DIR/$LATEST`
+        echo -e "$LAST_6_LINES" | $MAILX -s "Login to Basysbio detected!" $MAIL_LIST
+fi   
+
+/usr/bin/find $DIR -type f -mmin +1 -exec rm {} \;
\ No newline at end of file
-- 
GitLab