-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathstart.sh
81 lines (66 loc) · 2.53 KB
/
start.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
74
75
76
77
78
79
80
81
#!/bin/bash
# Starts the ndt-server binary running with all its associated supporting
# services set up just right. If you just want to run a server that speaks the
# unencrypted NDT5 (legacy) protocol, then you can run:
# $ docker run --net=host measurementlab/ndt
# and you will get an NDT server running on port 3001, with data being saved to
# the in-container directory /var/spool/ndt/
#
# If you would like to run NDT7 tests (which you should, it is a simpler
# protocol and a more robust measurement), then you will need a private key and
# a TLS certificate (let's assume they are called "/etc/certs/key.pem" and
# "/etc/certs/cert.pem"). To run an NDT7 server on port 443, you can do:
# $ docker run -v /etc/certs:/certs --net=host measurementlab/ndt \
# --key=/certs/key.pem --cert=/certs/cert.pem
#
# The NDT server produces data on disk. If you would like this data saved to a
# directory outside of the docker container, then you need to mount the external
# directory inside the container at /var/spool/ndt using the -v argument to
# "docker run".
#
# All arguments to this script are passed directly through to ndt-server.
set -euxo pipefail
# Set up the filesystem.
# Set up UUIDs to have a common race-free prefix.
UUID_FILE=$(mktemp /tmp/uuidprefix.XXXXXX)
/create-uuid-prefix-file --filename="${UUID_FILE}"
# Set up the data directory.
DATA_DIR=/var/spool/ndt
mkdir -p "${DATA_DIR}"
# Start all services.
# Start the tcp-info logging service.
mkdir -p "${DATA_DIR}"/tcpinfo
/tcp-info \
--prometheusx.listen-address=:9991 \
--uuid-prefix-file="${UUID_FILE}" \
--output="${DATA_DIR}"/tcpinfo \
--tcpinfo.eventsocket=/var/local/tcpeventsocket.sock \
&
echo "Waiting for the tcpinfo eventsocket to become available..."
while ! socat -u OPEN:/dev/null UNIX-CONNECT:/var/local/tcpeventsocket.sock; do
sleep 1
done
# Start the traceroute service.
mkdir -p "${DATA_DIR}"/traceroute
/traceroute-caller \
--prometheusx.listen-address=:9992 \
--uuid-prefix-file="${UUID_FILE}" \
--hopannotation-output="${DATA_DIR}"/hopannotation1 \
--traceroute-output="${DATA_DIR}"/scamper1 \
--tcpinfo.eventsocket=/var/local/tcpeventsocket.sock \
&
# Start packet header capture.
mkdir -p "${DATA_DIR}"/pcap
/packet-headers \
--prometheusx.listen-address=:9993 \
--datadir="${DATA_DIR}"/pcap \
--tcpinfo.eventsocket=/var/local/tcpeventsocket.sock \
&
# Start the NDT server.
/ndt-server \
--uuid-prefix-file="${UUID_FILE}" \
--datadir="${DATA_DIR}" \
$*
&
# Any of the backgrounded processes dying should kill the whole thing.
wait -n