Sfoglia il codice sorgente

More consolidation of mesh functions

Bob Mottram 8 anni fa
parent
commit
423fdcad5e
No account linked to committer's email

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

246
 }
246
 }
247
 
247
 
248
 function install_tox_node {
248
 function install_tox_node {
249
-	if [ $INSTALLING_MESH ]; then
250
-		mesh_tox_node
251
-		return
252
-	fi
253
-
254
 	if grep -Fxq "install_tox_node" $COMPLETION_FILE; then
249
 	if grep -Fxq "install_tox_node" $COMPLETION_FILE; then
255
 		return
250
 		return
256
 	fi
251
 	fi
321
 	echo 'install_tox_client' >> $COMPLETION_FILE
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
 function mesh_tox_node {
319
 function mesh_tox_node {
336
 	# obtain commits from the main file
320
 	# obtain commits from the main file
337
 	TOXCORE_COMMIT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}')
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
 	echo "Tox Repository Installed."
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
 # NOTE: deliberately no exit 0
574
 # NOTE: deliberately no exit 0

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

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

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

94
 	chmod +x $rootdir/usr/bin/$WATCHDOG_SCRIPT_NAME
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
 		return
103
 		return
100
 	fi
104
 	fi
101
 	# only enable avahi if we're doing mesh networking
105
 	# only enable avahi if we're doing mesh networking
119
 		sed -i "s|host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
123
 		sed -i "s|host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
120
 	fi
124
 	fi
121
 
125
 
122
-	echo 'configure_avahi' >> $COMPLETION_FILE
126
+	echo 'install_avahi' >> $COMPLETION_FILE
123
 }
127
 }
124
 
128
 
125
 # NOTE: deliberately there is no "exit 0"
129
 # NOTE: deliberately there is no "exit 0"

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

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

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

290
 	create_upgrade_script
290
 	create_upgrade_script
291
 	letsencrypt_renewals
291
 	letsencrypt_renewals
292
 	install_watchdog_script
292
 	install_watchdog_script
293
-	configure_avahi
293
+	install_avahi
294
 	create_avahi_onion_domains
294
 	create_avahi_onion_domains
295
 	#install_atheros_wifi
295
 	#install_atheros_wifi
296
 	route_outgoing_traffic_through_tor
296
 	route_outgoing_traffic_through_tor

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

392
 	echo 'install_dynamicdns' >> $COMPLETION_FILE
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
 function install_web_server {
427
 function install_web_server {
428
+	if [ $INSTALLING_MESH ]; then
429
+		mesh_web_server
430
+		return
431
+	fi
396
 	if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then
432
 	if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then
397
 		return
433
 		return
398
 	fi
434
 	fi
530
 	echo 'install_web_server' >> $COMPLETION_FILE
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
 # NOTE: deliberately no exit 0
569
 # NOTE: deliberately no exit 0