From 137821b926f04dc19c5592bfaba0af83a9712074 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 4 Jul 2016 13:32:23 +0100 Subject: [PATCH] Function to remove tox node --- src/freedombone-app-tox | 20 ++++++++++++++++++++ src/freedombone-mesh-install | 22 +++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/freedombone-app-tox b/src/freedombone-app-tox index d8c3f14e..51e7f309 100755 --- a/src/freedombone-app-tox +++ b/src/freedombone-app-tox @@ -44,6 +44,26 @@ TOXIC_REPO="https://github.com/Tox/toxic" TOXIC_COMMIT='cf16849b374e484a33a4dffa3dfb937b59d537f2' TOXIC_FILE=/usr/local/bin/toxic +function remove_tox_node { + if ! grep -Fxq "install_tox_node" $COMPLETION_FILE; then + return + fi + + iptables -D INPUT -p tcp --dport $TOX_PORT -j ACCEPT + function_check save_firewall_settings + save_firewall_settings + + function_check remove_onion_service + remove_onion_service tox ${TOX_PORT} + + ${PROJECT_NAME}-mesh-install -f tox_node --remove yes + if [ ! "$?" = "0" ]; then + echo $'Failed to remove tox node' + exit 763836 + fi + sed -i '/install_tox_node/d' $COMPLETION_FILE +} + function configure_firewall_for_tox { if grep -Fxq "configure_firewall_for_tox" $COMPLETION_FILE; then return diff --git a/src/freedombone-mesh-install b/src/freedombone-mesh-install index 5372caa3..0c0f6c0f 100755 --- a/src/freedombone-mesh-install +++ b/src/freedombone-mesh-install @@ -432,6 +432,22 @@ function mesh_firewall { $CHROOT_PREFIX systemctl enable meshfirewall } +function mesh_tox_node_remove { + systemctl stop tox-bootstrapd + systemctl disable tox-bootstrapd + if [ -f /etc/systemd/system/tox-bootstrapd.service ]; then + rm /etc/systemd/system/tox-bootstrapd.service + fi + if [ -d $INSTALL_DIR/toxcore ]; then + cd $INSTALL_DIR/toxcore + make uninstall + rm -rf $INSTALL_DIR/toxcore + fi + if [ -f /etc/tox-bootstrapd.conf ]; then + rm /etc/tox-bootstrapd.conf + fi +} + function mesh_tox_node { # obtain commits from the main file if [ -f /usr/local/bin/${PROJECT_NAME} ]; then @@ -1083,7 +1099,11 @@ if [[ $FN == 'batman_client' ]]; then mesh_batman_client fi if [[ $FN == 'tox_node' ]]; then - mesh_tox_node + if [[ $REMOVE != 'yes' ]]; then + mesh_tox_node + else + mesh_tox_node_remove + fi fi if [[ $FN == 'tox_client' ]]; then mesh_tox_client