Ver código fonte

Script to install toxcore

Bob Mottram 9 anos atrás
pai
commit
7a1637daeb
2 arquivos alterados com 134 adições e 18 exclusões
  1. 131
    15
      src/freedombone-image-customise
  2. 3
    3
      src/freedombone-image-mesh

+ 131
- 15
src/freedombone-image-customise Ver arquivo

@@ -627,22 +627,95 @@ function mesh_tox_node {
627 627
 	chroot "$rootdir" apt-get -y install libsodium13 libsodium-dev libcap2-bin
628 628
 	chroot "$rootdir" apt-get -y install libconfig9 libconfig-dev
629 629
 
630
-	if [ ! -d $rootdir$INSTALL_DIR ]; then
631
-		mkdir -p $rootdir$INSTALL_DIR
630
+
631
+	TEMP_SCRIPT=/tmp/fbtmp37272.sh
632
+	echo '#!/bin/bash' > $TEMP_SCRIPT
633
+	echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
634
+	echo "git clone $TOXCORE_REPO $INSTALL_DIR/toxcore" >> $TEMP_SCRIPT
635
+	echo "cd $INSTALL_DIR" >> $TEMP_SCRIPT
636
+	echo "git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT" >> $TEMP_SCRIPT
637
+	echo 'autoreconf -i' >> $TEMP_SCRIPT
638
+	echo './configure --enable-daemon --disable-av' >> $TEMP_SCRIPT
639
+	echo 'make' >> $TEMP_SCRIPT
640
+	echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
641
+	echo '    exit 1' >> $TEMP_SCRIPT
642
+	echo 'fi' >> $TEMP_SCRIPT
643
+	echo 'make install' >> $TEMP_SCRIPT
644
+	echo 'exit 0' >> $TEMP_SCRIPT
645
+	chmod +x $TEMP_SCRIPT
646
+	cp $TEMP_SCRIPT $rootdir/root/
647
+
648
+	SECONDS=0
649
+	chroot "$rootdir" $TEMP_SCRIPT
650
+	if [ ! "$?" = "0" ]; then
651
+		duration=$SECONDS
652
+		echo $"Toxcore compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
653
+		echo $'Unable to make toxcore'
654
+		exit 73835
655
+	fi
656
+	duration=$SECONDS
657
+	echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
658
+	chroot "$rootdir" cp /usr/local/lib/libtoxcore* /usr/lib/
659
+
660
+	if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
661
+		echo $"File not found /usr/local/bin/tox-bootstrapd"
662
+		exit 37825
632 663
 	fi
633
-	git clone $TOXCORE_REPO $rootdir$INSTALL_DIR/toxcore
634
-	if [ ! -d $rootdir$INSTALL_DIR/toxcore ]; then
635
-		echo $'Unable to clone toxcore'
636
-		exit 543335
664
+
665
+	chroot "$rootdir" 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
666
+	chroot "$rootdir" chmod 700 /var/lib/tox-bootstrapd
667
+
668
+	# remove Maildir
669
+	if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
670
+		rm -rf $rootdir/var/lib/tox-bootstrapd/Maildir
637 671
 	fi
638
-	cd $rootdir$INSTALL_DIR/toxcore
639
-	git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
640 672
 
641
-	if ! grep -q "Toxcore commit" $rootdir$COMPLETION_FILE; then
642
-		echo "Toxcore commit:$TOXCORE_COMMIT" >> $rootdir$COMPLETION_FILE
643
-	else
644
-		sed -i "s|Toxcore commit.*|Toxcore commit:$TOXCORE_COMMIT|g" $rootdir$COMPLETION_FILE
673
+	# create configuration file
674
+	TOX_BOOTSTRAP_CONFIG=$rootdir/etc/tox-bootstrapd.conf
675
+	echo "port = $TOX_PORT" > $TOX_BOOTSTRAP_CONFIG
676
+	echo 'keys_file_path = "/var/lib/tox-bootstrapd/keys"' >> $TOX_BOOTSTRAP_CONFIG
677
+	echo 'pid_file_path = "/var/run/tox-bootstrapd/tox-bootstrapd.pid"' >> $TOX_BOOTSTRAP_CONFIG
678
+	echo 'enable_ipv6 = true' >> $TOX_BOOTSTRAP_CONFIG
679
+	echo 'enable_ipv4_fallback = true' >> $TOX_BOOTSTRAP_CONFIG
680
+	echo 'enable_lan_discovery = true' >> $TOX_BOOTSTRAP_CONFIG
681
+	echo 'enable_tcp_relay = true' >> $TOX_BOOTSTRAP_CONFIG
682
+	echo "tcp_relay_ports = [443, 3389, $TOX_PORT]" >> $TOX_BOOTSTRAP_CONFIG
683
+	echo 'enable_motd = true' >> $TOX_BOOTSTRAP_CONFIG
684
+	echo 'motd = "tox-bootstrapd"' >> $TOX_BOOTSTRAP_CONFIG
685
+
686
+	if [ $TOX_NODES ]; then
687
+		echo 'bootstrap_nodes = (' >> $TOX_BOOTSTRAP_CONFIG
688
+		toxcount=0
689
+		while [ "x${TOX_NODES[toxcount]}" != "x" ]
690
+		do
691
+			toxval_ipv4=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $1}')
692
+			toxval_ipv6=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $2}')
693
+			toxval_port=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $3}')
694
+			toxval_pubkey=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $4}')
695
+			toxval_maintainer=$(echo $TOX_NODES[toxcount] | awk -F ',' '{print $5}')
696
+			echo "{ // $toxval_maintainer" >> $TOX_BOOTSTRAP_CONFIG
697
+			if [[ $toxval_ipv6 != 'NONE' ]]; then
698
+				echo "  address = \"$toxval_ipv6\"" >> $TOX_BOOTSTRAP_CONFIG
699
+			else
700
+				echo "  address = \"$toxval_ipv4\"" >> $TOX_BOOTSTRAP_CONFIG
701
+			fi
702
+			echo "  port = $toxval_port" >> $TOX_BOOTSTRAP_CONFIG
703
+			echo "  public_key = \"$toxval_pubkey\"" >> $TOX_BOOTSTRAP_CONFIG
704
+			toxcount=$(( $toxcount + 1 ))
705
+			if [ "x${TOX_NODES[toxcount]}" != "x" ]; then
706
+				echo "}," >> $TOX_BOOTSTRAP_CONFIG
707
+			else
708
+				echo "}" >> $TOX_BOOTSTRAP_CONFIG
709
+			fi
710
+		done
711
+		echo ')' >> $TOX_BOOTSTRAP_CONFIG
645 712
 	fi
713
+
714
+	chroot "$rootdir" cp $INSTALL_DIR/other/bootstrap_daemon/tox-bootstrapd.service /etc/systemd/system/
715
+	chroot "$rootdir" sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' /etc/systemd/system/tox-bootstrapd.service
716
+
717
+	chroot "$rootdir" systemctl daemon-reload
718
+	chroot "$rootdir" systemctl enable tox-bootstrapd.service
646 719
 }
647 720
 
648 721
 function mesh_tox_avahi {
@@ -663,12 +736,28 @@ function mesh_tox_avahi {
663 736
 		echo $'No ToxID repo was specified'
664 737
 		exit 78252
665 738
 	fi
666
-	
739
+
667 740
 	# install a command to obtain the Tox ID
668
-	chroot "$rootdir" git clone $TOXID_REPO $INSTALL_DIR/toxid
741
+	git clone $TOXID_REPO $rootdir$INSTALL_DIR/toxid
742
+
669 743
 	if [ ! -d $rootdir$INSTALL_DIR/toxid ]; then
670
-		exit 63921
744
+		echo $'toxid repo not found'
745
+		exit 52682
671 746
 	fi
747
+	cd $rootdir$INSTALL_DIR/toxid
748
+	chroot "$rootdir" make
749
+	if [ ! "$?" = "0" ]; then
750
+		echo $'Failed to compile toxid'
751
+		exit 58432
752
+	fi
753
+	chroot "$rootdir" make install
754
+
755
+	chroot "$rootdir" toxavahi
756
+
757
+	# publish regularly
758
+	echo "* *     * * *   root    toxavahi > /dev/null" >> $rootdir/etc/crontab
759
+
760
+	chroot "$rootdir" systemctl restart avahi-daemon
672 761
 }
673 762
 
674 763
 function mesh_tox_client {
@@ -712,6 +801,33 @@ function mesh_tox_client {
712 801
 	else
713 802
 		sed -i "s|Toxic commit.*|Toxic commit:$TOXIC_COMMIT|g" $rootdir$COMPLETION_FILE
714 803
 	fi
804
+
805
+	if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
806
+		TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
807
+	else
808
+		TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
809
+	fi
810
+
811
+	if [ ! -d $rootdir$INSTALL_DIR/toxic ]; then
812
+		echo $"$INSTALL_DIR/toxic not found"
813
+		exit 347835
814
+	fi
815
+
816
+	SECONDS=0
817
+	chroot "$rootdir" make
818
+	if [ ! -f $rootdir$INSTALL_DIR/toxic/build/toxic ]; then
819
+		duration=$SECONDS
820
+		echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
821
+		echo $'Unable to make tox client'
822
+		exit 74872
823
+	fi
824
+	chroot "$rootdir" make install
825
+	if [ ! -f $rootdir$TOXIC_FILE ]; then
826
+		echo $"Tox client was not installed to $TOXIC_FILE"
827
+		exit 63278
828
+	fi
829
+	duration=$SECONDS
830
+	echo $"Toxic client compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
715 831
 }
716 832
 
717 833
 function mesh_zeronet {

+ 3
- 3
src/freedombone-image-mesh Ver arquivo

@@ -506,9 +506,9 @@ if [ -f /root/.initial_mesh_setup ]; then
506 506
 	configure_zeronet_blog
507 507
 	configure_zeronet_mail
508 508
 	configure_zeronet_forum
509
-	compile_toxcore
510
-	compile_toxid
511
-	compile_tox_client
509
+	#compile_toxcore
510
+	#compile_toxid
511
+	#compile_tox_client
512 512
 	configure_toxcore
513 513
 	configure_zeronet
514 514