|
@@ -36,6 +36,175 @@ DHTNODES=/usr/share/toxic/DHTnodes
|
36
|
36
|
IRC_PORT=6697
|
37
|
37
|
PEERS_FILE=/tmp/meshpeers.txt
|
38
|
38
|
|
|
39
|
+TOX_PORT=33445
|
|
40
|
+TOX_REPO='git://github.com/irungentoo/toxcore.git'
|
|
41
|
+TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
|
|
42
|
+
|
|
43
|
+function install_toxcore {
|
|
44
|
+ if [ -f $TOX_BOOTSTRAP_ID_FILE ]; then
|
|
45
|
+ return
|
|
46
|
+ fi
|
|
47
|
+
|
|
48
|
+ sudo apt-get -y install build-essential libtool autotools-dev
|
|
49
|
+ sudo apt-get -y install automake checkinstall check git yasm
|
|
50
|
+ sudo apt-get -y install libsodium13 libsodium-dev libcap2-bin
|
|
51
|
+ sudo apt-get -y install libconfig9 libconfig-dev
|
|
52
|
+
|
|
53
|
+ if [ ! -d ~/develop ]; then
|
|
54
|
+ mkdir ~/develop
|
|
55
|
+ fi
|
|
56
|
+ cd ~/develop
|
|
57
|
+ git clone $TOXCORE_REPO
|
|
58
|
+ cd ~/develop/toxcore
|
|
59
|
+ autoreconf -i
|
|
60
|
+ ./configure --enable-daemon
|
|
61
|
+ if [ ! "$?" = "0" ]; then
|
|
62
|
+ exit 78467
|
|
63
|
+ fi
|
|
64
|
+ make
|
|
65
|
+ if [ ! "$?" = "0" ]; then
|
|
66
|
+ exit 84562
|
|
67
|
+ fi
|
|
68
|
+ sudo make install
|
|
69
|
+ sudo cp /usr/local/lib/libtoxcore* /usr/lib/
|
|
70
|
+
|
|
71
|
+ if [ ! -f /usr/local/bin/tox-bootstrapd ]; then
|
|
72
|
+ echo "File not found /usr/local/bin/tox-bootstrapd"
|
|
73
|
+ exit 73862
|
|
74
|
+ fi
|
|
75
|
+
|
|
76
|
+ 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
|
|
77
|
+ sudo chmod 700 /var/lib/tox-bootstrapd
|
|
78
|
+ if [ ! -f ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf ]; then
|
|
79
|
+ echo "File not found $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.conf"
|
|
80
|
+ exit 476835
|
|
81
|
+ fi
|
|
82
|
+
|
|
83
|
+ # create configuration file
|
|
84
|
+ echo "port = $TOX_PORT" > /tmp/tox-bootstrapd.conf
|
|
85
|
+ echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> /tmp/tox-bootstrapd.conf
|
|
86
|
+ echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> /tmp/tox-bootstrapd.conf
|
|
87
|
+ echo 'enable_ipv6 = true' >> /tmp/tox-bootstrapd.conf
|
|
88
|
+ echo 'enable_ipv4_fallback = true' >> /tmp/tox-bootstrapd.conf
|
|
89
|
+ echo 'enable_lan_discovery = true' >> /tmp/tox-bootstrapd.conf
|
|
90
|
+ echo 'enable_tcp_relay = true' >> /tmp/tox-bootstrapd.conf
|
|
91
|
+ echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> /tmp/tox-bootstrapd.conf
|
|
92
|
+ echo 'enable_motd = true' >> /tmp/tox-bootstrapd.conf
|
|
93
|
+ echo 'motd = "tox-bootstrapd"' >> /tmp/tox-bootstrapd.conf
|
|
94
|
+ sudo cp /tmp/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
|
95
|
+ rm /tmp/tox-bootstrapd.conf
|
|
96
|
+
|
|
97
|
+ if [ -f /bin/systemctl ]; then
|
|
98
|
+ if [ ! -f ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service ]; then
|
|
99
|
+ echo "File not found ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service"
|
|
100
|
+ exit 7359
|
|
101
|
+ fi
|
|
102
|
+ sudo cp ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.service /etc/systemd/system/
|
|
103
|
+
|
|
104
|
+ sudo systemctl daemon-reload
|
|
105
|
+ sudo systemctl enable tox-bootstrapd.service
|
|
106
|
+ sudo systemctl start tox-bootstrapd.service
|
|
107
|
+ if [ ! "$?" = "0" ]; then
|
|
108
|
+ sudo systemctl status tox-bootstrapd.service
|
|
109
|
+ exit 5846
|
|
110
|
+ fi
|
|
111
|
+
|
|
112
|
+ sudo systemctl restart tox-bootstrapd.service
|
|
113
|
+ else
|
|
114
|
+ sudo cp ~/develop/toxcore/other/bootstrap_daemon/tox-bootstrapd.sh /etc/init.d/tox-bootstrapd
|
|
115
|
+ sudo chmod 755 /etc/init.d/tox-bootstrapd
|
|
116
|
+ sudo update-rc.d tox-bootstrapd defaults
|
|
117
|
+ sudo service tox-bootstrapd start
|
|
118
|
+ fi
|
|
119
|
+
|
|
120
|
+ TOX_PUBLIC_KEY=$(cat /var/log/syslog | grep tox | grep "Public Key" | awk -F ' ' '{print $8}' | tail -1)
|
|
121
|
+ if [ ${#TOX_PUBLIC_KEY} -lt 30 ]; then
|
|
122
|
+ echo 'Could not obtain the tox node public key'
|
|
123
|
+ exit 6529
|
|
124
|
+ fi
|
|
125
|
+
|
|
126
|
+ # save the public key for later reference
|
|
127
|
+ echo "$TOX_PUBLIC_KEY" > $TOX_BOOTSTRAP_ID_FILE
|
|
128
|
+}
|
|
129
|
+
|
|
130
|
+function install_toxid {
|
|
131
|
+ if [ -f /usr/local/bin/toxid ]; then
|
|
132
|
+ return
|
|
133
|
+ fi
|
|
134
|
+ cd ~/develop
|
|
135
|
+ git clone https://github.com/bashrc/toxid
|
|
136
|
+ cd ~/develop/toxid
|
|
137
|
+ make
|
|
138
|
+ sudo make install
|
|
139
|
+
|
|
140
|
+ if [ ! -f /usr/local/bin/toxid ]; then
|
|
141
|
+ echo "Couldn't install toxid"
|
|
142
|
+ exit 6389
|
|
143
|
+ fi
|
|
144
|
+
|
|
145
|
+ if ! grep -Fxq "toxavahi" /etc/crontab; then
|
|
146
|
+ cp /etc/crontab /tmp/crontab
|
|
147
|
+ echo "* * * * * root toxavahi > /dev/null" >> /tmp/crontab
|
|
148
|
+ sudo cp /tmp/crontab /etc/crontab
|
|
149
|
+ rm /tmp/crontab
|
|
150
|
+ fi
|
|
151
|
+}
|
|
152
|
+
|
|
153
|
+function run_tox {
|
|
154
|
+ if [ -f $TOXIC_PATH ]; then
|
|
155
|
+ # update bootstrap nodes
|
|
156
|
+ if [ -f $DHTNODES ]; then
|
|
157
|
+ if [ ! -f $DHTNODES.internet ]; then
|
|
158
|
+ sudo cp $DHTNODES $DHTNODES.internet
|
|
159
|
+ fi
|
|
160
|
+ fi
|
|
161
|
+ lstox -f dht > /tmp/dht
|
|
162
|
+ sudo cp /tmp/dht $DHTNODES
|
|
163
|
+
|
|
164
|
+ # get a list of peers
|
|
165
|
+ PEER_TOX_ID_LIST=$(lstox | grep $AVAHI_DOMAIN | sort -u)
|
|
166
|
+ if [ ! $PEER_TOX_ID_LIST ]; then
|
|
167
|
+ echo 'No peers found'
|
|
168
|
+ exit 0
|
|
169
|
+ fi
|
|
170
|
+ PEER_TOX_ID_LIST_COUNT=$(echo $PEER_TOX_ID_LIST | wc -l)
|
|
171
|
+ PEER_TOX_ID=''
|
|
172
|
+ if [ $PEER_TOX_ID_LIST_COUNT -lt "2" ]; then
|
|
173
|
+ # single peer
|
|
174
|
+ PEER_TOX_ID=$(echo $PEER_TOX_ID_LIST | awk -F ' ' '{print $3}')
|
|
175
|
+ else
|
|
176
|
+ # choose a user from a list
|
|
177
|
+ echo ''
|
|
178
|
+ echo "Select a user on $AVAHI_DOMAIN:"
|
|
179
|
+ ctr=0
|
|
180
|
+ while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
181
|
+ toxusername=$(echo $line | awk -F ' ' '{print $2}')
|
|
182
|
+ echo " $ctr. $toxusername"
|
|
183
|
+ ctr=$((ctr + 1))
|
|
184
|
+ done < "$PEER_TOX_ID_LIST"
|
|
185
|
+ read user_index
|
|
186
|
+ PEER_TOX_ID=$(echo $PEER_TOX_ID_LIST | tail -n+${user_index} | head -n1 | awk -F ' ' '{print $3}')
|
|
187
|
+ fi
|
|
188
|
+
|
|
189
|
+ # if this is a valid ID
|
|
190
|
+ if [ ${#PEER_TOX_ID} -gt 30 ]; then
|
|
191
|
+ # start client and make a friend request
|
|
192
|
+ echo "/nick $USER
|
|
193
|
+/add $PEER_TOX_ID
|
|
194
|
+/exit
|
|
195
|
+" | $TOXIC_PATH -d
|
|
196
|
+ # Running twice is a hack to get around buggyness in the client
|
|
197
|
+ $TOXIC_PATH -d
|
|
198
|
+ exit 0
|
|
199
|
+ else
|
|
200
|
+ # ID was invalid
|
|
201
|
+ echo $PEER_TOX_ID
|
|
202
|
+ echo "Tox ID for $AVAHI_DOMAIN was not found"
|
|
203
|
+ exit 6
|
|
204
|
+ fi
|
|
205
|
+ fi
|
|
206
|
+}
|
|
207
|
+
|
39
|
208
|
if [ ! -f /usr/bin/batman ]; then
|
40
|
209
|
freedombone-client
|
41
|
210
|
fi
|
|
@@ -49,13 +218,15 @@ if [ -f /usr/local/share/toxic/DHTnodes ]; then
|
49
|
218
|
fi
|
50
|
219
|
|
51
|
220
|
if [ ! -f /tmp/meshtype ]; then
|
|
221
|
+ install_toxcore
|
|
222
|
+ install_toxid
|
52
|
223
|
sudo batman start
|
53
|
224
|
if [ ! "$?" = "0" ]; then
|
54
|
225
|
exit 2
|
55
|
226
|
fi
|
56
|
227
|
fi
|
57
|
228
|
|
58
|
|
-avahi-browse -atl | grep "Workstation" | awk -F ' ' '{print $4}' > $PEERS_FILE
|
|
229
|
+avahi-browse -atl | grep "Workstation" | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
|
59
|
230
|
|
60
|
231
|
if [ ! -f $PEERS_FILE ]; then
|
61
|
232
|
echo 'No peers were found'
|
|
@@ -113,7 +284,7 @@ if [ ! $AVAHI_DOMAIN ]; then
|
113
|
284
|
exit 3
|
114
|
285
|
fi
|
115
|
286
|
|
116
|
|
-# Connect to IRC
|
|
287
|
+# if only mumble is installed
|
117
|
288
|
if [ ! -f $IRSSI_PATH ]; then
|
118
|
289
|
if [ ! -f $TOXIC_PATH ]; then
|
119
|
290
|
if [ -f $MUMBLE_PATH ]; then
|
|
@@ -126,6 +297,7 @@ if [ ! -f $IRSSI_PATH ]; then
|
126
|
297
|
fi
|
127
|
298
|
fi
|
128
|
299
|
|
|
300
|
+# if only irssi is installed
|
129
|
301
|
if [ ! -f $MUMBLE_PATH ]; then
|
130
|
302
|
if [ ! -f $TOXIC_PATH ]; then
|
131
|
303
|
if [ -f $IRSSI_PATH ]; then
|
|
@@ -138,33 +310,10 @@ if [ ! -f $MUMBLE_PATH ]; then
|
138
|
310
|
fi
|
139
|
311
|
fi
|
140
|
312
|
|
|
313
|
+# if only tox is installed
|
141
|
314
|
if [ ! -f $MUMBLE_PATH ]; then
|
142
|
315
|
if [ ! -f $IRSSI_PATH ]; then
|
143
|
|
- if [ -f $TOXIC_PATH ]; then
|
144
|
|
- if [ -f $DHTNODES ]; then
|
145
|
|
- if [ ! -f $DHTNODES.internet ]; then
|
146
|
|
- sudo cp $DHTNODES $DHTNODES.internet
|
147
|
|
- fi
|
148
|
|
- fi
|
149
|
|
- lstox -f dht > /tmp/dht
|
150
|
|
- sudo cp /tmp/dht $DHTNODES
|
151
|
|
- PEER_TOX_ID=$(lstox | grep $AVAHI_DOMAIN | head -n 1 | awk -F ' ' '{print $2}')
|
152
|
|
- if [ ${#PEER_TOX_ID} -gt 30 ]; then
|
153
|
|
- echo "/nick $USER
|
154
|
|
-/add $PEER_TOX_ID
|
155
|
|
-/exit
|
156
|
|
-" | $TOXIC_PATH -d
|
157
|
|
- $TOXIC_PATH -d
|
158
|
|
- exit 0
|
159
|
|
- else
|
160
|
|
- echo $PEER_TOX_ID
|
161
|
|
- echo "Tox ID for $AVAHI_DOMAIN was not found"
|
162
|
|
- exit 6
|
163
|
|
- fi
|
164
|
|
- fi
|
165
|
|
- echo 'You need irssi/mumble/toxic installed on your system'
|
166
|
|
- sudo batman stop
|
167
|
|
- exit 4
|
|
316
|
+ run_tox
|
168
|
317
|
fi
|
169
|
318
|
fi
|
170
|
319
|
|
|
@@ -172,7 +321,7 @@ echo ''
|
172
|
321
|
echo 'Choose communication service:'
|
173
|
322
|
echo ' 1. VoIP'
|
174
|
323
|
echo ' 2. Tox Chat'
|
175
|
|
-echo ' 3. IRC (WARNING: not encrypted)'
|
|
324
|
+echo ' 3. IRC (WARNING: not secure)'
|
176
|
325
|
echo ''
|
177
|
326
|
|
178
|
327
|
read peer_index
|
|
@@ -203,34 +352,12 @@ if [[ $peer_index == 1 ]]; then
|
203
|
352
|
fi
|
204
|
353
|
else
|
205
|
354
|
if [[ $peer_index == 2 ]]; then
|
206
|
|
- if [ -f $TOX_PATH ]; then
|
207
|
|
- if [ -f $DHTNODES ]; then
|
208
|
|
- if [ ! -f $DHTNODES.internet ]; then
|
209
|
|
- sudo cp $DHTNODES $DHTNODES.internet
|
210
|
|
- fi
|
211
|
|
- fi
|
212
|
|
- lstox -f dht > /tmp/dht
|
213
|
|
- sudo cp /tmp/dht $DHTNODES
|
214
|
|
- PEER_TOX_ID=$(lstox | grep $AVAHI_DOMAIN | head -n 1 | awk -F ' ' '{print $2}')
|
215
|
|
- if [ ${#PEER_TOX_ID} -gt 30 ]; then
|
216
|
|
- echo "/nick $USER
|
217
|
|
-/add $PEER_TOX_ID
|
218
|
|
-/exit
|
219
|
|
-" | $TOXIC_PATH -d
|
220
|
|
- $TOXIC_PATH -d
|
221
|
|
- else
|
222
|
|
- echo "Tox ID for $AVAHI_DOMAIN was not found"
|
223
|
|
- exit 6
|
224
|
|
- fi
|
225
|
|
- else
|
226
|
|
- echo 'Tox may not be installed on this system'
|
227
|
|
- exit 7
|
228
|
|
- fi
|
|
355
|
+ run_tox
|
229
|
356
|
else
|
230
|
357
|
if [ -f $IRSSI_PATH ]; then
|
231
|
358
|
$IRSSI_PATH -c $AVAHI_DOMAIN -p $IRC_PORT -n $USER
|
232
|
359
|
else
|
233
|
|
- echo 'Irssi may not be installed on this system'
|
|
360
|
+ echo 'Irssi/toxic/mumble may not be installed on this system'
|
234
|
361
|
exit 8
|
235
|
362
|
fi
|
236
|
363
|
fi
|