Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp-v1 / manual_start.sh @ master

History | View | Annotate | Download (4.93 KB)

1 317bc815 Nitesh Mor
#!/bin/bash
2
3
# Script to manually operate a number of different components.
4
# This is an alternative to the much more automated "make xyz"
5
# ecosystem, but it provides a lot more control.
6 b0d00d2f Nitesh Mor
#
7
# You could just do `source <this filename>` and then run the
8
# provided shell functions as if they were shell commands.
9 317bc815 Nitesh Mor
10 5cc2efc2 Nitesh Mor
DBG=""
11 8aa6f61e Nitesh Mor
TMPDIR=/tmp/tmpdata
12 317bc815 Nitesh Mor
13
ROUTER_ID=$TMPDIR/router.id
14
ROUTER_KEY=$TMPDIR/router.key
15
ROUTER_PORT=8007
16
17 b6381853 Nitesh Mor
# additional router for bb related tests
18
ROUTER1_ID=$TMPDIR/router1.id
19
ROUTER1_KEY=$TMPDIR/router1.key
20
ROUTER1_PORT=8008
21
22 b0d00d2f Nitesh Mor
# log server
23 317bc815 Nitesh Mor
SERVER_ID=$TMPDIR/server.id
24
SERVER_KEY=$TMPDIR/server.key
25
SERVER_DIR=$TMPDIR/server
26
27 b0d00d2f Nitesh Mor
# normal clients (for reading, writing, etc)
28 317bc815 Nitesh Mor
CL_W_DIR=$TMPDIR/cl_w
29
CL_R_DIR=$TMPDIR/cl_r
30
31 b0d00d2f Nitesh Mor
# logname, etc
32 317bc815 Nitesh Mor
LOGNAME=$TMPDIR/log.name
33
LOGPRIV=$TMPDIR/log.privkey
34
LOGENC=$TMPDIR/log.enckey
35
36 b0d00d2f Nitesh Mor
# traffic agent client/server. We just separate them because
37
# why not?
38
TRAFFIC_AGENT_SERVER_ID=$TMPDIR/traffic-agent-server.id
39
TRAFFIC_AGENT_SERVER_KEY=$TMPDIR/traffic-agent-server.key
40
41 760c146d Nitesh Mor
gdp_clean_everything() {
42 317bc815 Nitesh Mor
    rm -rf $TMPDIR/*
43
}
44
45 760c146d Nitesh Mor
gdp_gen_names(){
46 317bc815 Nitesh Mor
    mkdir -p $TMPDIR
47
48
    # generate router keys
49 b0d00d2f Nitesh Mor
    ./apps/ent_gen $DBG router $ROUTER_ID $ROUTER_KEY
50 b6381853 Nitesh Mor
    ./apps/ent_gen $DBG router $ROUTER1_ID $ROUTER1_KEY
51 317bc815 Nitesh Mor
52
    # generate log-server keys
53 b0d00d2f Nitesh Mor
    ./apps/ent_gen $DBG server $SERVER_ID $SERVER_KEY
54
55
    # generate traffic-agent server/client keys
56
    ./apps/ent_gen $DBG client $TRAFFIC_AGENT_SERVER_ID $TRAFFIC_AGENT_SERVER_KEY
57 317bc815 Nitesh Mor
}
58
59 760c146d Nitesh Mor
gdp_run_router() {
60 317bc815 Nitesh Mor
    mkdir -p $TMPDIR
61 5cc2efc2 Nitesh Mor
    python -m gdp.routing -p $ROUTER_PORT $DBG $ROUTER_ID $ROUTER_KEY standalone -s
62 317bc815 Nitesh Mor
}
63
64
65 b6381853 Nitesh Mor
gdp_run_router_with_bb() {
66
    # runs the same router, but with bb support. need to call gdp_run_bb first
67
    mkdir -p $TMPDIR
68
    python -m gdp.routing -p $ROUTER_PORT $DBG $ROUTER_ID $ROUTER_KEY qa 127.0.0.1:8000
69
}
70
71
gdp_run_router1_with_bb() {
72
    # runs another router on a different port
73
    mkdir -p $TMPDIR
74
    python -m gdp.routing -p $ROUTER1_PORT $DBG $ROUTER1_ID $ROUTER1_KEY qa 127.0.0.1:8000
75
}
76
77
gdp_run_bb() {
78
    # run the blackbox
79
    mkdir -p $TMPDIR
80
    python -m gdp.routing.blackbox single 8000
81
}
82
83
84 760c146d Nitesh Mor
gdp_run_traffic_agent_server() {
85 b0d00d2f Nitesh Mor
    mkdir -p $TMPDIR
86
    router_name=`./apps/ent_read -a $ROUTER_ID`
87 9155ff20 Nitesh Mor
    router=127.0.0.1:$ROUTER_PORT,$router_name
88 f4242a11 Nitesh Mor
    ./apps/traffic-agent $DBG --router $router server \
89
        --id_file $TRAFFIC_AGENT_SERVER_ID --key_file $TRAFFIC_AGENT_SERVER_KEY
90 b0d00d2f Nitesh Mor
}
91
92 760c146d Nitesh Mor
gdp_run_traffic_agent_client() {
93 d83f5071 Nitesh Mor
    # pass in something like -n 100000 -s 5000
94 b0d00d2f Nitesh Mor
    mkdir -p $TMPDIR
95
    router_name=`./apps/ent_read -a $ROUTER_ID`
96 f4242a11 Nitesh Mor
    router=127.0.0.1:$ROUTER_PORT,$router_name
97 b0d00d2f Nitesh Mor
    server_name=`./apps/ent_read -a $TRAFFIC_AGENT_SERVER_ID`
98 d83f5071 Nitesh Mor
    set -x
99 f4242a11 Nitesh Mor
    ./apps/traffic-agent $DBG --router $router client \
100 d83f5071 Nitesh Mor
        --server $server_name \
101
        $@
102
    set +x
103 b0d00d2f Nitesh Mor
}
104
105 8b3d0a74 Nitesh Mor
gdp_run_ping_client() {
106
    # pass in something like -n 100 --skipfirst
107
    # run a regular server on the other side, that should work
108
    mkdir -p $TMPDIR
109
    router_name=`./apps/ent_read -a $ROUTER_ID`
110
    router=127.0.0.1:$ROUTER_PORT,$router_name
111
    remote_name=`./apps/ent_read -a $SERVER_ID`
112
    set -x
113
    ./apps/ping $DBG --router $router  \
114
        --remote $remote_name \
115
        $@
116
    set +x
117
}
118
119 b6381853 Nitesh Mor
gdp_run_ping_client_with_router1() {
120
    # connects to the additional router.
121
    # pass in something like -n 100 --skipfirst
122
    # run a regular server on the other side, that should work
123
    mkdir -p $TMPDIR
124
    router_name=`./apps/ent_read -a $ROUTER1_ID`
125
    router=127.0.0.1:$ROUTER1_PORT,$router_name
126
    remote_name=`./apps/ent_read -a $SERVER_ID`
127
    set -x
128
    ./apps/ping $DBG --router $router  \
129
        --remote $remote_name \
130
        $@
131
    set +x
132
}
133
134 8b3d0a74 Nitesh Mor
135 760c146d Nitesh Mor
gdp_run_server() {
136 317bc815 Nitesh Mor
    mkdir -p $TMPDIR
137
    router_name=`./apps/ent_read -a $ROUTER_ID`
138 af6bc6b8 Nitesh Mor
    router=127.0.0.1:$ROUTER_PORT,$router_name
139 317bc815 Nitesh Mor
    mkdir -p $SERVER_DIR
140 b6381853 Nitesh Mor
    set -x
141 e522faa0 Nitesh Mor
    python -m gdp.server $DBG \
142
        --router $router \
143
        --id_file $SERVER_ID --key_file $SERVER_KEY --logdir $SERVER_DIR
144 b6381853 Nitesh Mor
    set +x
145 317bc815 Nitesh Mor
}
146
147 760c146d Nitesh Mor
gdp_create_log() {
148 317bc815 Nitesh Mor
    mkdir -p $TMPDIR
149
    router_name=`./apps/ent_read -a $ROUTER_ID`
150
    router=127.0.0.1:$ROUTER_PORT,$router_name
151
    server_name=`./apps/ent_read -a $SERVER_ID`
152 5b2cd0db Nitesh Mor
    set -x
153
    ./apps/log-create $DBG --router $router --server $server_name \
154
        --nvdir $CL_W_DIR --logname $LOGNAME --privkey $LOGPRIV --enckey $LOGENC
155
    set +x
156 317bc815 Nitesh Mor
}
157
158
159 760c146d Nitesh Mor
gdp_append_log() {
160 d629f641 Nitesh Mor
    # pass in something like --source random 
161 317bc815 Nitesh Mor
    mkdir -p $TMPDIR
162
    logname=`cat $LOGNAME`
163
    router_name=`./apps/ent_read -a $ROUTER_ID`
164
    router=127.0.0.1:$ROUTER_PORT,$router_name
165 5b2cd0db Nitesh Mor
    set -x
166
    ./apps/log-append $DBG --router $router \
167 d629f641 Nitesh Mor
        --nvdir $CL_W_DIR --logname $logname --privkey $LOGPRIV --enckey $LOGENC \
168
        $@
169 5b2cd0db Nitesh Mor
    set +x
170 317bc815 Nitesh Mor
}
171
172 760c146d Nitesh Mor
gdp_read_log() {
173 d629f641 Nitesh Mor
    # pass in what you want to read, --start -1 --numrec 5
174 317bc815 Nitesh Mor
    mkdir -p $TMPDIR
175
    logname=`cat $LOGNAME`
176
    router_name=`./apps/ent_read -a $ROUTER_ID`
177
    router=127.0.0.1:$ROUTER_PORT,$router_name
178 5b2cd0db Nitesh Mor
    set -x
179
    ./apps/log-read $DBG --router $router \
180
        --nvdir $CL_R_DIR --logname $logname --enckey $LOGENC \
181 d629f641 Nitesh Mor
        $@
182 5b2cd0db Nitesh Mor
    set +x
183 317bc815 Nitesh Mor
}