summaryrefslogtreecommitdiff
path: root/.travis/tox-bootstrapd-docker
blob: bd192f072d91e8e10587695bbc8900a1e6b0a458 (plain)
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
#!/bin/sh

set -exu

tar c $(git ls-files) | docker build -f other/bootstrap_daemon/docker/Dockerfile -t toxchat/bootstrap-node -
sudo useradd \
  --home-dir /var/lib/tox-bootstrapd \
  --create-home \
  --system \
  --shell /sbin/nologin \
  --comment "Account to run Tox's DHT bootstrap daemon" \
  --user-group tox-bootstrapd
sudo chmod 700 /var/lib/tox-bootstrapd
docker run -d --name tox-bootstrapd \
  -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ \
  --ulimit nofile=32768:32768 \
  -p 443:443 \
  -p 3389:3389 \
  -p 33445:33445 \
  -p 33445:33445/udp \
  toxchat/bootstrap-node

sudo ls -lbh /var/lib/tox-bootstrapd

if sudo [ ! -f /var/lib/tox-bootstrapd/keys ]; then
  echo "Error: File /var/lib/tox-bootstrapd/keys doesn't exist"
  exit 1
fi

COUNTER=0
COUNTER_END=120
while [ $COUNTER -lt $COUNTER_END ]; do
  if docker logs tox-bootstrapd | grep -q "Connected to another bootstrap node successfully" ; then
    break
  fi
  sleep 1
  COUNTER=$(($COUNTER+1))
done

docker logs tox-bootstrapd

if [ "$COUNTER" = "$COUNTER_END" ]; then
  echo "Error: Didn't connect to any nodes"
  exit 1
fi

# Wait a bit befrore testing if the container is still running
sleep 30

docker ps -a

if [ "`docker inspect -f {{.State.Running}} tox-bootstrapd`" != "true" ]; then
  echo "Error: Container is not running"
  exit 1
fi

cat /proc/$(pidof tox-bootstrapd)/limits
if ! cat /proc/$(pidof tox-bootstrapd)/limits | grep -P '^Max open files(\s+)32768(\s+)32768(\s+)files'; then
  echo "Error: ulimit is not set to the expected value"
  exit 1
fi

if ! other/fun/bootstrap_node_info.py ipv4 localhost 33445 ; then
  echo "Error: Unable to get bootstrap node info"
  exit 1
fi