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,15 +369,19 @@ function mesh_tox_node {
369 369
 		exit 16865
370 370
 	fi
371 371
 
372
-	mesh_tox_node_prefix=''
373 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 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 386
 	if [ ! -d ${rootdir}${INSTALL_DIR} ]; then
383 387
 		mkdir -p ${rootdir}${INSTALL_DIR}
@@ -389,18 +393,32 @@ function mesh_tox_node {
389 393
 	cd ${rootdir}$INSTALL_DIR/toxcore
390 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 398
 cd ${INSTALL_DIR}/toxcore
394 399
 autoreconf -i
395 400
 ./configure --enable-daemon
396 401
 make
397 402
 make install
398 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 414
 	cp $rootdir/usr/local/lib/libtoxcore* $rootdir/usr/lib/
401 415
 	cp ${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/
402 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 423
 	SECONDS=0
406 424
 	if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then
@@ -412,8 +430,13 @@ EOF
412 430
 	duration=$SECONDS
413 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 441
 	# remove Maildir
419 442
 	if [ -d $rootdir/var/lib/tox-bootstrapd/Maildir ]; then
@@ -488,11 +511,19 @@ function mesh_tox_avahi {
488 511
 		exit 768352
489 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 516
 cd ${INSTALL_DIR}/toxid
493 517
 make
494 518
 make install
495 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 528
 	if [ ! -f $rootdir/usr/local/bin/toxid ]; then
498 529
 		echo $'toxid not found'
@@ -505,10 +536,6 @@ EOF
505 536
 }
506 537
 
507 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 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,8 +550,13 @@ function mesh_tox_client {
523 550
 		TOXIC_REPO=$TOXIC_REPO_MAIN
524 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 561
 	TEMP_SCRIPT_NAME=fbtmp728353.sh
530 562
 	TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME
@@ -545,7 +577,11 @@ function mesh_tox_client {
545 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 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 585
 	if [ ! "$?" = "0" ]; then
550 586
 		duration=$SECONDS
551 587
 		echo $"Toxic client compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed."