- fix attributes
[pingofdeath.git] / pl-podset
1 #! /bin/bash
2 Invocation="pl-podset HOSTIPAddr TARGETIPAddr"
3 # Run on a controlling computer to set the pod parameters on a
4 # remote node.  A hash code is generated and set into the remote
5 # node and stored in a local file for later invocation.
6 # -----------------------------------------------------------------
7 # $Header: /shareddata/CVS/planetlab/admin/ipod/pl-podset,v 1.3 2003/01/18 01:43:48 radams Exp $
8 #
9 # Copyright (c) 2003 Intel Corporation
10 # All rights reserved.
11 # This file is distributed under the terms in the attached INTEL_LICENSE
12 # file.  If you do not find this file, a copy can be obtained by
13 # writing to Intel Research Berkeley; Attention: Intel License Inquiry;
14 # 2150 Shattuck Avenue; Berkeley, CA 94704
15 # -----------------------------------------------------------------
16
17 HOSTIP=$1
18 TARGETIP=$2
19
20 if [[ x$HOSTIP == x || x$TARGETIP == x ]] ; then
21     echo "Invocation: $Invocation"
22     exit 1
23 fi
24
25 DATEE=`date +%Y%m%d%H%M`
26 TEMPFILE="/tmp/HashFile_$RANDOM"
27 HASHFILE="./HashFile"
28 PLBIN="/usr/local/planetlab/bin"
29
30 HASHCODE=`printf "%04x%04x%04x%04x%04x%04x%04x%04x\n" $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM $RANDOM`
31
32 #echo "HOSTIP = $HOSTIP"
33 #echo "TARGETIP = $TARGETIP"
34 #echo "HASHCODE = '$HASHCODE'"
35
36 ssh idsl1@$TARGETIP "sudo $PLBIN/pl-podcntl $HOSTIP 255.255.255.255 $HASHCODE"
37
38 if [[ -f $HASHFILE ]] ; then
39     grep -v "$TARGETIP" $HASHFILE > $TEMPFILE
40 else
41     touch $HASHFILE
42     touch $TEMPFILE
43 fi
44 echo "$DATEE    $HOSTIP $TARGETIP   $HASHCODE" >> $TEMPFILE
45 mv $HASHFILE $HASHFILE.last
46 mv $TEMPFILE $HASHFILE