Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

gdp-v1 / manual_start.sh @ master

History | View | Annotate | Download (4.93 KB)

1
#!/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
#
7
# You could just do `source <this filename>` and then run the
8
# provided shell functions as if they were shell commands.
9

    
10
DBG=""
11
TMPDIR=/tmp/tmpdata
12

    
13
ROUTER_ID=$TMPDIR/router.id
14
ROUTER_KEY=$TMPDIR/router.key
15
ROUTER_PORT=8007
16

    
17
# additional router for bb related tests
18
ROUTER1_ID=$TMPDIR/router1.id
19
ROUTER1_KEY=$TMPDIR/router1.key
20
ROUTER1_PORT=8008
21

    
22
# log server
23
SERVER_ID=$TMPDIR/server.id
24
SERVER_KEY=$TMPDIR/server.key
25
SERVER_DIR=$TMPDIR/server
26

    
27
# normal clients (for reading, writing, etc)
28
CL_W_DIR=$TMPDIR/cl_w
29
CL_R_DIR=$TMPDIR/cl_r
30

    
31
# logname, etc
32
LOGNAME=$TMPDIR/log.name
33
LOGPRIV=$TMPDIR/log.privkey
34
LOGENC=$TMPDIR/log.enckey
35

    
36
# 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
gdp_clean_everything() {
42
    rm -rf $TMPDIR/*
43
}
44

    
45
gdp_gen_names(){
46
    mkdir -p $TMPDIR
47

    
48
    # generate router keys
49
    ./apps/ent_gen $DBG router $ROUTER_ID $ROUTER_KEY
50
    ./apps/ent_gen $DBG router $ROUTER1_ID $ROUTER1_KEY
51

    
52
    # generate log-server keys
53
    ./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
}
58

    
59
gdp_run_router() {
60
    mkdir -p $TMPDIR
61
    python -m gdp.routing -p $ROUTER_PORT $DBG $ROUTER_ID $ROUTER_KEY standalone -s
62
}
63

    
64

    
65
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
gdp_run_traffic_agent_server() {
85
    mkdir -p $TMPDIR
86
    router_name=`./apps/ent_read -a $ROUTER_ID`
87
    router=127.0.0.1:$ROUTER_PORT,$router_name
88
    ./apps/traffic-agent $DBG --router $router server \
89
        --id_file $TRAFFIC_AGENT_SERVER_ID --key_file $TRAFFIC_AGENT_SERVER_KEY
90
}
91

    
92
gdp_run_traffic_agent_client() {
93
    # pass in something like -n 100000 -s 5000
94
    mkdir -p $TMPDIR
95
    router_name=`./apps/ent_read -a $ROUTER_ID`
96
    router=127.0.0.1:$ROUTER_PORT,$router_name
97
    server_name=`./apps/ent_read -a $TRAFFIC_AGENT_SERVER_ID`
98
    set -x
99
    ./apps/traffic-agent $DBG --router $router client \
100
        --server $server_name \
101
        $@
102
    set +x
103
}
104

    
105
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
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

    
135
gdp_run_server() {
136
    mkdir -p $TMPDIR
137
    router_name=`./apps/ent_read -a $ROUTER_ID`
138
    router=127.0.0.1:$ROUTER_PORT,$router_name
139
    mkdir -p $SERVER_DIR
140
    set -x
141
    python -m gdp.server $DBG \
142
        --router $router \
143
        --id_file $SERVER_ID --key_file $SERVER_KEY --logdir $SERVER_DIR
144
    set +x
145
}
146

    
147
gdp_create_log() {
148
    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
    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
}
157

    
158

    
159
gdp_append_log() {
160
    # pass in something like --source random 
161
    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
    set -x
166
    ./apps/log-append $DBG --router $router \
167
        --nvdir $CL_W_DIR --logname $logname --privkey $LOGPRIV --enckey $LOGENC \
168
        $@
169
    set +x
170
}
171

    
172
gdp_read_log() {
173
    # pass in what you want to read, --start -1 --numrec 5
174
    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
    set -x
179
    ./apps/log-read $DBG --router $router \
180
        --nvdir $CL_R_DIR --logname $logname --enckey $LOGENC \
181
        $@
182
    set +x
183
}