Browse Source

Function to remove tox

Bob Mottram 8 years ago
parent
commit
3f7be9c1d6
2 changed files with 48 additions and 1 deletions
  1. 34
    0
      src/freedombone-app-tox
  2. 14
    1
      src/freedombone-mesh-install

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

@@ -62,6 +62,40 @@ function remove_tox_node {
62 62
 		exit 763836
63 63
 	fi
64 64
 	sed -i '/install_tox_node/d' $COMPLETION_FILE
65
+	sed -i '/configure_firewall_for_tox/d' $COMPLETION_FILE
66
+}
67
+
68
+function remove_tox_avahi {
69
+	if ! grep -Fxq "tox_avahi" $COMPLETION_FILE; then
70
+		return
71
+	fi
72
+	cd $INSTALL_DIR/toxid
73
+	make uninstall
74
+	rm -rf $INSTALL_DIR/toxid
75
+	sed -i '/toxavahi/d' /etc/crontab
76
+	systemctl restart cron
77
+	sed -i '/tox_avahi/d' $COMPLETION_FILE
78
+}
79
+
80
+function remove_tox_client {
81
+	if ! grep -Fxq "install_tox_client" $COMPLETION_FILE; then
82
+		return
83
+	fi
84
+
85
+	${PROJECT_NAME}-mesh-install -f tox_client --remove yes
86
+	if [ ! "$?" = "0" ]; then
87
+		echo $'Could not remove Tox client'
88
+		exit 737253
89
+	fi
90
+	sed -i '/install_tox_client/d' $COMPLETION_FILE
91
+	sed -i '/Tox /d' $COMPLETION_FILE
92
+	sed -i '/Toxic /d' $COMPLETION_FILE
93
+}
94
+
95
+function remove_tox {
96
+	remove_tox_client
97
+	remove_tox_avahi
98
+	remove_tox_node
65 99
 }
66 100
 
67 101
 function configure_firewall_for_tox {

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

@@ -589,6 +589,15 @@ function mesh_tox_node {
589 589
 	$CHROOT_PREFIX systemctl enable tox-bootstrapd.service
590 590
 }
591 591
 
592
+function mesh_tox_client_remove {
593
+	if [ ! -d $INSTALL_DIR/toxic ]; then
594
+		return
595
+	fi
596
+	cd $INSTALL_DIR/toxic
597
+	make uninstall
598
+	rm -rf $INSTALL_DIR/toxic
599
+}
600
+
592 601
 function mesh_tox_client {
593 602
 	if [ -f /usr/local/bin/${PROJECT_NAME} ]; then
594 603
 		TOXIC_FILE=$(cat /usr/local/bin/${PROJECT_NAME}-app-tox | grep "TOXIC_FILE=" | head -n 1 | awk -F '=' '{print $2}')
@@ -1106,7 +1115,11 @@ if [[ $FN == 'tox_node' ]]; then
1106 1115
 	fi
1107 1116
 fi
1108 1117
 if [[ $FN == 'tox_client' ]]; then
1109
-	mesh_tox_client
1118
+	if [[ $REMOVE != 'yes' ]]; then
1119
+		mesh_tox_client
1120
+	else
1121
+		mesh_tox_client_remove
1122
+	fi
1110 1123
 fi
1111 1124
 if [[ $FN == 'zeronet' ]]; then
1112 1125
 	mesh_zeronet