From 72a47da79a5faa6688e6e2a350f2fba134b6069f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 17 Jul 2016 16:31:38 +0100 Subject: [PATCH] toxcore on mesh --- src/freedombone-app-tox | 106 ++++++++++---------------------- src/freedombone-image-customise | 4 -- 2 files changed, 34 insertions(+), 76 deletions(-) diff --git a/src/freedombone-app-tox b/src/freedombone-app-tox index 51ececad..a9af68e7 100755 --- a/src/freedombone-app-tox +++ b/src/freedombone-app-tox @@ -331,20 +331,11 @@ function install_tox_client { } function mesh_tox_node { - # obtain commits from the main file - TOXCORE_COMMIT_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXCORE_COMMIT=" | head -n 1 | awk -F "'" '{print $2}') - if [ ${#TOXCORE_COMMIT_MAIN} -gt 10 ]; then - TOXCORE_COMMIT=$TOXCORE_COMMIT_MAIN - fi if [ ! $TOXCORE_COMMIT ]; then echo $'No Tox commit was specified' exit 76325 fi - TOXCORE_REPO_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXCORE_REPO=" | head -n 1 | awk -F '"' '{print $2}') - if [ ${#TOXCORE_REPO_MAIN} -gt 10 ]; then - TOXCORE_REPO=$TOXCORE_REPO_MAIN - fi if [ ! $TOXCORE_REPO ]; then echo $'No Tox repo was specified' exit 16865 @@ -355,46 +346,33 @@ function mesh_tox_node { chroot "$rootdir" apt-get -y install libsodium13 libsodium-dev libcap2-bin chroot "$rootdir" apt-get -y install libconfig9 libconfig-dev - TEMP_SCRIPT_NAME=fbtmp37272.sh TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME - echo '#!/bin/bash' > $TEMP_SCRIPT - echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT - echo "git clone $TOXCORE_REPO $INSTALL_DIR/toxcore" >> $TEMP_SCRIPT - echo "cd $INSTALL_DIR/toxcore" >> $TEMP_SCRIPT - echo "git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT" >> $TEMP_SCRIPT - echo 'autoreconf -i' >> $TEMP_SCRIPT - echo './configure --enable-daemon --disable-av' >> $TEMP_SCRIPT - echo 'make' >> $TEMP_SCRIPT - echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT - echo ' exit 1' >> $TEMP_SCRIPT - echo 'fi' >> $TEMP_SCRIPT - echo 'make install' >> $TEMP_SCRIPT - echo 'cp /usr/local/lib/libtoxcore* /usr/lib/' >> $TEMP_SCRIPT - echo "cp $INSTALL_DIR/toxcore/other/bootstrap_daemon/tox-bootstrapd.service /etc/systemd/system/" >> $TEMP_SCRIPT - echo "sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' /etc/systemd/system/tox-bootstrapd.service" >> $TEMP_SCRIPT - echo 'systemctl enable tox-bootstrapd.service' >> $TEMP_SCRIPT - echo 'exit 0' >> $TEMP_SCRIPT - chmod +x $TEMP_SCRIPT - cp $TEMP_SCRIPT $rootdir/root/ + + mkdir -p ${rootdir}${INSTALL_DIR} + git clone ${TOXCORE_REPO} ${rootdir}${INSTALL_DIR}/toxcore + chroot "$rootdir" cd $INSTALL_DIR/toxcore && git checkout $TOXCORE_COMMIT -b $TOXCORE_COMMIT + chroot "$rootdir" cd $INSTALL_DIR/toxcore && autoreconf -i + chroot "$rootdir" cd $INSTALL_DIR/toxcore && ./configure --enable-daemon --disable-av + chroot "$rootdir" cd $INSTALL_DIR/toxcore && make + if [ ! "$?" = "0" ]; then + exit 429285 + fi + chroot "$rootdir" cd $INSTALL_DIR/toxcore && make install + cp $rootdir/usr/local/lib/libtoxcore* $rootdir/usr/lib/ + cp ${rootdir}${INSTALL_DIR}/toxcore/other/bootstrap_daemon/tox-bootstrapd.service $rootdir/etc/systemd/system/ + sed -i 's|ExecStart=.*|ExecStart=/usr/local/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf|g' $rootdir/etc/systemd/system/tox-bootstrapd.service + chroot "$rootdir" systemctl enable tox-bootstrapd.service SECONDS=0 - chroot "$rootdir" /root/$TEMP_SCRIPT_NAME - if [ ! "$?" = "0" ]; then + if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then duration=$SECONDS echo $"Toxcore compile failed at $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed." echo $'Unable to make toxcore' - rm $TEMP_SCRIPT exit 73835 fi duration=$SECONDS echo $"Toxcore compile $(($duration / 60)) minutes and $(($duration % 60)) seconds elapsed." - rm $TEMP_SCRIPT - - if [ ! -f $rootdir/usr/local/bin/tox-bootstrapd ]; then - echo $"File not found /usr/local/bin/tox-bootstrapd" - exit 37825 - fi 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 chroot "$rootdir" chmod 700 /var/lib/tox-bootstrapd @@ -452,46 +430,30 @@ function mesh_tox_avahi { exit 87359 fi - TOXID_REPO_MAIN=$(cat /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-tox | grep "TOXID_REPO=" | head -n 1 | awk -F '"' '{print $2}') - if [ ${#TOXID_REPO_MAIN} -gt 5 ]; then - TOXID_REPO=$TOXID_REPO_MAIN - fi if [ ! $TOXID_REPO ]; then echo $'No ToxID repo was specified' exit 78252 fi - TEMP_SCRIPT_NAME=fbtmp5328252.sh - TEMP_SCRIPT=/tmp/$TEMP_SCRIPT_NAME - echo '#!/bin/bash' > $TEMP_SCRIPT - echo "mkdir -p $INSTALL_DIR" >> $TEMP_SCRIPT - echo "git clone $TOXID_REPO $INSTALL_DIR/toxid" >> $TEMP_SCRIPT - echo "if [ ! -d $INSTALL_DIR/toxid ]; then" >> $TEMP_SCRIPT - echo ' exit 1' >> $TEMP_SCRIPT - echo 'fi' >> $TEMP_SCRIPT - echo "cd $INSTALL_DIR/toxid" >> $TEMP_SCRIPT - echo "make" >> $TEMP_SCRIPT - echo 'if [ ! "$?" = "0" ]; then' >> $TEMP_SCRIPT - echo ' exit 2' >> $TEMP_SCRIPT - echo 'fi' >> $TEMP_SCRIPT - echo 'make install' >> $TEMP_SCRIPT - echo 'if [ ! -f /usr/local/bin/toxavahi ]; then' >> $TEMP_SCRIPT - echo ' exit 3' >> $TEMP_SCRIPT - echo 'fi' >> $TEMP_SCRIPT - echo 'toxavahi' >> $TEMP_SCRIPT - echo 'echo "* * * * * root /usr/local/bin/toxavahi > /dev/null" >> /etc/crontab' >> $TEMP_SCRIPT - echo 'systemctl restart avahi-daemon' >> $TEMP_SCRIPT - echo 'exit 0' >> $TEMP_SCRIPT - chmod +x $TEMP_SCRIPT - cp $TEMP_SCRIPT $rootdir/root/ - - chroot "$rootdir" /root/$TEMP_SCRIPT_NAME - if [ ! "$?" = "0" ]; then - echo $"Unable to install toxid, returned $?" - rm $TEMP_SCRIPT - exit 62835 + if [ ! -d ${rootdir}${INSTALL_DIR} ]; then + mkdir -p ${rootdir}${INSTALL_DIR} fi - rm $TEMP_SCRIPT + + git clone ${TOXID_REPO} ${rootdir}${INSTALL_DIR}/toxid + if [ ! -d ${rootdir}${INSTALL_DIR}/toxid ]; then + echo $'Unable to clone toxid repo' + exit 768352 + fi + chroot "$rootdir" cd $INSTALL_DIR/toxid && make + if [ ! "$?" = "0" ]; then + echo $'Unable to make toxid' + exit 386823 + fi + chroot "$rootdir" cd $INSTALL_DIR/toxid && make install + if [ ! -f $rootdir/usr/local/bin/toxavahi ]; then + exit 3621729 + fi + echo "* * * * * root /usr/local/bin/toxavahi > /dev/null" >> $rootdir/etc/crontab } function mesh_tox_client { diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 7b0b1571..b0396b1f 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -680,10 +680,6 @@ function configure_user_interface { # IRC client chroot "$rootdir" apt-get -y install hexchat profanity - - # zeronet - - # TODO fi }