-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_Revelio.sh
executable file
·74 lines (58 loc) · 2.17 KB
/
run_Revelio.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env sh
# call the script with sudo!!
# example:
# sudo bash ./run_Revelio.sh revelio_on_location "unique-location-name"
# the name of the location should not go over 100 characters
# get the working directory
DIR="$( cd "$( dirname $0 )" && pwd )"
# create the results file in /tmp ?
# add curl command to download the test binary here
# get the mac address
# ---------------------------------------------------------------------------
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
# gnu/linux
mac=$( ( ip link show | grep eth | awk '/ether/ {print $2}' | head -1 ) \
2>/dev/null );
if [ -z "$mac" ]; then
# openwrt
mac=$( ( ifconfig br-lan | awk '/HWaddr/ {print $5}' ) 2> /dev/null );
fi
elif [[ "$unamestr" == 'Darwin' ]]; then
# mac os x
mac=$( ( ifconfig | awk '/ether/ {print $2}' ) 2> /dev/null );
fi
if [ -z "$mac" ]; then
if [ -z "$MACADDRESS" ]; then
echo "cannot set mac address; set MACADDRESS env" > /dev/stderr;
exit 1
else
mac=$MACADDRESS;
fi
fi
# uniform UUID representation
mac=`echo $mac | tr "[:upper:]" "[:lower:]"`
# ---------------------------------------------------------------------------
# retrieve the boxid from the server
# ---------------------------------------------------------------------------
data="{\"mac\" : \"${mac}\"}"
boxid=$( (curl -X POST -H "Content-Type: application/json" -d "$data" http://zompopo.it.uc3m.es/measurement_agent 2> /dev/null ) );
if [ -z "$boxid" ]; then
echo "server did not send uuid" > /dev/stderr; # boxid = uuid
exit 1
fi
# ---------------------------------------------------------------------------
# verify if miniupnp is installed
miniupnp=$(ldconfig -p | grep "miniupnpc")
if [ -z "$miniupnp" ]; then
echo "miniupnpc no found; install before re-run" > /dev/stderr;
exit 1
fi
#-----------------------------------------------------------------------------
#result file
mkdir -p $DIR/results && touch $DIR/results/$boxid
#hour=$( date '+%H' )
#day=$( date '+%d' )
$DIR/bin/$1 -l $2 >> $DIR/results/$boxid 2> /dev/null
curl -X POST -F results=@"$DIR/results/$boxid" "http://zompopo.it.uc3m.es/Revelio/$boxid/result" > /dev/null 2>&1
rm -rf $DIR/results