summaryrefslogtreecommitdiff
path: root/lognotify.sh
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-09-27 05:55:19 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-09-27 05:55:19 -0700
commitc536de67b14fd943f937be7bc84b099186632bc1 (patch)
tree97b30be51f36d0959f72660c2f52a982f3dbc1f5 /lognotify.sh
parent1b2b62ccd8122c72944dab5fa5f7f6214b1f93f8 (diff)
downloadlognotify-c536de67b14fd943f937be7bc84b099186632bc1.tar.gz
lognotify-c536de67b14fd943f937be7bc84b099186632bc1.tar.xz
Add SSH_OPTIONS setting, check that config exists.
Diffstat (limited to 'lognotify.sh')
-rwxr-xr-xlognotify.sh24
1 files changed, 18 insertions, 6 deletions
diff --git a/lognotify.sh b/lognotify.sh
index 161a50b..f291c50 100755
--- a/lognotify.sh
+++ b/lognotify.sh
@@ -1,7 +1,14 @@
#!/bin/bash
#
+# lognotify.sh
+# http://github.com/omp/lognotify
+#
# Copyright 2010 David Vazgenovich Shakaryan <dvshakaryan@gmail.com>
-# Distributed under the terms of the GNU General Public License v3
+# Distributed under the terms of the GNU General Public License v3.
+# See http://www.gnu.org/licenses/gpl.txt for the full license text.
+#
+# Retrieve additions to remote log files via SSH. Log files are cached locally
+# and only new lines are fetched from the server.
CACHEDIR="${HOME}/.cache/lognotify"
CONFIGDIR="${HOME}/.config/lognotify"
@@ -12,7 +19,13 @@ if [ $# != 1 ]; then
fi
IDENTIFIER="$1"
-source "${CONFIGDIR}/${IDENTIFIER}"
+
+if [ -f "${CONFIGDIR}/${IDENTIFIER}" ]; then
+ source "${CONFIGDIR}/${IDENTIFIER}"
+else
+ echo "$0: configuration file for specified identifier not found" >&2
+ exit 1
+fi
# Setup cache directory if nonexistent.
if [ ! -d "${CACHEDIR}" ]; then
@@ -33,16 +46,15 @@ echo "${LINES}"
echo -n "* Acquiring new lines via SSH... "
if [ "${LINES}" == 0 ]; then
- LOGAPPEND=$(ssh ${SERVER} "cat ${LOGPATH}")
+ LOGAPPEND=$(ssh ${SSH_OPTIONS} ${SSH_HOSTNAME} "cat ${LOGPATH}")
else
- LOGAPPEND=$(ssh ${SERVER} "cat ${LOGPATH} | sed -e '1,${LINES}d'")
+ LOGAPPEND=$(ssh ${SSH_OPTIONS} ${SSH_HOSTNAME} "cat ${LOGPATH} | sed -e '1,${LINES}d'")
fi
echo "Done"
if [ -n "${LOGAPPEND}" ]; then
echo "* Number of new lines: $(echo "${LOGAPPEND}" | wc -l)"
- echo
echo "${LOGAPPEND}" | tee -a "${CACHEDIR}/${IDENTIFIER}"
else
- echo "* No new lines found."
+ echo "* No new lines in log."
fi