2ac58df1366322b999cce4ace52303bb64931421
[monitor.git] / setup-agent.sh
1 #!/bin/bash
2
3 # NOTE: Must be an absolute path to guarantee it is read.
4 INSTALLPATH=/usr/share/monitor/
5 # Generate an 'sh' style file full of variables in monitor.conf
6 $INSTALLPATH/shconfig.py >  $INSTALLPATH/monitorconfig.sh
7 source $INSTALLPATH/monitorconfig.sh
8 cd ${MONITOR_SCRIPT_ROOT}
9 set -e
10 DATE=`date +%Y-%m-%d-%T`
11
12 set +e
13 AGENT=`ps ax | grep ssh-agent | grep -v grep`
14 set -e
15 if [ -z "$AGENT" ] ; then
16         echo "starting ssh agent"
17         # if no agent is running, set it up.
18         ssh-agent > ${MONITOR_SCRIPT_ROOT}/agent.sh
19         source ${MONITOR_SCRIPT_ROOT}/agent.sh
20         ssh-add /etc/planetlab/debug_ssh_key.rsa
21         ssh-add /etc/planetlab/root_ssh_key.rsa
22 fi
23 #TODO: should add a call to ssh-add -l to check if the keys are loaded or not.
24 source ${MONITOR_SCRIPT_ROOT}/agent.sh
25 exit
26