Browse Source

Fix broken chroot

Bob Mottram 8 years ago
parent
commit
d138819154
1 changed files with 55 additions and 19 deletions
  1. 55
    19
      src/freedombone-app-tox

+ 55
- 19
src/freedombone-app-tox View File

369
 		exit 16865
369
 		exit 16865
370
 	fi
370
 	fi
371
 
371
 
372
-	mesh_tox_node_prefix=''
373
 	if [ $rootdir ]; then
372
 	if [ $rootdir ]; then
374
-		mesh_tox_node_prefix="chroot \"$rootdir\""
373
+		chroot ${rootdir} apt-get -y install build-essential libtool autotools-dev
374
+		chroot ${rootdir} apt-get -y install automake checkinstall check git yasm
375
+		chroot ${rootdir} apt-get -y install libsodium13 libsodium-dev libcap2-bin
376
+		chroot ${rootdir} apt-get -y install libconfig9 libconfig-dev autoconf
377
+		chroot ${rootdir} apt-get -y install libopus-dev libvpx-dev
378
+	else
379
+		apt-get -y install build-essential libtool autotools-dev
380
+		apt-get -y install automake checkinstall check git yasm
381
+		apt-get -y install libsodium13 libsodium-dev libcap2-bin
382
+		apt-get -y install libconfig9 libconfig-dev autoconf
383
+		apt-get -y install libopus-dev libvpx-dev
375
 	fi
384
 	fi
376
-	$mesh_tox_node_prefix apt-get -y install build-essential libtool autotools-dev
377
-	$mesh_tox_node_prefix apt-get -y install automake checkinstall check git yasm
378
-	$mesh_tox_node_prefix apt-get -y install libsodium13 libsodium-dev libcap2-bin
379
-	$mesh_tox_node_prefix apt-get -y install libconfig9 libconfig-dev autoconf
380
-	$mesh_tox_node_prefix apt-get -y install libopus-dev libvpx-dev
381
 
385
 
382
 	if [ ! -d ${rootdir}${INSTALL_DIR} ]; then
386
 	if [ ! -d ${rootdir}${INSTALL_DIR} ]; then
383
 		mkdir -p ${rootdir}${INSTALL_DIR}
387
 		mkdir -p ${rootdir}${INSTALL_DIR}
389
 	cd ${rootdir}$INSTALL_DIR/toxcore
393
 	cd ${rootdir}$INSTALL_DIR/toxcore
390
 	git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
394
 	git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT
391
 
395
 
392
-	$mesh_tox_node_prefix /bin/bash -x <<EOF
396
+	if [ ${rootdir} ]; then
397
+		chroot ${rootdir} /bin/bash -x <<EOF
393
 cd ${INSTALL_DIR}/toxcore
398
 cd ${INSTALL_DIR}/toxcore
394
 autoreconf -i
399
 autoreconf -i
395
 ./configure --enable-daemon
400
 ./configure --enable-daemon
396
 make
401
 make
397
 make install
402
 make install
398
 EOF
403
 EOF
404
+	else
405
+		/bin/bash -x <<EOF
406
+cd ${INSTALL_DIR}/toxcore
407
+autoreconf -i
408
+./configure --enable-daemon
409
+make
410
+make install
411
+EOF
412
+	fi
399
 
413
 
400
 	cp $rootdir/usr/local/lib/libtoxcore* $rootdir/usr/lib/
414
 	cp $rootdir/usr/local/lib/libtoxcore* $rootdir/usr/lib/
401
 	cp ${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
415
 	cp ${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
402
 	sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
416
 	sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service
403
-	$mesh_tox_node_prefix systemctl enable tox-bootstrapd.service
417
+	if [ ${rootdir} ]; then
418
+		chroot ${rootdir} systemctl enable tox-bootstrapd.service
419
+	else
420
+		systemctl enable tox-bootstrapd.service
421
+	fi
404
 
422
 
405
 	SECONDS=0
423
 	SECONDS=0
406
 	if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
424
 	if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
412
 	duration=$SECONDS
430
 	duration=$SECONDS
413
 	echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
431
 	echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
414
 
432
 
415
-	$mesh_tox_node_prefix 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
416
-	$mesh_tox_node_prefix chmod 700 /var/lib/tox-bootstrapd
433
+	if [ ${rootdir} ]; then
434
+		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
435
+		chroot ${rootdir} chmod 700 /var/lib/tox-bootstrapd
436
+	else
437
+		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
438
+		chmod 700 /var/lib/tox-bootstrapd
439
+	fi
417
 
440
 
418
 	# remove Maildir
441
 	# remove Maildir
419
 	if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
442
 	if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
488
 		exit 768352
511
 		exit 768352
489
 	fi
512
 	fi
490
 
513
 
491
-	$mesh_tox_avahi_prefix /bin/bash -x <<EOF
514
+	if [ ${rootdir} ]; then
515
+		chroot ${rootdir} /bin/bash -x <<EOF
492
 cd ${INSTALL_DIR}/toxid
516
 cd ${INSTALL_DIR}/toxid
493
 make
517
 make
494
 make install
518
 make install
495
 EOF
519
 EOF
520
+	else
521
+		/bin/bash -x <<EOF
522
+cd ${INSTALL_DIR}/toxid
523
+make
524
+make install
525
+EOF
526
+	fi
496
 
527
 
497
 	if [ ! -f $rootdir/usr/local/bin/toxid ]; then
528
 	if [ ! -f $rootdir/usr/local/bin/toxid ]; then
498
 		echo $'toxid not found'
529
 		echo $'toxid not found'
505
 }
536
 }
506
 
537
 
507
 function mesh_tox_client {
538
 function mesh_tox_client {
508
-	mesh_tox_client_prefix=''
509
-	if [ $rootdir ]; then
510
-		mesh_tox_client_prefix="chroot \"$rootdir\""
511
-	fi
512
 
539
 
513
 	TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
540
 	TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
514
 
541
 
523
 		TOXIC_REPO=$TOXIC_REPO_MAIN
550
 		TOXIC_REPO=$TOXIC_REPO_MAIN
524
 	fi
551
 	fi
525
 
552
 
526
-	$mesh_tox_client_prefix apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
527
-	$mesh_tox_client_prefix apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
553
+	if [ ${rootdir} ]; then
554
+		chroot ${rootdir} apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
555
+		chroot ${rootdir} apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
556
+	else
557
+		apt-get -y install libncursesw5-dev libconfig-dev libqrencode-dev
558
+		apt-get -y install libcurl4-openssl-dev libvpx-dev libopenal-dev
559
+	fi
528
 
560
 
529
 	TEMP_SCRIPT_NAME=fbtmp728353.sh
561
 	TEMP_SCRIPT_NAME=fbtmp728353.sh
530
 	TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
562
 	TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
545
 	TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
577
 	TOXIC_FILE=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
546
 
578
 
547
 	SECONDS=0
579
 	SECONDS=0
548
-	$mesh_tox_client_prefix /root/$TEMP_SCRIPT_NAME
580
+	if [ ${rootdir} ]; then
581
+		chroot ${rootdir} /root/$TEMP_SCRIPT_NAME
582
+	else
583
+		/root/$TEMP_SCRIPT_NAME
584
+	fi
549
 	if [ ! "$?" = "0" ]; then
585
 	if [ ! "$?" = "0" ]; then
550
 		duration=$SECONDS
586
 		duration=$SECONDS
551
 		echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."
587
 		echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."