diff options
Diffstat (limited to 'other')
-rw-r--r-- | other/bootstrap_daemon/README.md | 51 | ||||
-rw-r--r-- | other/bootstrap_daemon/docker/Dockerfile | 59 | ||||
-rw-r--r-- | other/bootstrap_daemon/docker/get-nodes.py | 49 |
3 files changed, 158 insertions, 1 deletions
diff --git a/other/bootstrap_daemon/README.md b/other/bootstrap_daemon/README.md index e77e3ae0..2d9e5615 100644 --- a/other/bootstrap_daemon/README.md +++ b/other/bootstrap_daemon/README.md | |||
@@ -5,7 +5,9 @@ | |||
5 | <br> | 5 | <br> |
6 | - [For `init.d` users](#initd) | 6 | - [For `init.d` users](#initd) |
7 | - [Troubleshooting](#initd-troubleshooting) | 7 | - [Troubleshooting](#initd-troubleshooting) |
8 | 8 | <br> | |
9 | - [For `Docker` users](#docker) | ||
10 | - [Troubleshooting](#docker-troubleshooting) | ||
9 | 11 | ||
10 | These instructions are primarily tested on Debian Linux, Wheezy for init.d and Jessie for systemd, but they should work on other POSIX-compliant systems too. | 12 | These instructions are primarily tested on Debian Linux, Wheezy for init.d and Jessie for systemd, but they should work on other POSIX-compliant systems too. |
11 | 13 | ||
@@ -146,3 +148,50 @@ sudo grep "tox-bootstrapd" /var/log/syslog | |||
146 | - Make sure tox-bootstrapd has read permission for the config file. | 148 | - Make sure tox-bootstrapd has read permission for the config file. |
147 | 149 | ||
148 | - Make sure tox-bootstrapd location matches its path in the `/etc/init.d/tox-bootstrapd` init script. | 150 | - Make sure tox-bootstrapd location matches its path in the `/etc/init.d/tox-bootstrapd` init script. |
151 | |||
152 | |||
153 | <a name="docker" /> | ||
154 | ##For `Docker` users: | ||
155 | |||
156 | If you are familiar with Docker and would rather run the daemon in a Docker container, run the following from this directory: | ||
157 | |||
158 | ```sh | ||
159 | sudo docker build -t tox-bootstrapd docker/ | ||
160 | |||
161 | 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 | ||
162 | sudo chmod 700 /var/lib/tox-bootstrapd | ||
163 | |||
164 | sudo docker run -d --name tox-bootstrapd --restart always -v /var/lib/tox-bootstrapd/:/var/lib/tox-bootstrapd/ -p 443:443 -p 3389:3389 -p 33445:33445 -p 33445:33445/udp tox-bootstrapd | ||
165 | ``` | ||
166 | |||
167 | We create a new user and protect its home directory in order to mount it in the Docker image, so that the kyepair the daemon uses would be shared with the host system, which makes it less likely that you would loose the keypair while playing with the Docker container. | ||
168 | |||
169 | You can check logs for your public key or any errors: | ||
170 | ```sh | ||
171 | sudo docker logs tox-bootstrapd | ||
172 | ``` | ||
173 | |||
174 | If you are an experienced Docker user and have a version of Docker that supports `docker cp` both host->container and container->host directions, you might want to skip the directory mounting part and just do: | ||
175 | |||
176 | ```sh | ||
177 | sudo docker build -t tox-bootstrapd docker/ | ||
178 | sudo docker run -d --name tox-bootstrapd --restart always -p 443:443 -p 3389:3389 -p 33445:33445 -p 33445:33445/udp tox-bootstrapd | ||
179 | sudo docker logs tox-bootstrapd | ||
180 | ``` | ||
181 | |||
182 | The keypair is stored in `/var/lib/tox-bootstrapd/keys` file, so if you skipped the directory mounting part and want a new Docker container to retain the same public key that from an old one, just copy/overwrite it from the old container. | ||
183 | |||
184 | Note that the Docker container runs a script which pulls a list of bootstrap nodes off https://nodes.tox.chat/ and adds them in the config file. | ||
185 | |||
186 | <a name="docker-troubleshooting" /> | ||
187 | ###Troubleshooting: | ||
188 | |||
189 | - Check if the container is running: | ||
190 | ```sh | ||
191 | sudo docker ps -a | ||
192 | ``` | ||
193 | |||
194 | - Check the log for errors: | ||
195 | ```sh | ||
196 | sudo docker logs tox-bootstrapd | ||
197 | ``` | ||
diff --git a/other/bootstrap_daemon/docker/Dockerfile b/other/bootstrap_daemon/docker/Dockerfile new file mode 100644 index 00000000..ef9d525c --- /dev/null +++ b/other/bootstrap_daemon/docker/Dockerfile | |||
@@ -0,0 +1,59 @@ | |||
1 | FROM debian:jessie | ||
2 | |||
3 | # get all deps | ||
4 | RUN apt-get update && apt-get install -y \ | ||
5 | build-essential \ | ||
6 | libtool \ | ||
7 | autotools-dev \ | ||
8 | automake \ | ||
9 | checkinstall \ | ||
10 | check \ | ||
11 | git \ | ||
12 | yasm \ | ||
13 | libsodium-dev \ | ||
14 | libconfig-dev \ | ||
15 | python3 \ | ||
16 | && apt-get clean \ | ||
17 | && rm -rf /var/lib/apt/lists/* | ||
18 | |||
19 | # install toxcore and daemon | ||
20 | WORKDIR /root/ | ||
21 | RUN git clone https://github.com/irungentoo/toxcore | ||
22 | WORKDIR /root/toxcore/ | ||
23 | RUN ./autogen.sh | ||
24 | RUN ./configure --enable-daemon | ||
25 | RUN make -j`nproc` | ||
26 | RUN make install -j`nproc` | ||
27 | RUN ldconfig | ||
28 | |||
29 | WORKDIR /root/toxcore/other/bootstrap_daemon/ | ||
30 | |||
31 | # add new user | ||
32 | RUN useradd --home-dir /var/lib/tox-bootstrapd --create-home \ | ||
33 | --system --shell /sbin/nologin \ | ||
34 | --comment "Account to run Tox's DHT bootstrap daemon" \ | ||
35 | --user-group tox-bootstrapd | ||
36 | RUN chmod 700 /var/lib/tox-bootstrapd | ||
37 | |||
38 | RUN cp tox-bootstrapd.conf /etc/tox-bootstrapd.conf | ||
39 | |||
40 | # remove all the example bootstrap nodes from the config file | ||
41 | RUN N=-1 && \ | ||
42 | while grep -q "bootstrap_nodes =" /etc/tox-bootstrapd.conf; \ | ||
43 | do \ | ||
44 | head -n $N tox-bootstrapd.conf > /etc/tox-bootstrapd.conf; \ | ||
45 | N=$((N-1)); \ | ||
46 | done | ||
47 | |||
48 | # add bootstrap nodes from https://nodes.tox.chat/ | ||
49 | RUN python3 docker/get-nodes.py >> /etc/tox-bootstrapd.conf | ||
50 | |||
51 | USER tox-bootstrapd | ||
52 | |||
53 | ENTRYPOINT /usr/local/bin/tox-bootstrapd \ | ||
54 | --config /etc/tox-bootstrapd.conf \ | ||
55 | --log-backend stdout \ | ||
56 | --foreground | ||
57 | |||
58 | EXPOSE 443 3389 33445 | ||
59 | EXPOSE 33445/udp | ||
diff --git a/other/bootstrap_daemon/docker/get-nodes.py b/other/bootstrap_daemon/docker/get-nodes.py new file mode 100644 index 00000000..9a284748 --- /dev/null +++ b/other/bootstrap_daemon/docker/get-nodes.py | |||
@@ -0,0 +1,49 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | """ | ||
3 | Copyright (c) 2016 by nurupo <nurupo.contributions@gmail.com> | ||
4 | |||
5 | Permission is hereby granted, free of charge, to any person obtaining a copy | ||
6 | of this software and associated documentation files (the "Software"), to deal | ||
7 | in the Software without restriction, including without limitation the rights | ||
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
9 | copies of the Software, and to permit persons to whom the Software is | ||
10 | furnished to do so, subject to the following conditions: | ||
11 | |||
12 | The above copyright notice and this permission notice shall be included in | ||
13 | all copies or substantial portions of the Software. | ||
14 | |||
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
21 | THE SOFTWARE. | ||
22 | """ | ||
23 | |||
24 | # Gets a list of nodes from https://nodes.tox.chat/json and prints them out | ||
25 | # in the format of tox-bootstrapd config file. | ||
26 | |||
27 | import urllib.request | ||
28 | import json | ||
29 | |||
30 | response = urllib.request.urlopen('https://nodes.tox.chat/json') | ||
31 | raw_json = response.read().decode('ascii', 'ignore') | ||
32 | nodes = json.loads(raw_json)['nodes'] | ||
33 | |||
34 | output = 'bootstrap_nodes = (' | ||
35 | |||
36 | for node in nodes: | ||
37 | node_output = ' { // ' + node['maintainer'] + '\n' | ||
38 | node_output += ' public_key = "' + node['public_key'] + '"\n' | ||
39 | node_output += ' port = ' + str(node['port']) + '\n' | ||
40 | node_output += ' address = "' | ||
41 | if len(node['ipv4']) > 4: | ||
42 | output += node_output + node['ipv4'] + '"\n },\n' | ||
43 | if len(node['ipv6']) > 4: | ||
44 | output += node_output + node['ipv6'] + '"\n },\n' | ||
45 | |||
46 | # remove last comma | ||
47 | output = output[:-2] + '\n)\n' | ||
48 | |||
49 | print(output) | ||