浏览代码

functions to remove babel

Bob Mottram 8 年前
父节点
当前提交
879ab883fb
共有 2 个文件被更改,包括 62 次插入26 次删除
  1. 44
    25
      src/freedombone-app-babel
  2. 18
    1
      src/freedombone-mesh-install

+ 44
- 25
src/freedombone-app-babel 查看文件

32
 ENABLE_BABEL="no"
32
 ENABLE_BABEL="no"
33
 BABEL_PORT=6696
33
 BABEL_PORT=6696
34
 
34
 
35
+function remove_babel {
36
+    if ! grep -Fxq "mesh_babel" $COMPLETION_FILE; then
37
+        return
38
+    fi
39
+
40
+    ${PROJECT_NAME}-mesh-install -f babel --remove yes
41
+    if [ ! "$?" = "0" ]; then
42
+        echo $'Failed to remove babel'
43
+        exit 83658
44
+    fi
45
+
46
+    iptables -D INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
47
+    function_check save_firewall_settings
48
+    save_firewall_settings
49
+
50
+    sed -i '/mesh_babel/d' $COMPLETION_FILE
51
+    sed -i '/configure_firewall_for_babel/d' $COMPLETION_FILE
52
+}
53
+
35
 function configure_firewall_for_babel {
54
 function configure_firewall_for_babel {
36
-	if grep -Fxq "configure_firewall_for_babel" $COMPLETION_FILE; then
37
-		return
38
-	fi
39
-	if [[ $ENABLE_BABEL != "yes" ]]; then
40
-		return
41
-	fi
42
-	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
43
-	function_check save_firewall_settings
44
-	save_firewall_settings
55
+    if grep -Fxq "configure_firewall_for_babel" $COMPLETION_FILE; then
56
+        return
57
+    fi
58
+    if [[ $ENABLE_BABEL != "yes" ]]; then
59
+        return
60
+    fi
61
+    iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
62
+    function_check save_firewall_settings
63
+    save_firewall_settings
45
 
64
 
46
-	OPEN_PORTS+=("Babel    $BABEL_PORT")
47
-	echo 'configure_firewall_for_babel' >> $COMPLETION_FILE
65
+    OPEN_PORTS+=("Babel    $BABEL_PORT")
66
+    echo 'configure_firewall_for_babel' >> $COMPLETION_FILE
48
 }
67
 }
49
 
68
 
50
 function mesh_babel {
69
 function mesh_babel {
51
-	if grep -Fxq "mesh_babel" $COMPLETION_FILE; then
52
-		return
53
-	fi
54
-	if [[ $ENABLE_BABEL != "yes" ]]; then
55
-		return
56
-	fi
70
+    if grep -Fxq "mesh_babel" $COMPLETION_FILE; then
71
+        return
72
+    fi
73
+    if [[ $ENABLE_BABEL != "yes" ]]; then
74
+        return
75
+    fi
57
 
76
 
58
-	${PROJECT_NAME}-mesh-install -f babel
59
-	if [ ! "$?" = "0" ]; then
60
-		echo $'Failed to install babel'
61
-		exit 67242
62
-	fi
77
+    ${PROJECT_NAME}-mesh-install -f babel
78
+    if [ ! "$?" = "0" ]; then
79
+        echo $'Failed to install babel'
80
+        exit 67242
81
+    fi
63
 
82
 
64
-	function_check configure_firewall_for_babel
65
-	configure_firewall_for_babel
66
-	echo 'mesh_babel' >> $COMPLETION_FILE
83
+    function_check configure_firewall_for_babel
84
+    configure_firewall_for_babel
85
+    echo 'mesh_babel' >> $COMPLETION_FILE
67
 }
86
 }
68
 
87
 
69
 # NOTE: deliberately there is no "exit 0"
88
 # NOTE: deliberately there is no "exit 0"

+ 18
- 1
src/freedombone-mesh-install 查看文件

77
 
77
 
78
 MESH_INSTALL_DIR=/var/lib
78
 MESH_INSTALL_DIR=/var/lib
79
 
79
 
80
+REMOVE='no'
81
+
80
 source /usr/local/bin/${PROJECT_NAME}-utils-git
82
 source /usr/local/bin/${PROJECT_NAME}-utils-git
81
 if [ -f /usr/bin/${PROJECT_NAME}-utils-git ]; then
83
 if [ -f /usr/bin/${PROJECT_NAME}-utils-git ]; then
82
 	source /usr/bin/${PROJECT_NAME}-utils-git
84
 	source /usr/bin/${PROJECT_NAME}-utils-git
178
 	$CHROOT_PREFIX systemctl enable babel
180
 	$CHROOT_PREFIX systemctl enable babel
179
 }
181
 }
180
 
182
 
183
+function mesh_babel_remove {
184
+	$CHROOT_PREFIX systemctl stop babel
185
+	$CHROOT_PREFIX apt-get -y remove --purge babeld
186
+	rm ${rootdir}/var/lib/babel
187
+	rm ${rootdir}/etc/systemd/system/babel.service
188
+}
189
+
181
 function mesh_avahi {
190
 function mesh_avahi {
182
 	$CHROOT_PREFIX apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd
191
 	$CHROOT_PREFIX apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd
183
 
192
 
1030
 			shift
1039
 			shift
1031
 			FRIENDS_MIRRORS_SERVER="$1"
1040
 			FRIENDS_MIRRORS_SERVER="$1"
1032
 			;;
1041
 			;;
1042
+		--remove)
1043
+			shift
1044
+			REMOVE="$1"
1045
+			;;
1033
 		*)
1046
 		*)
1034
 			# unknown option
1047
 			# unknown option
1035
 			;;
1048
 			;;
1039
 done
1052
 done
1040
 
1053
 
1041
 if [[ $FN == 'babel' ]]; then
1054
 if [[ $FN == 'babel' ]]; then
1042
-	mesh_babel
1055
+	if [[ $REMOVE != 'yes' ]]; then
1056
+		mesh_babel
1057
+	else
1058
+		mesh_babel_remove
1059
+	fi
1043
 fi
1060
 fi
1044
 if [[ $FN == 'babel_client' ]]; then
1061
 if [[ $FN == 'babel_client' ]]; then
1045
 	mesh_babel_client
1062
 	mesh_babel_client