Преглед на файлове

Scriptifying more things

Bob Mottram преди 8 години
родител
ревизия
8da1ff40a3
променени са 1 файла, в които са добавени 46 реда и са изтрити 37 реда
  1. 46
    37
      src/freedombone-image-customise

+ 46
- 37
src/freedombone-image-customise Целия файл

@@ -642,6 +642,7 @@ function mesh_tox_node {
642 642
 	echo '    exit 1' >> $TEMP_SCRIPT
643 643
 	echo 'fi' >> $TEMP_SCRIPT
644 644
 	echo 'make install' >> $TEMP_SCRIPT
645
+	echo 'cp /usr/local/lib/libtoxcore* /usr/lib/' >> $TEMP_SCRIPT
645 646
 	echo 'exit 0' >> $TEMP_SCRIPT
646 647
 	chmod +x $TEMP_SCRIPT
647 648
 	cp $TEMP_SCRIPT $rootdir/root/
@@ -652,11 +653,12 @@ function mesh_tox_node {
652 653
 		duration=$SECONDS
653 654
 		echo $"Toxcore compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
654 655
 		echo $'Unable to make toxcore'
656
+		rm $TEMP_SCRIPT
655 657
 		exit 73835
656 658
 	fi
657 659
 	duration=$SECONDS
658 660
 	echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
659
-	chroot "$rootdir" cp /usr/local/lib/libtoxcore* /usr/lib/
661
+	rm $TEMP_SCRIPT
660 662
 
661 663
 	if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
662 664
 		echo $"File not found /usr/local/bin/tox-bootstrapd"
@@ -738,25 +740,33 @@ function mesh_tox_avahi {
738 740
 		exit 78252
739 741
 	fi
740 742
 
741
-	# install a command to obtain the Tox ID
742
-	git clone $TOXID_REPO $rootdir$INSTALL_DIR/toxid
743
+	TEMP_SCRIPT_NAME=fbtmp5328252.sh
744
+	TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
745
+	echo '#!/bin/bash' > $TEMP_SCRIPT
746
+	echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
747
+	echo "git clone $TOXID_REPO $INSTALL_DIR/toxid" >> $TEMP_SCRIPT
748
+	echo "if [ ! -d $INSTALL_DIR/toxid ]; then" >> $TEMP_SCRIPT
749
+	echo '    exit 1' >> $TEMP_SCRIPT
750
+	echo 'fi' >> $TEMP_SCRIPT
751
+	echo "cd $INSTALL_DIR/toxid" >> $TEMP_SCRIPT
752
+	echo "make" >> $TEMP_SCRIPT
753
+	echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
754
+	echo '    exit 2' >> $TEMP_SCRIPT
755
+	echo 'fi' >> $TEMP_SCRIPT
756
+	echo 'make install' >> $TEMP_SCRIPT
757
+	echo 'toxavahi' >> $TEMP_SCRIPT
758
+	echo 'echo "* *     * * *   root    toxavahi > /dev/null" >> /etc/crontab' >> $TEMP_SCRIPT
759
+	echo 'exit 0' >> $TEMP_SCRIPT
760
+	chmod +x $TEMP_SCRIPT
761
+	cp $TEMP_SCRIPT $rootdir/root/
743 762
 
744
-	if [ ! -d $rootdir$INSTALL_DIR/toxid ]; then
745
-		echo $'toxid repo not found'
746
-		exit 52682
747
-	fi
748
-	cd $rootdir$INSTALL_DIR/toxid
749
-	chroot "$rootdir" make
763
+	chroot "$rootdir" /root/$TEMP_SCRIPT_NAME
750 764
 	if [ ! "$?" = "0" ]; then
751
-		echo $'Failed to compile toxid'
752
-		exit 58432
765
+		echo $'Unable to install toxid'
766
+		rm $TEMP_SCRIPT
767
+		exit 62835
753 768
 	fi
754
-	chroot "$rootdir" make install
755
-
756
-	chroot "$rootdir" toxavahi
757
-
758
-	# publish regularly
759
-	echo "* *     * * *   root    toxavahi > /dev/null" >> $rootdir/etc/crontab
769
+	rm $TEMP_SCRIPT
760 770
 
761 771
 	chroot "$rootdir" systemctl restart avahi-daemon
762 772
 }
@@ -790,18 +800,21 @@ function mesh_tox_client {
790 800
 	chroot "$rootdir" apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
791 801
 	chroot "$rootdir" apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
792 802
 
793
-	if [ ! -d $rootdir$INSTALL_DIR ]; then
794
-		mkdir -p $rootdir$INSTALL_DIR
795
-	fi
796
-	git clone $TOXIC_REPO $rootdir$INSTALL_DIR/toxic
797
-	cd $rootdir$INSTALL_DIR/toxic
798
-	git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT
799
-
800
-	if ! grep -q "Toxic commit" $rootdir$COMPLETION_FILE; then
801
-		echo "Toxic commit:$TOXIC_COMMIT" >> $rootdir$COMPLETION_FILE
802
-	else
803
-		sed -i "s|Toxic commit.*|Toxic commit:$TOXIC_COMMIT|g" $rootdir$COMPLETION_FILE
804
-	fi
803
+	TEMP_SCRIPT_NAME=fbtmp728353.sh
804
+	TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
805
+	echo '#!/bin/bash' > $TEMP_SCRIPT
806
+	echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT
807
+	echo "git clone $TOXIC_REPO $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
808
+	echo "cd $INSTALL_DIR/toxic" >> $TEMP_SCRIPT
809
+	echo "git checkout $TOXIC_COMMIT -b $TOXIC_COMMIT" >> $TEMP_SCRIPT
810
+	echo 'make' >> $TEMP_SCRIPT
811
+	echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT
812
+	echo '    exit 1' >> $TEMP_SCRIPT
813
+	echo 'fi' >> $TEMP_SCRIPT
814
+	echo 'make install' >> $TEMP_SCRIPT
815
+	echo 'exit 0' >> $TEMP_SCRIPT
816
+	chmod +x $TEMP_SCRIPT
817
+	cp $TEMP_SCRIPT $rootdir/root/
805 818
 
806 819
 	if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
807 820
 		TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
@@ -809,20 +822,16 @@ function mesh_tox_client {
809 822
 		TOXIC_FILE=$(cat /usr/bin/${PROJECT_NAME} | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
810 823
 	fi
811 824
 
812
-	if [ ! -d $rootdir$INSTALL_DIR/toxic ]; then
813
-		echo $"$INSTALL_DIR/toxic not found"
814
-		exit 347835
815
-	fi
816
-
817 825
 	SECONDS=0
818
-	chroot "$rootdir" make
819
-	if [ ! -f $rootdir$INSTALL_DIR/toxic/build/toxic ]; then
826
+	chroot "$rootdir" /root/$TEMP_SCRIPT_NAME
827
+	if [ ! "$?" = "0" ]; then
820 828
 		duration=$SECONDS
821 829
 		echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
822 830
 		echo $'Unable to make tox client'
831
+		rm $TEMP_SCRIPT
823 832
 		exit 74872
824 833
 	fi
825
-	chroot "$rootdir" make install
834
+	rm $TEMP_SCRIPT
826 835
 	if [ ! -f $rootdir$TOXIC_FILE ]; then
827 836
 		echo $"Tox client was not installed to $TOXIC_FILE"
828 837
 		exit 63278