add a directory to run automated scripts by default
authorStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 17 Jun 2009 20:32:41 +0000 (20:32 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 17 Jun 2009 20:32:41 +0000 (20:32 +0000)
add a script to setup the ssh-agent to allow for password protected keys

cron.d/copy-logs.sh [new file with mode: 0755]
setup-agent.sh [new file with mode: 0755]

diff --git a/cron.d/copy-logs.sh b/cron.d/copy-logs.sh
new file mode 100755 (executable)
index 0000000..634d873
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+cd /usr/share/monitor
+source agent.sh &> /dev/null
+
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/httpd/*-* /var/lib/monitor/httpd-log
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/httpd/*error* /var/lib/monitor/httpd-log
+
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/*-filesystem* /var/lib/monitor/filesystem
+rsync -qv -az -e ssh root@chloe.cs.princeton.edu:/vservers/www-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
+
+rsync -qv -az -e ssh root@amber.cs.princeton.edu:/vservers/db-current/var/log/*-filesystem* /var/lib/monitor/filesystem
+rsync -qv -az -e ssh root@amber.cs.princeton.edu:/vservers/db-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
+
+rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/*-filesystem* /var/lib/monitor/filesystem
+rsync -qv -az -e ssh root@janine.cs.princeton.edu:/vservers/boot-current/var/log/*-checkrpm* /var/lib/monitor/checkrpm
diff --git a/setup-agent.sh b/setup-agent.sh
new file mode 100755 (executable)
index 0000000..2ac58df
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# NOTE: Must be an absolute path to guarantee it is read.
+INSTALLPATH=/usr/share/monitor/
+# Generate an 'sh' style file full of variables in monitor.conf
+$INSTALLPATH/shconfig.py >  $INSTALLPATH/monitorconfig.sh
+source $INSTALLPATH/monitorconfig.sh
+cd ${MONITOR_SCRIPT_ROOT}
+set -e
+DATE=`date +%Y-%m-%d-%T`
+
+set +e
+AGENT=`ps ax | grep ssh-agent | grep -v grep`
+set -e
+if [ -z "$AGENT" ] ; then
+        echo "starting ssh agent"
+        # if no agent is running, set it up.
+        ssh-agent > ${MONITOR_SCRIPT_ROOT}/agent.sh
+        source ${MONITOR_SCRIPT_ROOT}/agent.sh
+        ssh-add /etc/planetlab/debug_ssh_key.rsa
+        ssh-add /etc/planetlab/root_ssh_key.rsa
+fi
+#TODO: should add a call to ssh-add -l to check if the keys are loaded or not.
+source ${MONITOR_SCRIPT_ROOT}/agent.sh
+exit
+