Browse Source

More consolidation of mesh functions

Bob Mottram 8 years ago
parent
commit
423fdcad5e
No account linked to committer's email

+ 20
- 16
src/freedombone-app-tox View File

@@ -246,11 +246,6 @@ function tox_avahi {
246 246
 }
247 247
 
248 248
 function install_tox_node {
249
-	if [ $INSTALLING_MESH ]; then
250
-		mesh_tox_node
251
-		return
252
-	fi
253
-
254 249
 	if grep -Fxq "install_tox_node" $COMPLETION_FILE; then
255 250
 		return
256 251
 	fi
@@ -321,17 +316,6 @@ function install_tox_client {
321 316
 	echo 'install_tox_client' >> $COMPLETION_FILE
322 317
 }
323 318
 
324
-function install_tox {
325
-	if grep -Fxq "install_tox" $COMPLETION_FILE; then
326
-		return
327
-	fi
328
-	configure_firewall_for_tox
329
-	install_tox_node
330
-	tox_avahi
331
-	install_tox_client
332
-	echo 'install_tox' >> $COMPLETION_FILE
333
-}
334
-
335 319
 function mesh_tox_node {
336 320
 	# obtain commits from the main file
337 321
 	TOXCORE_COMMIT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
@@ -567,4 +551,24 @@ function enable_tox_repo {
567 551
 	echo "Tox Repository Installed."
568 552
 }
569 553
 
554
+function install_tox {
555
+	if grep -Fxq "install_tox" $COMPLETION_FILE; then
556
+		return
557
+	fi
558
+
559
+	configure_firewall_for_tox
560
+
561
+	if [ $INSTALLING_MESH ]; then
562
+		mesh_tox_node
563
+		mesh_tox_avahi
564
+		mesh_tox_client
565
+	else
566
+		install_tox_node
567
+		tox_avahi
568
+		install_tox_client
569
+	fi
570
+
571
+	echo 'install_tox' >> $COMPLETION_FILE
572
+}
573
+
570 574
 # NOTE: deliberately no exit 0

+ 3
- 5
src/freedombone-image-customise View File

@@ -520,13 +520,11 @@ initialise_mesh() {
520 520
 
521 521
 	INSTALLING_MESH=1
522 522
 
523
-	mesh_firewall
524
-	mesh_avahi
523
+	configure_firewall
524
+	install_avahi
525 525
 	install_batman
526 526
 	install_tox_node
527
-	mesh_tox_avahi
528
-	mesh_tox_client
529
-	mesh_web_server
527
+	install_web_server
530 528
 	install_zeronet
531 529
 
532 530
 	MESH_SERVICE='mesh-setup.service'

+ 7
- 3
src/freedombone-utils-avahi View File

@@ -94,8 +94,12 @@ function mesh_avahi {
94 94
 	chmod +x $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
95 95
 }
96 96
 
97
-function configure_avahi {
98
-	if grep -Fxq "configure_avahi" $COMPLETION_FILE; then
97
+function install_avahi {
98
+	if [ $INSTALLING_MESH ]; then
99
+		mesh_avahi
100
+		return
101
+	fi
102
+	if grep -Fxq "install_avahi" $COMPLETION_FILE; then
99 103
 		return
100 104
 	fi
101 105
 	# only enable avahi if we're doing mesh networking
@@ -119,7 +123,7 @@ function configure_avahi {
119 123
 		sed -i "s|host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
120 124
 	fi
121 125
 
122
-	echo 'configure_avahi' >> $COMPLETION_FILE
126
+	echo 'install_avahi' >> $COMPLETION_FILE
123 127
 }
124 128
 
125 129
 # NOTE: deliberately there is no "exit 0"

+ 4
- 0
src/freedombone-utils-firewall View File

@@ -47,6 +47,10 @@ function enable_ipv6 {
47 47
 }
48 48
 
49 49
 function configure_firewall {
50
+	if [ $INSTALLING_MESH ]; then
51
+		mesh_firewall
52
+		return
53
+	fi
50 54
     if grep -q "RELATED" /etc/firewall.conf; then
51 55
         # recreate the firewall to remove RELATED
52 56
         sed -i "/firewall/d" $COMPLETION_FILE

+ 1
- 1
src/freedombone-utils-setup View File

@@ -290,7 +290,7 @@ function setup_utils {
290 290
 	create_upgrade_script
291 291
 	letsencrypt_renewals
292 292
 	install_watchdog_script
293
-	configure_avahi
293
+	install_avahi
294 294
 	create_avahi_onion_domains
295 295
 	#install_atheros_wifi
296 296
 	route_outgoing_traffic_through_tor

+ 36
- 32
src/freedombone-utils-web View File

@@ -392,7 +392,43 @@ function install_dynamicdns {
392 392
 	echo 'install_dynamicdns' >> $COMPLETION_FILE
393 393
 }
394 394
 
395
+function install_command_line_browser {
396
+	if grep -Fxq "install_command_line_browser" $COMPLETION_FILE; then
397
+		return
398
+	fi
399
+	apt-get -y install elinks
400
+
401
+	# set the home page
402
+	if ! grep -q "WWW_HOME" /home/$MY_USERNAME/.bashrc; then
403
+		if ! grep -q 'control' /home/$MY_USERNAME/.bashrc; then
404
+			echo "export WWW_HOME=$DEFAULT_SEARCH" >> /home/$MY_USERNAME/.bashrc
405
+		else
406
+			sed -i "/control/i export WWW_HOME=$DEFAULT_SEARCH" /home/$MY_USERNAME/.bashrc
407
+		fi
408
+	fi
409
+
410
+	echo 'install_command_line_browser' >> $COMPLETION_FILE
411
+}
412
+
413
+function mesh_web_server {
414
+	if [ -d /etc/apache2 ]; then
415
+		chroot "$rootdir" apt-get -y remove --purge apache2
416
+		chroot "$rootdir" rm -rf /etc/apache2
417
+	fi
418
+
419
+	chroot "$rootdir" apt-get -y install nginx
420
+
421
+	if [ ! -d $rootdir/etc/nginx ]; then
422
+		echo $'Unable to install web server'
423
+		exit 346825
424
+	fi
425
+}
426
+
395 427
 function install_web_server {
428
+	if [ $INSTALLING_MESH ]; then
429
+		mesh_web_server
430
+		return
431
+	fi
396 432
 	if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then
397 433
 		return
398 434
 	fi
@@ -530,36 +566,4 @@ function install_web_server {
530 566
 	echo 'install_web_server' >> $COMPLETION_FILE
531 567
 }
532 568
 
533
-function install_command_line_browser {
534
-	if grep -Fxq "install_command_line_browser" $COMPLETION_FILE; then
535
-		return
536
-	fi
537
-	apt-get -y install elinks
538
-
539
-	# set the home page
540
-	if ! grep -q "WWW_HOME" /home/$MY_USERNAME/.bashrc; then
541
-		if ! grep -q 'control' /home/$MY_USERNAME/.bashrc; then
542
-			echo "export WWW_HOME=$DEFAULT_SEARCH" >> /home/$MY_USERNAME/.bashrc
543
-		else
544
-			sed -i "/control/i export WWW_HOME=$DEFAULT_SEARCH" /home/$MY_USERNAME/.bashrc
545
-		fi
546
-	fi
547
-
548
-	echo 'install_command_line_browser' >> $COMPLETION_FILE
549
-}
550
-
551
-function mesh_web_server {
552
-	if [ -d /etc/apache2 ]; then
553
-		chroot "$rootdir" apt-get -y remove --purge apache2
554
-		chroot "$rootdir" rm -rf /etc/apache2
555
-	fi
556
-
557
-	chroot "$rootdir" apt-get -y install nginx
558
-
559
-	if [ ! -d $rootdir/etc/nginx ]; then
560
-		echo $'Unable to install web server'
561
-		exit 346825
562
-	fi
563
-}
564
-
565 569
 # NOTE: deliberately no exit 0