|
@@ -74,12 +74,12 @@ function logging_off_tox {
|
74
|
74
|
function remove_user_tox {
|
75
|
75
|
remove_username="$1"
|
76
|
76
|
|
77
|
|
- if [ -d /home/$remove_username/.config/tox ]; then
|
78
|
|
- if [ -d /home/$remove_username/.config/tox/chatlogs ]; then
|
79
|
|
- shred -zu /home/$remove_username/.config/tox/chatlogs/*
|
80
|
|
- rm -rf /home/$remove_username/.config/tox/chatlogs
|
|
77
|
+ if [ -d "/home/$remove_username/.config/tox" ]; then
|
|
78
|
+ if [ -d "/home/$remove_username/.config/tox/chatlogs" ]; then
|
|
79
|
+ shred -zu "/home/$remove_username/.config/tox/chatlogs/*"
|
|
80
|
+ rm -rf "/home/$remove_username/.config/tox/chatlogs"
|
81
|
81
|
fi
|
82
|
|
- shred -zu /home/$remove_username/.config/tox/*
|
|
82
|
+ shred -zu "/home/$remove_username/.config/tox/*"
|
83
|
83
|
fi
|
84
|
84
|
}
|
85
|
85
|
|
|
@@ -87,27 +87,27 @@ function add_user_tox {
|
87
|
87
|
new_username="$1"
|
88
|
88
|
|
89
|
89
|
# Note: password isn't used
|
90
|
|
- new_user_password="$2"
|
|
90
|
+ #new_user_password="$2"
|
91
|
91
|
|
92
|
92
|
USER_TOX_FILE=/home/${new_username}/.config/tox/data.tox
|
93
|
|
- if [ ! -f $USER_TOX_FILE ]; then
|
94
|
|
- mkdir -p /home/${new_username}/.config/tox
|
95
|
|
- chown -R ${new_username}:${new_username} /home/${new_username}/.config
|
96
|
|
- su -c "toxid -u ${new_username} -n data" - $new_username
|
97
|
|
- su -c "toxid --setuser ${new_username}" - $new_username
|
|
93
|
+ if [ ! -f "$USER_TOX_FILE" ]; then
|
|
94
|
+ mkdir -p "/home/${new_username}/.config/tox"
|
|
95
|
+ chown -R "${new_username}":"${new_username}" "/home/${new_username}/.config"
|
|
96
|
+ su -c "toxid -u ${new_username} -n data" - "$new_username"
|
|
97
|
+ su -c "toxid --setuser ${new_username}" - "$new_username"
|
98
|
98
|
fi
|
99
|
99
|
}
|
100
|
100
|
|
101
|
101
|
function run_client_tox {
|
102
|
102
|
# create a tox user
|
103
|
103
|
USER_TOX_FILE=/home/${USER}/.config/tox/data.tox
|
104
|
|
- if [ ! -f $USER_TOX_FILE ]; then
|
105
|
|
- mkdir -p /home/${USER}/.config/tox
|
106
|
|
- chown -R ${USER}:${USER} /home/${USER}/.config
|
107
|
|
- toxid -u ${USER} -n data
|
108
|
|
- toxid --setuser ${USER}
|
|
104
|
+ if [ ! -f "$USER_TOX_FILE" ]; then
|
|
105
|
+ mkdir -p "/home/${USER}/.config/tox"
|
|
106
|
+ chown -R "${USER}":"${USER}" "/home/${USER}/.config"
|
|
107
|
+ toxid -u "${USER}" -n data
|
|
108
|
+ toxid --setuser "${USER}"
|
109
|
109
|
fi
|
110
|
|
- toxic -f $USER_TOX_FILE --force-tcp --SOCKS5-proxy 127.0.0.1 9050
|
|
110
|
+ toxic -f "$USER_TOX_FILE" --force-tcp --SOCKS5-proxy 127.0.0.1 9050
|
111
|
111
|
}
|
112
|
112
|
|
113
|
113
|
function install_interactive_tox {
|
|
@@ -121,16 +121,17 @@ function configure_interactive_tox {
|
121
|
121
|
fi
|
122
|
122
|
bootstrap_id=$(cat $TOX_BOOTSTRAP_ID_FILE)
|
123
|
123
|
dialog --title $"Tox Bootstrap Node ID" \
|
124
|
|
- --msgbox $"\n$bootstrap_id\n\nTo copy this hold down the shift key, select the ID and then right click and copy." 10 70
|
|
124
|
+ --msgbox $"\\n$bootstrap_id\\n\\nTo copy this hold down the shift key, select the ID and then right click and copy." 10 70
|
125
|
125
|
}
|
126
|
126
|
|
127
|
127
|
function mesh_tox_qtox {
|
128
|
|
- if [ ! ${rootdir}$INSTALL_DIR ]; then
|
|
128
|
+ # shellcheck disable=SC2154
|
|
129
|
+ if [ ! "${rootdir}$INSTALL_DIR" ]; then
|
129
|
130
|
INSTALL_DIR=${rootdir}/root/build
|
130
|
131
|
fi
|
131
|
132
|
|
132
|
|
- if [ ! -d ${rootdir}$INSTALL_DIR ]; then
|
133
|
|
- mkdir -p ${rootdir}$INSTALL_DIR
|
|
133
|
+ if [ ! -d "${rootdir}$INSTALL_DIR" ]; then
|
|
134
|
+ mkdir -p "${rootdir}$INSTALL_DIR"
|
134
|
135
|
fi
|
135
|
136
|
|
136
|
137
|
chroot "${rootdir}" apt-get -yq install build-essential libatk1.0-0 libbz2-1.0 libc6 libcairo2 libdbus-1-3 libegl1-mesa libfontconfig1 libfreetype6 libgcc1 libgdk-pixbuf2.0-0 libgl1-mesa-glx libglib2.0-0 libgtk2.0-0 libice6 libicu57 libjpeg62-turbo libmng1 libmtdev1 libopenal1 libopus0 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpng16-16 libqrencode3 libsm6 libsodium18 libsqlite3-0 libssl1.1 libstdc++6 libtiff5 libudev1 libvpx4 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa libwebp6 libx11-6 libx11-xcb1 libxcb-glx0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinerama0 libxcb1 libxext6 libxfixes3 libxi6 libxrender1 libxss1 zlib1g libopus-dev libvpx-dev
|
|
@@ -149,30 +150,30 @@ function mesh_tox_qtox {
|
149
|
150
|
chroot "${rootdir}" apt-get -yq install build-essential cmake ffmpeg libexif-dev libgdk-pixbuf2.0-dev libglib2.0-dev libgtk2.0-dev libopenal-dev libqrencode-dev libqt5opengl5-dev libqt5svg5-dev libsqlcipher-dev libxss-dev pkg-config qrencode qt5-default qt5-qmake qttools5-dev qttools5-dev-tools yasm
|
150
|
151
|
|
151
|
152
|
if [ -d /repos/qtox ]; then
|
152
|
|
- mkdir ${rootdir}$INSTALL_DIR/qtox
|
153
|
|
- cp -r -p /repos/qtox/. ${rootdir}$INSTALL_DIR/qtox
|
154
|
|
- cd ${rootdir}$INSTALL_DIR/qtox
|
|
153
|
+ mkdir "${rootdir}$INSTALL_DIR/qtox"
|
|
154
|
+ cp -r -p /repos/qtox/. "${rootdir}$INSTALL_DIR/qtox"
|
|
155
|
+ cd "${rootdir}$INSTALL_DIR/qtox" || exit 264826826
|
155
|
156
|
git pull
|
156
|
157
|
else
|
157
|
|
- git clone $QTOX_REPO ${rootdir}$INSTALL_DIR/qtox
|
|
158
|
+ git clone "$QTOX_REPO" "${rootdir}$INSTALL_DIR/qtox"
|
158
|
159
|
fi
|
159
|
160
|
|
160
|
|
- if [ ! -d ${rootdir}$INSTALL_DIR/qtox ]; then
|
|
161
|
+ if [ ! -d "${rootdir}$INSTALL_DIR/qtox" ]; then
|
161
|
162
|
exit 72428
|
162
|
163
|
fi
|
163
|
|
- cd ${rootdir}${INSTALL_DIR}/qtox
|
|
164
|
+ cd "${rootdir}${INSTALL_DIR}/qtox" || exit 235745728
|
164
|
165
|
git checkout $QTOX_COMMIT -b $QTOX_COMMIT
|
165
|
|
- chroot ${rootdir} /bin/bash -x <<EOF
|
|
166
|
+ chroot "${rootdir}" /bin/bash -x <<EOF
|
166
|
167
|
cd ${INSTALL_DIR}/qtox
|
167
|
168
|
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig"
|
168
|
169
|
cmake .
|
169
|
170
|
make
|
170
|
171
|
make install
|
171
|
172
|
EOF
|
172
|
|
- if [ ! -f ${rootdir}/usr/local/bin/qtox ]; then
|
|
173
|
+ if [ ! -f "${rootdir}/usr/local/bin/qtox" ]; then
|
173
|
174
|
exit 75784
|
174
|
175
|
fi
|
175
|
|
- cp ${rootdir}/usr/local/bin/qtox ${rootdir}/usr/bin/qtox
|
|
176
|
+ cp "${rootdir}/usr/local/bin/qtox" "${rootdir}/usr/bin/qtox"
|
176
|
177
|
}
|
177
|
178
|
|
178
|
179
|
function reconfigure_tox {
|
|
@@ -181,9 +182,9 @@ function reconfigure_tox {
|
181
|
182
|
|
182
|
183
|
function upgrade_tox {
|
183
|
184
|
function_check set_repo_commit
|
184
|
|
- set_repo_commit $INSTALL_DIR/toxcore "toxcore commit" "$TOXCORE_COMMIT" $TOXCORE_REPO
|
185
|
|
- if [[ $(commit_has_changed $INSTALL_DIR/toxcore "toxcore commit" "$TOXCORE_COMMIT") == "1" ]]; then
|
186
|
|
- cd $INSTALL_DIR/toxcore
|
|
185
|
+ set_repo_commit "$INSTALL_DIR/toxcore" "toxcore commit" "$TOXCORE_COMMIT" $TOXCORE_REPO
|
|
186
|
+ if [[ $(commit_has_changed "$INSTALL_DIR/toxcore" "toxcore commit" "$TOXCORE_COMMIT") == "1" ]]; then
|
|
187
|
+ cd "$INSTALL_DIR/toxcore" || exit 53683563
|
187
|
188
|
sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
|
188
|
189
|
autoreconf -i
|
189
|
190
|
./configure --enable-daemon
|
|
@@ -194,9 +195,9 @@ function upgrade_tox {
|
194
|
195
|
fi
|
195
|
196
|
|
196
|
197
|
function_check set_repo_commit
|
197
|
|
- set_repo_commit $INSTALL_DIR/toxic "Toxic commit" "$TOXIC_COMMIT" $TOXIC_REPO
|
198
|
|
- if [[ $(commit_has_changed $INSTALL_DIR/toxic "Toxic commit" "$TOXIC_COMMIT") == "1" ]]; then
|
199
|
|
- cd $INSTALL_DIR/toxic
|
|
198
|
+ set_repo_commit "$INSTALL_DIR/toxic" "Toxic commit" "$TOXIC_COMMIT" $TOXIC_REPO
|
|
199
|
+ if [[ $(commit_has_changed "$INSTALL_DIR/toxic" "Toxic commit" "$TOXIC_COMMIT") == "1" ]]; then
|
|
200
|
+ cd "$INSTALL_DIR/toxic" || exit 4684618
|
200
|
201
|
make
|
201
|
202
|
make install
|
202
|
203
|
fi
|
|
@@ -221,12 +222,11 @@ function backup_local_tox {
|
221
|
222
|
}
|
222
|
223
|
|
223
|
224
|
function restore_local_tox {
|
224
|
|
- if [ -d $USB_MOUNT/backup/tox ]; then
|
|
225
|
+ if [ -d "$USB_MOUNT/backup/tox" ]; then
|
225
|
226
|
echo $"Restoring Tox node settings"
|
226
|
227
|
function_check restore_directory_from_usb
|
227
|
228
|
#restore_directory_from_usb / tox
|
228
|
|
- restore_directory_from_usb /var/lib/tox-bootstrapd tox
|
229
|
|
- if [ ! "$?" = "0" ]; then
|
|
229
|
+ if ! restore_directory_from_usb /var/lib/tox-bootstrapd tox; then
|
230
|
230
|
function_check set_user_permissions
|
231
|
231
|
set_user_permissions
|
232
|
232
|
function_check backup_unmount_drive
|
|
@@ -234,8 +234,7 @@ function restore_local_tox {
|
234
|
234
|
exit 6393
|
235
|
235
|
fi
|
236
|
236
|
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
237
|
|
- systemctl restart tox-bootstrapd.service
|
238
|
|
- if [ ! "$?" = "0" ]; then
|
|
237
|
+ if ! systemctl restart tox-bootstrapd.service; then
|
239
|
238
|
systemctl status tox-bootstrapd.service
|
240
|
239
|
function_check set_user_permissions
|
241
|
240
|
set_user_permissions
|
|
@@ -259,17 +258,15 @@ function backup_remote_tox {
|
259
|
258
|
}
|
260
|
259
|
|
261
|
260
|
function restore_remote_tox {
|
262
|
|
- if [ -d $SERVER_DIRECTORY/backup/tox ]; then
|
|
261
|
+ if [ -d "$SERVER_DIRECTORY/backup/tox" ]; then
|
263
|
262
|
echo $"Restoring Tox node settings"
|
264
|
263
|
function_check restore_directory_from_friend
|
265
|
264
|
#restore_directory_from_friend / tox
|
266
|
|
- restore_directory_from_friend /var/lib/tox-bootstrapd tox
|
267
|
|
- if [ ! "$?" = "0" ]; then
|
|
265
|
+ if ! restore_directory_from_friend /var/lib/tox-bootstrapd tox; then
|
268
|
266
|
exit 93653
|
269
|
267
|
fi
|
270
|
268
|
cp /var/lib/tox-bootstrapd/tox-bootstrapd.conf /etc/tox-bootstrapd.conf
|
271
|
|
- systemctl restart tox-bootstrapd.service
|
272
|
|
- if [ ! "$?" = "0" ]; then
|
|
269
|
+ if ! systemctl restart tox-bootstrapd.service; then
|
273
|
270
|
systemctl status tox-bootstrapd.service
|
274
|
271
|
exit 59369
|
275
|
272
|
fi
|
|
@@ -283,8 +280,7 @@ function remove_tox_node {
|
283
|
280
|
function_check remove_onion_service
|
284
|
281
|
remove_onion_service tox ${TOX_PORT}
|
285
|
282
|
|
286
|
|
- ${PROJECT_NAME}-mesh-install -f tox_node --remove yes
|
287
|
|
- if [ ! "$?" = "0" ]; then
|
|
283
|
+ if ! "${PROJECT_NAME}-mesh-install" -f tox_node --remove yes; then
|
288
|
284
|
echo $'Failed to remove tox node'
|
289
|
285
|
exit 763836
|
290
|
286
|
fi
|
|
@@ -293,21 +289,20 @@ function remove_tox_node {
|
293
|
289
|
}
|
294
|
290
|
|
295
|
291
|
function remove_tox_avahi {
|
296
|
|
- cd $INSTALL_DIR/toxid
|
|
292
|
+ cd "$INSTALL_DIR/toxid" || exit 82456275
|
297
|
293
|
make uninstall
|
298
|
|
- rm -rf $INSTALL_DIR/toxid
|
299
|
|
- sed -i '/tox_avahi/d' $COMPLETION_FILE
|
|
294
|
+ rm -rf "$INSTALL_DIR/toxid"
|
|
295
|
+ sed -i '/tox_avahi/d' "$COMPLETION_FILE"
|
300
|
296
|
}
|
301
|
297
|
|
302
|
298
|
function remove_tox_client {
|
303
|
|
- ${PROJECT_NAME}-mesh-install -f tox_client --remove yes
|
304
|
|
- if [ ! "$?" = "0" ]; then
|
|
299
|
+ if ! "${PROJECT_NAME}-mesh-install" -f tox_client --remove yes; then
|
305
|
300
|
echo $'Could not remove Tox client'
|
306
|
301
|
exit 737253
|
307
|
302
|
fi
|
308
|
|
- sed -i '/install_tox_client/d' $COMPLETION_FILE
|
309
|
|
- sed -i '/Tox /d' $COMPLETION_FILE
|
310
|
|
- sed -i '/Toxic /d' $COMPLETION_FILE
|
|
303
|
+ sed -i '/install_tox_client/d' "$COMPLETION_FILE"
|
|
304
|
+ sed -i '/Tox /d' "$COMPLETION_FILE"
|
|
305
|
+ sed -i '/Toxic /d' "$COMPLETION_FILE"
|
311
|
306
|
}
|
312
|
307
|
|
313
|
308
|
function remove_tox {
|
|
@@ -317,7 +312,7 @@ function remove_tox {
|
317
|
312
|
}
|
318
|
313
|
|
319
|
314
|
function configure_firewall_for_tox {
|
320
|
|
- if [ ! $INSTALLING_MESH ]; then
|
|
315
|
+ if [ ! "$INSTALLING_MESH" ]; then
|
321
|
316
|
if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
|
322
|
317
|
return
|
323
|
318
|
fi
|
|
@@ -331,16 +326,16 @@ function configure_firewall_for_tox {
|
331
|
326
|
return
|
332
|
327
|
fi
|
333
|
328
|
|
334
|
|
- TOX_PORT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
|
|
329
|
+ TOX_PORT_MAIN=$(grep "TOX_PORT=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '=' '{print $2}')
|
335
|
330
|
if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
|
336
|
331
|
TOX_PORT=$TOX_PORT_MAIN
|
337
|
332
|
fi
|
338
|
|
- if [ ! $TOX_PORT ]; then
|
|
333
|
+ if [ ! "$TOX_PORT" ]; then
|
339
|
334
|
echo $'No Tox port was specified'
|
340
|
335
|
exit 32856
|
341
|
336
|
fi
|
342
|
337
|
|
343
|
|
- firewall_add Tox ${TOX_PORT}
|
|
338
|
+ firewall_add Tox "${TOX_PORT}"
|
344
|
339
|
mark_completed "${FUNCNAME[0]}"
|
345
|
340
|
}
|
346
|
341
|
|
|
@@ -355,24 +350,23 @@ function tox_avahi {
|
355
|
350
|
fi
|
356
|
351
|
|
357
|
352
|
# install a command to obtain the Tox ID
|
358
|
|
- cd $INSTALL_DIR
|
|
353
|
+ cd "$INSTALL_DIR" || exit 131497953
|
359
|
354
|
|
360
|
355
|
if [ -d /repos/toxid ]; then
|
361
|
|
- mkdir $INSTALL_DIR/toxid
|
362
|
|
- cp -r -p /repos/toxid/. $INSTALL_DIR/toxid
|
363
|
|
- cd $INSTALL_DIR/toxid
|
|
356
|
+ mkdir "$INSTALL_DIR/toxid"
|
|
357
|
+ cp -r -p /repos/toxid/. "$INSTALL_DIR/toxid"
|
|
358
|
+ cd "$INSTALL_DIR/toxid" || exit 468276424526
|
364
|
359
|
git pull
|
365
|
360
|
else
|
366
|
361
|
function_check git_clone
|
367
|
|
- git_clone $TOXID_REPO $INSTALL_DIR/toxid
|
|
362
|
+ git_clone "$TOXID_REPO" "$INSTALL_DIR/toxid"
|
368
|
363
|
fi
|
369
|
364
|
|
370
|
|
- if [ ! -d $INSTALL_DIR/toxid ]; then
|
|
365
|
+ if [ ! -d "$INSTALL_DIR/toxid" ]; then
|
371
|
366
|
exit 63921
|
372
|
367
|
fi
|
373
|
|
- cd $INSTALL_DIR/toxid
|
374
|
|
- make
|
375
|
|
- if [ ! "$?" = "0" ]; then
|
|
368
|
+ cd "$INSTALL_DIR/toxid" || exit 4782462846
|
|
369
|
+ if ! make; then
|
376
|
370
|
exit 58432
|
377
|
371
|
fi
|
378
|
372
|
make install
|
|
@@ -399,13 +393,13 @@ function install_tox_node {
|
399
|
393
|
mesh_tox_node
|
400
|
394
|
|
401
|
395
|
# onion address for bootstrapping
|
402
|
|
- TOX_ONION_HOSTNAME=$(add_onion_service tox ${TOX_PORT} ${TOX_PORT})
|
|
396
|
+ add_onion_service tox "${TOX_PORT}" "${TOX_PORT}"
|
403
|
397
|
|
404
|
398
|
systemctl restart tox-bootstrapd.service
|
405
|
399
|
|
406
|
400
|
sleep 3
|
407
|
401
|
|
408
|
|
- TOX_PUBLIC_KEY=$(cat /var/log/syslog | grep tox | grep "Public Key" | tail -n 1 | awk -F ' ' '{print $8}')
|
|
402
|
+ TOX_PUBLIC_KEY=$(grep tox /var/log/syslog | grep "Public Key" | tail -n 1 | awk -F ' ' '{print $8}')
|
409
|
403
|
if [ ${#TOX_PUBLIC_KEY} -lt 30 ]; then
|
410
|
404
|
echo $'Could not obtain the tox node public key'
|
411
|
405
|
exit 6529
|
|
@@ -435,58 +429,58 @@ function install_tox_client {
|
435
|
429
|
|
436
|
430
|
function mesh_tox_node {
|
437
|
431
|
# obtain commits from the main file
|
438
|
|
- TOXCORE_COMMIT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
|
|
432
|
+ TOXCORE_COMMIT_MAIN=$(grep "TOXCORE_COMMIT=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F "'" '{print $2}')
|
439
|
433
|
if [ ${#TOXCORE_COMMIT_MAIN} -gt 10 ]; then
|
440
|
434
|
TOXCORE_COMMIT=$TOXCORE_COMMIT_MAIN
|
441
|
435
|
fi
|
442
|
|
- if [ ! $TOXCORE_COMMIT ]; then
|
|
436
|
+ if [ ! "$TOXCORE_COMMIT" ]; then
|
443
|
437
|
echo $'No Tox commit was specified'
|
444
|
438
|
exit 76325
|
445
|
439
|
fi
|
446
|
440
|
|
447
|
|
- TOXID_REPO_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}')
|
|
441
|
+ TOXID_REPO_MAIN=$(grep "TOXID_REPO=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '"' '{print $2}')
|
448
|
442
|
if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then
|
449
|
443
|
TOXID_REPO=$TOXID_REPO_MAIN
|
450
|
444
|
fi
|
451
|
|
- if [ ! $TOXID_REPO ]; then
|
|
445
|
+ if [ ! "$TOXID_REPO" ]; then
|
452
|
446
|
echo $'No ToxID repo was specified'
|
453
|
447
|
exit 78252
|
454
|
448
|
fi
|
455
|
449
|
|
456
|
|
- TOX_PORT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOX_PORT=" | head -n 1 | awk -F '=' '{print $2}')
|
|
450
|
+ TOX_PORT_MAIN=$(grep "TOX_PORT=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '=' '{print $2}')
|
457
|
451
|
if [ ${#TOX_PORT_MAIN} -gt 2 ]; then
|
458
|
452
|
TOX_PORT=$TOX_PORT_MAIN
|
459
|
453
|
fi
|
460
|
|
- if [ ! $TOX_PORT ]; then
|
|
454
|
+ if [ ! "$TOX_PORT" ]; then
|
461
|
455
|
echo $'No Tox port was specified'
|
462
|
456
|
exit 32856
|
463
|
457
|
fi
|
464
|
458
|
|
465
|
|
- TOXCORE_REPO_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}')
|
|
459
|
+ TOXCORE_REPO_MAIN=$(grep "TOXCORE_REPO=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '"' '{print $2}')
|
466
|
460
|
if [ ${#TOXCORE_REPO_MAIN} -gt 10 ]; then
|
467
|
461
|
TOXCORE_REPO=$TOXCORE_REPO_MAIN
|
468
|
462
|
fi
|
469
|
|
- if [ ! $TOXCORE_REPO ]; then
|
|
463
|
+ if [ ! "$TOXCORE_REPO" ]; then
|
470
|
464
|
echo $'No Tox repo was specified'
|
471
|
465
|
exit 16865
|
472
|
466
|
fi
|
473
|
467
|
|
474
|
|
- if [ ! $TOXCORE_COMMIT ]; then
|
|
468
|
+ if [ ! "$TOXCORE_COMMIT" ]; then
|
475
|
469
|
echo $'No Tox commit was specified'
|
476
|
470
|
exit 76325
|
477
|
471
|
fi
|
478
|
472
|
|
479
|
|
- if [ ! $TOXCORE_REPO ]; then
|
|
473
|
+ if [ ! "$TOXCORE_REPO" ]; then
|
480
|
474
|
echo $'No Tox repo was specified'
|
481
|
475
|
exit 16865
|
482
|
476
|
fi
|
483
|
477
|
|
484
|
|
- if [ $rootdir ]; then
|
485
|
|
- chroot ${rootdir} apt-get -yq install build-essential libtool autotools-dev
|
486
|
|
- chroot ${rootdir} apt-get -yq install automake checkinstall check git yasm
|
487
|
|
- chroot ${rootdir} apt-get -yq install libsodium18 libsodium-dev libcap2-bin
|
488
|
|
- chroot ${rootdir} apt-get -yq install libconfig9 libconfig-dev autoconf
|
489
|
|
- chroot ${rootdir} apt-get -yq install libopus-dev libvpx-dev
|
|
478
|
+ if [ "$rootdir" ]; then
|
|
479
|
+ chroot "${rootdir}" apt-get -yq install build-essential libtool autotools-dev
|
|
480
|
+ chroot "${rootdir}" apt-get -yq install automake checkinstall check git yasm
|
|
481
|
+ chroot "${rootdir}" apt-get -yq install libsodium18 libsodium-dev libcap2-bin
|
|
482
|
+ chroot "${rootdir}" apt-get -yq install libconfig9 libconfig-dev autoconf
|
|
483
|
+ chroot "${rootdir}" apt-get -yq install libopus-dev libvpx-dev
|
490
|
484
|
else
|
491
|
485
|
apt-get -yq install build-essential libtool autotools-dev
|
492
|
486
|
apt-get -yq install automake checkinstall check git yasm
|
|
@@ -495,27 +489,26 @@ function mesh_tox_node {
|
495
|
489
|
apt-get -yq install libopus-dev libvpx-dev
|
496
|
490
|
fi
|
497
|
491
|
|
498
|
|
- if [ ! -d ${rootdir}${INSTALL_DIR} ]; then
|
499
|
|
- mkdir -p ${rootdir}${INSTALL_DIR}
|
|
492
|
+ if [ ! -d "${rootdir}${INSTALL_DIR}" ]; then
|
|
493
|
+ mkdir -p "${rootdir}${INSTALL_DIR}"
|
500
|
494
|
fi
|
501
|
|
- if [ ! -d ${rootdir}${INSTALL_DIR}/toxcore ]; then
|
|
495
|
+ if [ ! -d "${rootdir}${INSTALL_DIR}/toxcore" ]; then
|
502
|
496
|
if [ -d /repos/toxcore ]; then
|
503
|
|
- mkdir ${rootdir}${INSTALL_DIR}/toxcore
|
504
|
|
- cp -r -p /repos/toxcore/. ${rootdir}${INSTALL_DIR}/toxcore
|
505
|
|
- cd ${rootdir}${INSTALL_DIR}/toxcore
|
|
497
|
+ mkdir "${rootdir}${INSTALL_DIR}/toxcore"
|
|
498
|
+ cp -r -p /repos/toxcore/. "${rootdir}${INSTALL_DIR}/toxcore"
|
|
499
|
+ cd "${rootdir}${INSTALL_DIR}/toxcore" || exit 2468246284
|
506
|
500
|
git pull
|
507
|
501
|
else
|
508
|
|
- git clone ${TOXCORE_REPO} ${rootdir}${INSTALL_DIR}/toxcore
|
509
|
|
- if [ ! "$?" = "0" ]; then
|
510
|
|
- exit 429252
|
|
502
|
+ if ! git clone "${TOXCORE_REPO}" "${rootdir}${INSTALL_DIR}/toxcore"; then
|
|
503
|
+ exit 4292521
|
511
|
504
|
fi
|
512
|
505
|
fi
|
513
|
506
|
fi
|
514
|
|
- cd ${rootdir}$INSTALL_DIR/toxcore
|
515
|
|
- git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
|
|
507
|
+ cd "${rootdir}$INSTALL_DIR/toxcore" || exit 46824624
|
|
508
|
+ git checkout "$TOXCORE_COMMIT" -b "$TOXCORE_COMMIT"
|
516
|
509
|
|
517
|
|
- if [ ${rootdir} ]; then
|
518
|
|
- chroot ${rootdir} /bin/bash -x <<EOF
|
|
510
|
+ if [ "${rootdir}" ]; then
|
|
511
|
+ chroot "${rootdir}" /bin/bash -x <<EOF
|
519
|
512
|
cd ${INSTALL_DIR}/toxcore
|
520
|
513
|
autoreconf -i
|
521
|
514
|
./configure --enable-daemon
|
|
@@ -532,28 +525,28 @@ make install
|
532
|
525
|
EOF
|
533
|
526
|
fi
|
534
|
527
|
|
535
|
|
- cp $rootdir/usr/local/lib/libtoxcore* $rootdir/usr/lib/
|
536
|
|
- cp ${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
|
537
|
|
- sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
|
538
|
|
- if [ ${rootdir} ]; then
|
539
|
|
- chroot ${rootdir} systemctl enable tox-bootstrapd.service
|
|
528
|
+ cp "$rootdir/usr/local/lib/libtoxcore*" "$rootdir/usr/lib/"
|
|
529
|
+ cp "${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service" "$rootdir/etc/systemd/system/"
|
|
530
|
+ sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' "$rootdir/etc/systemd/system/tox-bootstrapd.service"
|
|
531
|
+ if [ "${rootdir}" ]; then
|
|
532
|
+ chroot "${rootdir}" systemctl enable tox-bootstrapd.service
|
540
|
533
|
else
|
541
|
534
|
systemctl enable tox-bootstrapd.service
|
542
|
535
|
fi
|
543
|
536
|
|
544
|
537
|
SECONDS=0
|
545
|
|
- if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
|
|
538
|
+ if [ ! -f "$rootdir/usr/local/bin/tox-bootstrapd" ]; then
|
546
|
539
|
duration=$SECONDS
|
547
|
|
- echo $"Toxcore compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
540
|
+ echo $"Toxcore compile failed at $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."
|
548
|
541
|
echo $'Unable to make toxcore'
|
549
|
542
|
exit 73835
|
550
|
543
|
fi
|
551
|
544
|
duration=$SECONDS
|
552
|
|
- echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
545
|
+ echo $"Toxcore compile $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."
|
553
|
546
|
|
554
|
|
- if [ ${rootdir} ]; then
|
555
|
|
- chroot ${rootdir} /usr/sbin/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
|
556
|
|
- chroot ${rootdir} /bin/chmod 700 /var/lib/tox-bootstrapd
|
|
547
|
+ if [ "${rootdir}" ]; then
|
|
548
|
+ chroot "${rootdir}" /usr/sbin/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
|
|
549
|
+ chroot "${rootdir}" /bin/chmod 700 /var/lib/tox-bootstrapd
|
557
|
550
|
else
|
558
|
551
|
chmod 600 /etc/shadow
|
559
|
552
|
chmod 600 /etc/gshadow
|
|
@@ -564,87 +557,89 @@ EOF
|
564
|
557
|
fi
|
565
|
558
|
|
566
|
559
|
# remove Maildir
|
567
|
|
- if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
|
568
|
|
- rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
|
|
560
|
+ if [ -d "$rootdir/var/lib/tox-bootstrapd/Maildir" ]; then
|
|
561
|
+ rm -rf "$rootdir/var/lib/tox-bootstrapd/Maildir"
|
569
|
562
|
fi
|
570
|
563
|
|
571
|
564
|
# create configuration file
|
572
|
565
|
TOX_BOOTSTRAP_CONFIG=$rootdir/etc/tox-bootstrapd.conf
|
573
|
|
- echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
|
574
|
|
- echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $TOX_BOOTSTRAP_CONFIG
|
575
|
|
- echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
|
576
|
|
- echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
|
577
|
|
- echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
|
578
|
|
- echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
|
579
|
|
- echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
|
580
|
|
- echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
|
581
|
|
- echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
|
582
|
|
- echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
|
|
566
|
+ { echo "port = $TOX_PORT";
|
|
567
|
+ echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"';
|
|
568
|
+ echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"';
|
|
569
|
+ echo 'enable_ipv6 = true';
|
|
570
|
+ echo 'enable_ipv4_fallback = true';
|
|
571
|
+ echo 'enable_lan_discovery = true';
|
|
572
|
+ echo 'enable_tcp_relay = true';
|
|
573
|
+ echo "tcp_relay_ports = [443, 3389, $TOX_PORT]";
|
|
574
|
+ echo 'enable_motd = true';
|
|
575
|
+ echo 'motd = "tox-bootstrapd"'; } > "$TOX_BOOTSTRAP_CONFIG"
|
583
|
576
|
|
584
|
577
|
if [ $TOX_NODES ]; then
|
585
|
|
- echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
|
|
578
|
+ echo 'bootstrap_nodes = (' >> "$TOX_BOOTSTRAP_CONFIG"
|
586
|
579
|
toxcount=0
|
587
|
580
|
while [ "x${TOX_NODES[toxcount]}" != "x" ]
|
588
|
581
|
do
|
589
|
|
- toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
|
590
|
|
- toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
|
591
|
|
- toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
|
592
|
|
- toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
|
593
|
|
- toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
|
594
|
|
- echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
|
|
582
|
+ # shellcheck disable=SC2102
|
|
583
|
+ nodes_str=$(echo $TOX_NODES[toxcount])
|
|
584
|
+ toxval_ipv4=$(awk "$nodes_str" -F ',' '{print $1}')
|
|
585
|
+ toxval_ipv6=$(awk "$nodes_str" -F ',' '{print $2}')
|
|
586
|
+ toxval_port=$(awk "$nodes_str" -F ',' '{print $3}')
|
|
587
|
+ toxval_pubkey=$(awk "$nodes_str" -F ',' '{print $4}')
|
|
588
|
+ toxval_maintainer=$(awk "$nodes_str" -F ',' '{print $5}')
|
|
589
|
+ echo "{ // $toxval_maintainer" >> "$TOX_BOOTSTRAP_CONFIG"
|
595
|
590
|
if [[ $toxval_ipv6 != 'NONE' ]]; then
|
596
|
|
- echo " address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
|
|
591
|
+ echo " address = \"$toxval_ipv6\"" >> "$TOX_BOOTSTRAP_CONFIG"
|
597
|
592
|
else
|
598
|
|
- echo " address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
|
|
593
|
+ echo " address = \"$toxval_ipv4\"" >> "$TOX_BOOTSTRAP_CONFIG"
|
599
|
594
|
fi
|
600
|
|
- echo " port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
|
601
|
|
- echo " public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
|
602
|
|
- toxcount=$(( $toxcount + 1 ))
|
|
595
|
+ echo " port = $toxval_port" >> "$TOX_BOOTSTRAP_CONFIG"
|
|
596
|
+ echo " public_key = \"$toxval_pubkey\"" >> "$TOX_BOOTSTRAP_CONFIG"
|
|
597
|
+ toxcount=$((toxcount + 1))
|
603
|
598
|
if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
|
604
|
|
- echo "}," >> $TOX_BOOTSTRAP_CONFIG
|
|
599
|
+ echo "}," >> "$TOX_BOOTSTRAP_CONFIG"
|
605
|
600
|
else
|
606
|
|
- echo "}" >> $TOX_BOOTSTRAP_CONFIG
|
|
601
|
+ echo "}" >> "$TOX_BOOTSTRAP_CONFIG"
|
607
|
602
|
fi
|
608
|
603
|
done
|
609
|
|
- echo ')' >> $TOX_BOOTSTRAP_CONFIG
|
|
604
|
+ echo ')' >> "$TOX_BOOTSTRAP_CONFIG"
|
610
|
605
|
fi
|
611
|
606
|
|
612
|
|
- if [ -f $rootdir/var/lib/tox-bootstrapd/keys ]; then
|
613
|
|
- chmod 700 $rootdir/var/lib/tox-bootstrapd/keys
|
|
607
|
+ if [ -f "$rootdir/var/lib/tox-bootstrapd/keys" ]; then
|
|
608
|
+ chmod 700 "$rootdir/var/lib/tox-bootstrapd/keys"
|
614
|
609
|
fi
|
615
|
610
|
}
|
616
|
611
|
|
617
|
612
|
function mesh_tox_avahi {
|
618
|
|
- if [ ! -d $rootdir/etc/avahi ]; then
|
|
613
|
+ if [ ! -d "$rootdir/etc/avahi" ]; then
|
619
|
614
|
echo $'tox_avahi: avahi is not installed'
|
620
|
615
|
exit 87359
|
621
|
616
|
fi
|
622
|
617
|
|
623
|
|
- if [ ! $TOXID_REPO ]; then
|
|
618
|
+ if [ ! "$TOXID_REPO" ]; then
|
624
|
619
|
echo $'No ToxID repo was specified'
|
625
|
620
|
exit 78252
|
626
|
621
|
fi
|
627
|
622
|
|
628
|
|
- if [ ! -d ${rootdir}${INSTALL_DIR} ]; then
|
629
|
|
- mkdir -p ${rootdir}${INSTALL_DIR}
|
|
623
|
+ if [ ! -d "${rootdir}${INSTALL_DIR}" ]; then
|
|
624
|
+ mkdir -p "${rootdir}${INSTALL_DIR}"
|
630
|
625
|
fi
|
631
|
626
|
|
632
|
627
|
if [ -d /repos/toxid ]; then
|
633
|
|
- mkdir ${rootdir}${INSTALL_DIR}/toxid
|
634
|
|
- cp -r -p /repos/toxid/. ${rootdir}${INSTALL_DIR}/toxid
|
635
|
|
- cd ${rootdir}${INSTALL_DIR}/toxid
|
|
628
|
+ mkdir "${rootdir}${INSTALL_DIR}/toxid"
|
|
629
|
+ cp -r -p /repos/toxid/. "${rootdir}${INSTALL_DIR}/toxid"
|
|
630
|
+ cd "${rootdir}${INSTALL_DIR}/toxid" || exit 2468246
|
636
|
631
|
git pull
|
637
|
632
|
else
|
638
|
|
- git clone ${TOXID_REPO} ${rootdir}${INSTALL_DIR}/toxid
|
|
633
|
+ git clone "${TOXID_REPO}" "${rootdir}${INSTALL_DIR}/toxid"
|
639
|
634
|
fi
|
640
|
635
|
|
641
|
|
- if [ ! -d ${rootdir}${INSTALL_DIR}/toxid ]; then
|
|
636
|
+ if [ ! -d "${rootdir}${INSTALL_DIR}/toxid" ]; then
|
642
|
637
|
echo $'Unable to clone toxid repo'
|
643
|
638
|
exit 768352
|
644
|
639
|
fi
|
645
|
640
|
|
646
|
|
- if [ ${rootdir} ]; then
|
647
|
|
- chroot ${rootdir} /bin/bash -x <<EOF
|
|
641
|
+ if [ "${rootdir}" ]; then
|
|
642
|
+ chroot "${rootdir}" /bin/bash -x <<EOF
|
648
|
643
|
cd ${INSTALL_DIR}/toxid
|
649
|
644
|
make
|
650
|
645
|
make install
|
|
@@ -657,45 +652,46 @@ make install
|
657
|
652
|
EOF
|
658
|
653
|
fi
|
659
|
654
|
|
660
|
|
- if [ ! -f $rootdir/usr/local/bin/toxid ]; then
|
|
655
|
+ if [ ! -f "$rootdir/usr/local/bin/toxid" ]; then
|
661
|
656
|
echo $'toxid not found'
|
662
|
657
|
exit 74370
|
663
|
658
|
fi
|
664
|
|
- if [ ! -f $rootdir/usr/local/bin/toxavahi ]; then
|
|
659
|
+ if [ ! -f "$rootdir/usr/local/bin/toxavahi" ]; then
|
665
|
660
|
exit 3621729
|
666
|
661
|
fi
|
667
|
662
|
|
668
|
663
|
MESH_SYNC_COMMAND=$rootdir/usr/bin/mesh-sync
|
669
|
|
- echo '#!/bin/bash' > $MESH_SYNC_COMMAND
|
670
|
|
- echo '/usr/local/bin/toxavahi 2> /dev/null' >> $MESH_SYNC_COMMAND
|
671
|
|
- echo '/usr/local/bin/meshavahi 2> /dev/null' >> $MESH_SYNC_COMMAND
|
672
|
|
- chmod +x $MESH_SYNC_COMMAND
|
|
664
|
+ { echo '#!/bin/bash';
|
|
665
|
+ echo '/usr/local/bin/toxavahi 2> /dev/null';
|
|
666
|
+ echo '/usr/local/bin/meshavahi 2> /dev/null'; } > "$MESH_SYNC_COMMAND"
|
|
667
|
+ chmod +x "$MESH_SYNC_COMMAND"
|
673
|
668
|
|
674
|
|
- if ! grep -q "mesh-sync" ${rootdir}/etc/crontab; then
|
675
|
|
- echo "*/1 * * * * root /usr/bin/mesh-sync 2> /dev/null" >> ${rootdir}/etc/crontab
|
676
|
|
- echo "*/1 * * * * root ( sleep 20 ; /usr/bin/mesh-sync 2> /dev/null )" >> ${rootdir}/etc/cro echo "*/1 * * * * root ( sleep 40 ; /usr/bin/mesh-sync 2> /dev/null )" >> ${rootdir}/etc/crontab
|
|
669
|
+ if ! grep -q "mesh-sync" "${rootdir}/etc/crontab"; then
|
|
670
|
+ { echo "*/1 * * * * root /usr/bin/mesh-sync 2> /dev/null";
|
|
671
|
+ echo "*/1 * * * * root ( sleep 20 ; /usr/bin/mesh-sync 2> /dev/null )";
|
|
672
|
+ echo "*/1 * * * * root ( sleep 40 ; /usr/bin/mesh-sync 2> /dev/null )"; } >> "${rootdir}/etc/crontab"
|
677
|
673
|
fi
|
678
|
674
|
}
|
679
|
675
|
|
680
|
676
|
function mesh_tox_client {
|
681
|
677
|
|
682
|
|
- TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
|
|
678
|
+ TOXIC_FILE=$(grep "TOXIC_FILE=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '=' '{print $2}')
|
683
|
679
|
|
684
|
680
|
# obtain commits from the main file
|
685
|
|
- TOXIC_COMMIT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
|
|
681
|
+ TOXIC_COMMIT_MAIN=$(grep "TOXIC_COMMIT=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F "'" '{print $2}')
|
686
|
682
|
if [ ${#TOXIC_COMMIT_MAIN} -gt 10 ]; then
|
687
|
683
|
TOXIC_COMMIT=$TOXIC_COMMIT_MAIN
|
688
|
684
|
fi
|
689
|
685
|
|
690
|
|
- TOXIC_REPO_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_REPO=" | head -n 1 | awk -F '"' '{print $2}')
|
|
686
|
+ TOXIC_REPO_MAIN=$(grep "TOXIC_REPO=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '"' '{print $2}')
|
691
|
687
|
if [ ${#TOXIC_REPO_MAIN} -gt 5 ]; then
|
692
|
688
|
TOXIC_REPO=$TOXIC_REPO_MAIN
|
693
|
689
|
fi
|
694
|
690
|
|
695
|
|
- if [ ${rootdir} ]; then
|
696
|
|
- chroot ${rootdir} apt-get -yq install libncursesw5-dev libconfig-dev libqrencode-dev
|
697
|
|
- chroot ${rootdir} apt-get -yq install libcurl4-openssl-dev libvpx-dev libopenal-dev
|
698
|
|
- chroot ${rootdir} apt-get -yq install libqrencode-dev
|
|
691
|
+ if [ "${rootdir}" ]; then
|
|
692
|
+ chroot "${rootdir}" apt-get -yq install libncursesw5-dev libconfig-dev libqrencode-dev
|
|
693
|
+ chroot "${rootdir}" apt-get -yq install libcurl4-openssl-dev libvpx-dev libopenal-dev
|
|
694
|
+ chroot "${rootdir}" apt-get -yq install libqrencode-dev
|
699
|
695
|
else
|
700
|
696
|
apt-get -yq install libncursesw5-dev libconfig-dev libqrencode-dev
|
701
|
697
|
apt-get -yq install libcurl4-openssl-dev libvpx-dev libopenal-dev
|
|
@@ -704,57 +700,57 @@ function mesh_tox_client {
|
704
|
700
|
|
705
|
701
|
TEMP_SCRIPT_NAME=fbtmp728353.sh
|
706
|
702
|
TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
|
707
|
|
- echo '#!/bin/bash' > $TEMP_SCRIPT
|
708
|
|
- echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
|
709
|
|
- echo 'if [ -d /repos/toxic ]; then' >> $TEMP_SCRIPT
|
710
|
|
- echo " mkdir $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
711
|
|
- echo " cp -r -p /repos/toxic/. $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
712
|
|
- echo " cd $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
713
|
|
- echo ' git pull' >> $TEMP_SCRIPT
|
714
|
|
- echo 'else' >> $TEMP_SCRIPT
|
715
|
|
- echo " git clone $TOXIC_REPO $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
716
|
|
- echo 'fi' >> $TEMP_SCRIPT
|
717
|
|
- echo "cd $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
|
718
|
|
- echo "git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT" >> $TEMP_SCRIPT
|
719
|
|
- echo 'make' >> $TEMP_SCRIPT
|
720
|
|
- echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
|
721
|
|
- echo ' exit 1' >> $TEMP_SCRIPT
|
722
|
|
- echo 'fi' >> $TEMP_SCRIPT
|
723
|
|
- echo 'make install' >> $TEMP_SCRIPT
|
724
|
|
- echo 'exit 0' >> $TEMP_SCRIPT
|
|
703
|
+ { echo '#!/bin/bash';
|
|
704
|
+ echo "mkdir -p $INSTALL_DIR";
|
|
705
|
+ echo 'if [ -d /repos/toxic ]; then';
|
|
706
|
+ echo " mkdir $INSTALL_DIR/toxic";
|
|
707
|
+ echo " cp -r -p /repos/toxic/. $INSTALL_DIR/toxic";
|
|
708
|
+ echo " cd $INSTALL_DIR/toxic";
|
|
709
|
+ echo ' git pull';
|
|
710
|
+ echo 'else';
|
|
711
|
+ echo " git clone $TOXIC_REPO $INSTALL_DIR/toxic";
|
|
712
|
+ echo 'fi';
|
|
713
|
+ echo "cd $INSTALL_DIR/toxic";
|
|
714
|
+ echo "git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT";
|
|
715
|
+ echo 'make';
|
|
716
|
+ echo 'if [ ! "$?" = "0" ]; then';
|
|
717
|
+ echo ' exit 1';
|
|
718
|
+ echo 'fi';
|
|
719
|
+ echo 'make install';
|
|
720
|
+ echo 'exit 0'; } > "$TEMP_SCRIPT"
|
725
|
721
|
chmod +x $TEMP_SCRIPT
|
726
|
|
- cp $TEMP_SCRIPT $rootdir/root/
|
|
722
|
+ cp "$TEMP_SCRIPT" "$rootdir/root/"
|
727
|
723
|
|
728
|
|
- TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
|
|
724
|
+ TOXIC_FILE=$(grep "TOXIC_FILE=" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox" | head -n 1 | awk -F '=' '{print $2}')
|
729
|
725
|
|
730
|
726
|
SECONDS=0
|
731
|
|
- if [ ${rootdir} ]; then
|
732
|
|
- chroot ${rootdir} /root/$TEMP_SCRIPT_NAME
|
|
727
|
+ if [ "${rootdir}" ]; then
|
|
728
|
+ chroot "${rootdir}" "/root/$TEMP_SCRIPT_NAME"
|
733
|
729
|
else
|
734
|
730
|
/root/$TEMP_SCRIPT_NAME
|
735
|
731
|
fi
|
|
732
|
+ # shellcheck disable=SC2181
|
736
|
733
|
if [ ! "$?" = "0" ]; then
|
737
|
734
|
cat -n /root/fbtmp728353.sh
|
738
|
735
|
duration=$SECONDS
|
739
|
|
- echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
736
|
+ echo $"Toxic client compile failed at $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."
|
740
|
737
|
echo $'Unable to make tox client'
|
741
|
738
|
rm $TEMP_SCRIPT
|
742
|
739
|
exit 74872
|
743
|
740
|
fi
|
744
|
741
|
rm $TEMP_SCRIPT
|
745
|
|
- if [ ! -f $rootdir$TOXIC_FILE ]; then
|
|
742
|
+ if [ ! -f "$rootdir$TOXIC_FILE" ]; then
|
746
|
743
|
echo $"Tox client was not installed to $TOXIC_FILE"
|
747
|
744
|
exit 63278
|
748
|
745
|
fi
|
749
|
746
|
duration=$SECONDS
|
750
|
|
- echo $"Toxic client compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
|
|
747
|
+ echo $"Toxic client compile $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."
|
751
|
748
|
}
|
752
|
749
|
|
753
|
750
|
function enable_tox_repo {
|
754
|
|
- echo 'deb http://download.opensuse.org/repositories/home:/antonbatenev:/tox/Debian_9.0/ /' > $rootdir/etc/apt/sources.list.d/tox.list
|
755
|
|
-
|
|
751
|
+ echo 'deb http://download.opensuse.org/repositories/home:/antonbatenev:/tox/Debian_9.0/ /' > "$rootdir/etc/apt/sources.list.d/tox.list"
|
756
|
752
|
|
757
|
|
- cat >> $rootdir/root/gettoxkey.sh <<EOF
|
|
753
|
+ cat >> "$rootdir/root/gettoxkey.sh" <<EOF
|
758
|
754
|
#!/bin/bash
|
759
|
755
|
wget -q http://download.opensuse.org/repositories/home:antonbatenev:tox/Debian_9.0/Release.key -O- > /root/tox.key
|
760
|
756
|
apt-key add /root/tox.key
|
|
@@ -769,30 +765,30 @@ EOF
|
769
|
765
|
function install_tox {
|
770
|
766
|
configure_firewall_for_tox
|
771
|
767
|
|
772
|
|
- if [ $INSTALLING_MESH ]; then
|
|
768
|
+ if [ "$INSTALLING_MESH" ]; then
|
773
|
769
|
mesh_tox_node
|
774
|
770
|
mesh_tox_avahi
|
775
|
771
|
mesh_tox_client
|
776
|
772
|
else
|
777
|
773
|
avoid_tor_restart=
|
778
|
|
- if [ -f $IMAGE_PASSWORD_FILE ]; then
|
|
774
|
+ if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
779
|
775
|
if [[ $ONION_ONLY != 'no' ]]; then
|
780
|
776
|
avoid_tor_restart=1
|
781
|
777
|
fi
|
782
|
778
|
fi
|
783
|
779
|
|
784
|
780
|
if [ $avoid_tor_restart ]; then
|
785
|
|
- ${PROJECT_NAME}-logging on --onion
|
|
781
|
+ "${PROJECT_NAME}-logging" on --onion
|
786
|
782
|
else
|
787
|
|
- ${PROJECT_NAME}-logging on
|
|
783
|
+ "${PROJECT_NAME}-logging" on
|
788
|
784
|
fi
|
789
|
785
|
|
790
|
786
|
install_tox_node
|
791
|
787
|
|
792
|
788
|
if [ $avoid_tor_restart ]; then
|
793
|
|
- ${PROJECT_NAME}-logging off --onion
|
|
789
|
+ "${PROJECT_NAME}-logging" off --onion
|
794
|
790
|
else
|
795
|
|
- ${PROJECT_NAME}-logging off
|
|
791
|
+ "${PROJECT_NAME}-logging" off
|
796
|
792
|
fi
|
797
|
793
|
|
798
|
794
|
tox_avahi
|