Browse Source

Function to remove tox node

Bob Mottram 8 years ago
parent
commit
137821b926
2 changed files with 41 additions and 1 deletions
  1. 20
    0
      src/freedombone-app-tox
  2. 21
    1
      src/freedombone-mesh-install

+ 20
- 0
src/freedombone-app-tox View File

@@ -44,6 +44,26 @@ TOXIC_REPO="https://github.com/Tox/toxic"
44 44
 TOXIC_COMMIT='cf16849b374e484a33a4dffa3dfb937b59d537f2'
45 45
 TOXIC_FILE=/usr/local/bin/toxic
46 46
 
47
+function remove_tox_node {
48
+	if ! grep -Fxq "install_tox_node" $COMPLETION_FILE; then
49
+		return
50
+	fi
51
+
52
+	iptables -D INPUT -p tcp --dport $TOX_PORT -j ACCEPT
53
+	function_check save_firewall_settings
54
+	save_firewall_settings
55
+
56
+	function_check remove_onion_service
57
+	remove_onion_service tox ${TOX_PORT}
58
+
59
+	${PROJECT_NAME}-mesh-install -f tox_node --remove yes
60
+	if [ ! "$?" = "0" ]; then
61
+		echo $'Failed to remove tox node'
62
+		exit 763836
63
+	fi
64
+	sed -i '/install_tox_node/d' $COMPLETION_FILE
65
+}
66
+
47 67
 function configure_firewall_for_tox {
48 68
 	if grep -Fxq "configure_firewall_for_tox" $COMPLETION_FILE; then
49 69
 		return

+ 21
- 1
src/freedombone-mesh-install View File

@@ -432,6 +432,22 @@ function mesh_firewall {
432 432
 	$CHROOT_PREFIX systemctl enable meshfirewall
433 433
 }
434 434
 
435
+function mesh_tox_node_remove {
436
+	systemctl stop tox-bootstrapd
437
+	systemctl disable tox-bootstrapd
438
+	if [ -f /etc/systemd/system/tox-bootstrapd.service ]; then
439
+		rm /etc/systemd/system/tox-bootstrapd.service
440
+	fi
441
+	if [ -d $INSTALL_DIR/toxcore ]; then
442
+		cd $INSTALL_DIR/toxcore
443
+		make uninstall
444
+		rm -rf $INSTALL_DIR/toxcore
445
+	fi
446
+	if [ -f /etc/tox-bootstrapd.conf ]; then
447
+		rm /etc/tox-bootstrapd.conf
448
+	fi
449
+}
450
+
435 451
 function mesh_tox_node {
436 452
 	# obtain commits from the main file
437 453
 	if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
@@ -1083,7 +1099,11 @@ if [[ $FN == 'batman_client' ]]; then
1083 1099
 	mesh_batman_client
1084 1100
 fi
1085 1101
 if [[ $FN == 'tox_node' ]]; then
1086
-	mesh_tox_node
1102
+	if [[ $REMOVE != 'yes' ]]; then
1103
+		mesh_tox_node
1104
+	else
1105
+		mesh_tox_node_remove
1106
+	fi
1087 1107
 fi
1088 1108
 if [[ $FN == 'tox_client' ]]; then
1089 1109
 	mesh_tox_client