clearer names for actions, and infer actions better
[monitor.git] / tools / 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 $INSTALLPATH/commands/shconfig.py >  $INSTALLPATH/monitorconfig.sh
6 source $INSTALLPATH/monitorconfig.sh
7 cd ${MONITOR_SCRIPT_ROOT}
8 set -e
9 DATE=`date +%Y-%m-%d-%T`
10
11 set +e
12 AGENT=`ps ax | grep ssh-agent | grep -v grep`
13 set -e
14 if [ -z "$AGENT" ] ; then
15         echo "starting ssh agent"
16         # if no agent is running, set it up.
17         ssh-agent > ${MONITOR_SCRIPT_ROOT}/agent.sh
18         source ${MONITOR_SCRIPT_ROOT}/agent.sh
19         ssh-add /etc/planetlab/debug_ssh_key.rsa
20         ssh-add /etc/planetlab/root_ssh_key.rsa
21 fi
22 #TODO: should add a call to ssh-add -l to check if the keys are loaded or not.
23 source ${MONITOR_SCRIPT_ROOT}/agent.sh
24 exit
25