Browse Source

Move firewall functions into app scripts

Bob Mottram 8 years ago
parent
commit
bc76f9237f

+ 15
- 0
src/freedombone-app-babel View File

@@ -32,6 +32,21 @@
32 32
 ENABLE_BABEL="no"
33 33
 BABEL_PORT=6696
34 34
 
35
+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
45
+
46
+	OPEN_PORTS+=("Babel    $BABEL_PORT")
47
+	echo 'configure_firewall_for_babel' >> $COMPLETION_FILE
48
+}
49
+
35 50
 function mesh_babel {
36 51
 	if grep -Fxq "mesh_babel" $COMPLETION_FILE; then
37 52
 		return

+ 13
- 0
src/freedombone-app-batman View File

@@ -32,6 +32,19 @@
32 32
 ENABLE_BATMAN="no"
33 33
 BATMAN_CELLID='any'
34 34
 
35
+function configure_firewall_for_batman {
36
+	if grep -Fxq "configure_firewall_for_batman" $COMPLETION_FILE; then
37
+		return
38
+	fi
39
+	if [[ $ENABLE_BATMAN != "yes" ]]; then
40
+		return
41
+	fi
42
+
43
+	function_check save_firewall_settings
44
+	save_firewall_settings
45
+	echo 'configure_firewall_for_batman' >> $COMPLETION_FILE
46
+}
47
+
35 48
 function mesh_batman {
36 49
 	if grep -Fxq "mesh_batman" $COMPLETION_FILE; then
37 50
 		return

+ 400
- 383
src/freedombone-app-cjdns View File

@@ -40,408 +40,425 @@ CJDNS_COMMIT='13189fde111d0500427a7a0ce06a970753527bca'
40 40
 CJDCMD_REPO="https://github.com/inhies/cjdcmd"
41 41
 CJDCMD_COMMIT='973cca6ed0eecf9041c3403a40193c0b1291b808'
42 42
 
43
+function configure_firewall_for_cjdns {
44
+    if grep -Fxq "configure_firewall_for_cjdns" $COMPLETION_FILE; then
45
+        return
46
+    fi
47
+    if [[ $ENABLE_CJDNS != "yes" ]]; then
48
+        return
49
+    fi
50
+    ip6tables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
51
+    ip6tables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
52
+    function_check save_firewall_settings
53
+    save_firewall_settings
54
+    echo 'configure_firewall_for_cjdns' >> $COMPLETION_FILE
55
+}
56
+
43 57
 function get_cjdns_public_key {
44
-	if [ -f /home/$MY_USERNAME/README ]; then
45
-		if grep -q "cjdns public key" /home/$MY_USERNAME/README; then
46
-			if [ ! $CJDNS_PUBLIC_KEY ]; then
47
-				CJDNS_PUBLIC_KEY=$(cat /home/$MY_USERNAME/README | grep "cjdns public key" | awk -F ':' '{print $2}' | sed 's/^ *//')
48
-			fi
49
-		fi
50
-	fi
58
+    if [ -f /home/$MY_USERNAME/README ]; then
59
+        if grep -q "cjdns public key" /home/$MY_USERNAME/README; then
60
+            if [ ! $CJDNS_PUBLIC_KEY ]; then
61
+                CJDNS_PUBLIC_KEY=$(cat /home/$MY_USERNAME/README | grep "cjdns public key" | awk -F ':' '{print $2}' | sed 's/^ *//')
62
+            fi
63
+        fi
64
+    fi
51 65
 }
52 66
 
53 67
 function get_cjdns_private_key {
54
-	if [ -f /home/$MY_USERNAME/README ]; then
55
-		if grep -q "cjdns private key" /home/$MY_USERNAME/README; then
56
-			if [ ! $CJDNS_PRIVATE_KEY ]; then
57
-				CJDNS_PRIVATE_KEY=$(cat /home/$MY_USERNAME/README | grep "cjdns private key" | awk -F ':' '{print $2}' | sed 's/^ *//')
58
-			fi
59
-		fi
60
-	fi
68
+    if [ -f /home/$MY_USERNAME/README ]; then
69
+        if grep -q "cjdns private key" /home/$MY_USERNAME/README; then
70
+            if [ ! $CJDNS_PRIVATE_KEY ]; then
71
+                CJDNS_PRIVATE_KEY=$(cat /home/$MY_USERNAME/README | grep "cjdns private key" | awk -F ':' '{print $2}' | sed 's/^ *//')
72
+            fi
73
+        fi
74
+    fi
61 75
 }
62 76
 
63 77
 function get_cjdns_ipv6_address {
64
-	if [ -f /home/$MY_USERNAME/README ]; then
65
-		if grep -q "cjdns IPv6 address" /home/$MY_USERNAME/README; then
66
-			if [ ! $CJDNS_IPV6 ]; then
67
-				CJDNS_IPV6=$(cat /home/$MY_USERNAME/README | grep "cjdns IPv6 address" | awk -F ':' '{print $2}' | sed 's/^ *//')
68
-			fi
69
-		fi
70
-	fi
78
+    if [ -f /home/$MY_USERNAME/README ]; then
79
+        if grep -q "cjdns IPv6 address" /home/$MY_USERNAME/README; then
80
+            if [ ! $CJDNS_IPV6 ]; then
81
+                CJDNS_IPV6=$(cat /home/$MY_USERNAME/README | grep "cjdns IPv6 address" | awk -F ':' '{print $2}' | sed 's/^ *//')
82
+            fi
83
+        fi
84
+    fi
71 85
 }
72 86
 
73 87
 function get_cjdns_port {
74
-	if [ -f /home/$MY_USERNAME/README ]; then
75
-		if grep -q "cjdns port" /home/$MY_USERNAME/README; then
76
-			if [ ! $CJDNS_PORT ]; then
77
-				CJDNS_PORT=$(cat /home/$MY_USERNAME/README | grep "cjdns port" | awk -F ':' '{print $2}' | sed 's/^ *//')
78
-			fi
79
-		fi
80
-	fi
88
+    if [ -f /home/$MY_USERNAME/README ]; then
89
+        if grep -q "cjdns port" /home/$MY_USERNAME/README; then
90
+            if [ ! $CJDNS_PORT ]; then
91
+                CJDNS_PORT=$(cat /home/$MY_USERNAME/README | grep "cjdns port" | awk -F ':' '{print $2}' | sed 's/^ *//')
92
+            fi
93
+        fi
94
+    fi
81 95
 }
82 96
 
83 97
 function get_cjdns_password {
84
-	if [ -f /home/$MY_USERNAME/README ]; then
85
-		if grep -q "cjdns password" /home/$MY_USERNAME/README; then
86
-			if [ ! $CJDNS_PASSWORD ]; then
87
-				CJDNS_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "cjdns password" | awk -F ':' '{print $2}' | sed 's/^ *//')
88
-			fi
89
-		fi
90
-	fi
98
+    if [ -f /home/$MY_USERNAME/README ]; then
99
+        if grep -q "cjdns password" /home/$MY_USERNAME/README; then
100
+            if [ ! $CJDNS_PASSWORD ]; then
101
+                CJDNS_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "cjdns password" | awk -F ':' '{print $2}' | sed 's/^ *//')
102
+            fi
103
+        fi
104
+    fi
91 105
 }
92 106
 
93 107
 function mesh_cjdns {
94
-	if [[ $ENABLE_CJDNS != "yes" ]]; then
95
-		return
96
-	fi
97
-
98
-	# update to the next commit
99
-	function_check set_repo_commit
100
-	set_repo_commit /etc/cjdns "cjdns commit" "$CJDNS_COMMIT" $CJDNS_REPO
101
-
102
-	if grep -Fxq "mesh_cjdns" $COMPLETION_FILE; then
103
-		return
104
-	fi
105
-
106
-	apt-get -y install nodejs git build-essential nmap
107
-
108
-	# if a README exists then obtain the cjdns parameters
109
-	function_check get_cjdns_ipv6_address
110
-	get_cjdns_ipv6_address
111
-
112
-	function_check get_cjdns_public_key
113
-	get_cjdns_public_key
114
-
115
-	function_check get_cjdns_private_key
116
-	get_cjdns_private_key
117
-
118
-	function_check get_cjdns_port
119
-	get_cjdns_port
120
-
121
-	function_check get_cjdns_password
122
-	get_cjdns_password
123
-
124
-	# special compile settings for running ./do on the Beaglebone Black
125
-	if [[ $INSTALLING_ON_BBB == "yes" ]]; then
126
-		CFLAGS="-O2 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -ftree-vectorize -ffast-math -mfloat-abi=hard -marm -Wno-error=maybe-uninitialized"
127
-		export LDFLAGS="$CFLAGS"
128
-	fi
129
-
130
-	if [ ! -d /etc/cjdns ]; then
131
-		function_check git_pull
132
-		git_clone $CJDNS_REPO /etc/cjdns
133
-		cd /etc/cjdns
134
-
135
-		git checkout $CJDNS_COMMIT -b $CJDNS_COMMIT
136
-		if ! grep -q "cjdns commit" $COMPLETION_FILE; then
137
-			echo "cjdns commit:$CJDNS_COMMIT" >> $COMPLETION_FILE
138
-		else
139
-			sed -i "s/cjdns commit.*/cjdns commit:$CJDNS_COMMIT/g" $COMPLETION_FILE
140
-		fi
141
-
142
-		./do
143
-		if [ ! "$?" = "0" ]; then
144
-			exit 7439
145
-		fi
146
-		# create a configuration
147
-		if [ ! -f /etc/cjdns/cjdroute.conf ]; then
148
-			./cjdroute --genconf > /etc/cjdns/cjdroute.conf
149
-			if [ ! "$?" = "0" ]; then
150
-				exit 5922
151
-			fi
152
-		fi
153
-		# create a user to run as
154
-		useradd cjdns
155
-	else
156
-		cd /etc/cjdns
157
-		function_check git_pull
158
-		git_pull $CJDNS_REPO
159
-		./do
160
-		if [ ! "$?" = "0" ]; then
161
-			exit 9926
162
-		fi
163
-	fi
164
-
165
-	# set permissions
166
-	chown -R cjdns:cjdns /etc/cjdns
167
-	chmod 600 /etc/cjdns/cjdroute.conf
168
-
169
-	/sbin/ip tuntap add mode tun user cjdns dev cjdroute0
170
-
171
-	# insert values into the configuration file
172
-	if [ $CJDNS_PRIVATE_KEY ]; then
173
-		sed -i "s/\"privateKey\":.*/\"privateKey\": \"$CJDNS_PRIVATE_KEY\",/g" /etc/cjdns/cjdroute.conf
174
-	else
175
-		CJDNS_PRIVATE_KEY=$(cat /etc/cjdns/cjdroute.conf | grep '"privateKey"' | awk -F '"' '{print $4}' | sed -n 1p)
176
-	fi
177
-	if [ $CJDNS_PUBLIC_KEY ]; then
178
-		sed -i "s/\"publicKey\":.*/\"publicKey\": \"$CJDNS_PUBLIC_KEY\",/g" /etc/cjdns/cjdroute.conf
179
-	else
180
-		CJDNS_PUBLIC_KEY=$(cat /etc/cjdns/cjdroute.conf | grep '"publicKey"' | awk -F '"' '{print $4}' | sed -n 1p)
181
-	fi
182
-	if [ $CJDNS_IPV6 ]; then
183
-		sed -i "s/\"ipv6\":.*/\"ipv6\": \"$CJDNS_IPV6\",/g" /etc/cjdns/cjdroute.conf
184
-	else
185
-		CJDNS_IPV6=$(cat /etc/cjdns/cjdroute.conf | grep '"ipv6"' | awk -F '"' '{print $4}' | sed -n 1p)
186
-	fi
187
-	if [ $CJDNS_PASSWORD ]; then
188
-		sed -i "0,/{\"password\":.*/s//{\"password\": \"$CJDNS_PASSWORD\"}/g" /etc/cjdns/cjdroute.conf
189
-	else
190
-		CJDNS_PASSWORD=$(cat /etc/cjdns/cjdroute.conf | grep '"password"' | awk -F '"' '{print $4}' | sed -n 1p)
191
-	fi
192
-	if [ $CJDNS_PORT ]; then
193
-		sed -i "s/\"bind\": \"0.0.0.0:.*/\"bind\": \"0.0.0.0:$CJDNS_PORT\",/g" /etc/cjdns/cjdroute.conf
194
-	else
195
-		CJDNS_PORT=$(cat /etc/cjdns/cjdroute.conf | grep '"bind": "0.0.0.0:' | awk -F '"' '{print $4}' | awk -F ':' '{print $2}' | sed -n 1p)
196
-	fi
197
-
198
-	function_check enable_ipv6
199
-	enable_ipv6
200
-
201
-	echo '#!/bin/sh -e' > /etc/init.d/cjdns
202
-	echo '### BEGIN INIT INFO' >> /etc/init.d/cjdns
203
-	echo '# hyperboria.sh - An init script (/etc/init.d/) for cjdns' >> /etc/init.d/cjdns
204
-	echo '# Provides:          cjdroute' >> /etc/init.d/cjdns
205
-	echo '# Required-Start:    $remote_fs $network' >> /etc/init.d/cjdns
206
-	echo '# Required-Stop:     $remote_fs $network' >> /etc/init.d/cjdns
207
-	echo '# Default-Start:     2 3 4 5' >> /etc/init.d/cjdns
208
-	echo '# Default-Stop:      0 1 6' >> /etc/init.d/cjdns
209
-	echo '# Short-Description: Cjdns router' >> /etc/init.d/cjdns
210
-	echo '# Description:       A routing engine designed for security, scalability, speed and ease of use.' >> /etc/init.d/cjdns
211
-	echo '# cjdns git repo:    https://github.com/cjdelisle/cjdns/' >> /etc/init.d/cjdns
212
-	echo '### END INIT INFO' >> /etc/init.d/cjdns
213
-	echo '' >> /etc/init.d/cjdns
214
-	echo 'PROG="cjdroute"' >> /etc/init.d/cjdns
215
-	echo 'GIT_PATH="/etc/cjdns"' >> /etc/init.d/cjdns
216
-	echo 'PROG_PATH="/etc/cjdns"' >> /etc/init.d/cjdns
217
-	echo 'CJDNS_CONFIG="cjdroute.conf"' >> /etc/init.d/cjdns
218
-	echo 'CJDNS_USER="cjdns"' >> /etc/init.d/cjdns
219
-	echo "CJDNS_IP='$CJDNS_IPV6'" >> /etc/init.d/cjdns
220
-	echo '' >> /etc/init.d/cjdns
221
-	echo 'start() {' >> /etc/init.d/cjdns
222
-	echo '     # Start it up with the user cjdns' >> /etc/init.d/cjdns
223
-	echo '     if [ $(pgrep cjdroute | wc -l) != 0 ];' >> /etc/init.d/cjdns
224
-	echo '     then' >> /etc/init.d/cjdns
225
-	echo '         echo "cjdroute is already running. Doing nothing..."' >> /etc/init.d/cjdns
226
-	echo '     else' >> /etc/init.d/cjdns
227
-	echo '         echo " * Starting cjdroute"' >> /etc/init.d/cjdns
228
-	echo '         su -c "$PROG_PATH/$PROG < $PROG_PATH/$CJDNS_CONFIG" - $CJDNS_USER' >> /etc/init.d/cjdns
229
-	echo '         /sbin/ip addr add $CJDNS_IP/8 dev tun0' >> /etc/init.d/cjdns
230
-	echo '         /sbin/ip link set mtu 1312 dev tun0' >> /etc/init.d/cjdns
231
-	echo '         /sbin/ip link set tun0 up' >> /etc/init.d/cjdns
232
-	echo '         /sbin/ip tuntap add mode tun user cjdns dev tun0' >> /etc/init.d/cjdns
233
-	echo '     fi' >> /etc/init.d/cjdns
234
-	echo '}' >> /etc/init.d/cjdns
235
-	echo '' >> /etc/init.d/cjdns
236
-	echo 'stop() {' >> /etc/init.d/cjdns
237
-	echo '' >> /etc/init.d/cjdns
238
-	echo '     if [ $(pgrep cjdroute | wc -l) != 2 ];' >> /etc/init.d/cjdns
239
-	echo '     then' >> /etc/init.d/cjdns
240
-	echo '         echo "cjdns isnt running."' >> /etc/init.d/cjdns
241
-	echo '     else' >> /etc/init.d/cjdns
242
-	echo '         echo "Killing cjdroute"' >> /etc/init.d/cjdns
243
-	echo '         killall cjdroute' >> /etc/init.d/cjdns
244
-	echo '     fi' >> /etc/init.d/cjdns
245
-	echo '}' >> /etc/init.d/cjdns
246
-	echo '' >> /etc/init.d/cjdns
247
-	echo 'status() {' >> /etc/init.d/cjdns
248
-	echo '     if [ $(pgrep cjdroute | wc -l) != 0 ];' >> /etc/init.d/cjdns
249
-	echo '     then' >> /etc/init.d/cjdns
250
-	echo '         echo "Cjdns is running"' >> /etc/init.d/cjdns
251
-	echo '     else' >> /etc/init.d/cjdns
252
-	echo '         echo "Cjdns is not running"' >> /etc/init.d/cjdns
253
-	echo '     fi' >> /etc/init.d/cjdns
254
-	echo '}' >> /etc/init.d/cjdns
255
-	echo '' >> /etc/init.d/cjdns
256
-	echo ' update() {' >> /etc/init.d/cjdns
257
-	echo '     cd $GIT_PATH' >> /etc/init.d/cjdns
258
-	echo '     echo "Updating..."' >> /etc/init.d/cjdns
259
-	echo '     git pull' >> /etc/init.d/cjdns
260
-	echo '     ./do' >> /etc/init.d/cjdns
261
-	echo '}' >> /etc/init.d/cjdns
262
-	echo '' >> /etc/init.d/cjdns
263
-	echo '## Check to see if we are running as root first.' >> /etc/init.d/cjdns
264
-	echo 'if [ "$(id -u)" != "0" ]; then' >> /etc/init.d/cjdns
265
-	echo '    echo "This script must be run as root" 1>&2' >> /etc/init.d/cjdns
266
-	echo '    exit 1' >> /etc/init.d/cjdns
267
-	echo 'fi' >> /etc/init.d/cjdns
268
-	echo '' >> /etc/init.d/cjdns
269
-	echo 'case $1 in' >> /etc/init.d/cjdns
270
-	echo '     start)' >> /etc/init.d/cjdns
271
-	echo '         start' >> /etc/init.d/cjdns
272
-	echo '         exit 0' >> /etc/init.d/cjdns
273
-	echo '     ;;' >> /etc/init.d/cjdns
274
-	echo '     stop)' >> /etc/init.d/cjdns
275
-	echo '         stop' >> /etc/init.d/cjdns
276
-	echo '         exit 0' >> /etc/init.d/cjdns
277
-	echo '     ;;' >> /etc/init.d/cjdns
278
-	echo '     reload|restart|force-reload)' >> /etc/init.d/cjdns
279
-	echo '         stop' >> /etc/init.d/cjdns
280
-	echo '         sleep 1' >> /etc/init.d/cjdns
281
-	echo '         start' >> /etc/init.d/cjdns
282
-	echo '         exit 0' >> /etc/init.d/cjdns
283
-	echo '     ;;' >> /etc/init.d/cjdns
284
-	echo '     status)' >> /etc/init.d/cjdns
285
-	echo '         status' >> /etc/init.d/cjdns
286
-	echo '         exit 0' >> /etc/init.d/cjdns
287
-	echo '     ;;' >> /etc/init.d/cjdns
288
-	echo '     update|upgrade)' >> /etc/init.d/cjdns
289
-	echo '         update' >> /etc/init.d/cjdns
290
-	echo '         stop' >> /etc/init.d/cjdns
291
-	echo '         sleep 2' >> /etc/init.d/cjdns
292
-	echo '         start' >> /etc/init.d/cjdns
293
-	echo '         exit 0' >> /etc/init.d/cjdns
294
-	echo '     ;;' >> /etc/init.d/cjdns
295
-	echo '     **)' >> /etc/init.d/cjdns
296
-	echo '         echo "Usage: $0 (start|stop|restart|status|update)" 1>&2' >> /etc/init.d/cjdns
297
-	echo '         exit 1' >> /etc/init.d/cjdns
298
-	echo '     ;;' >> /etc/init.d/cjdns
299
-	echo 'esac' >> /etc/init.d/cjdns
300
-	chmod +x /etc/init.d/cjdns
301
-	update-rc.d cjdns defaults
302
-	service cjdns start
303
-	if [ ! "$?" = "0" ]; then
304
-		systemctl status cjdns.service
305
-		exit 8260
306
-	fi
307
-
308
-	apt-get -y install radvd
309
-	echo 'interface eth0' > /etc/radvd.conf
310
-	echo '{' >> /etc/radvd.conf
311
-	echo '    AdvSendAdvert on;' >> /etc/radvd.conf
312
-	echo '    prefix fdfc::1/64' >> /etc/radvd.conf
313
-	echo '    {' >> /etc/radvd.conf
314
-	echo '        AdvRouterAddr on;' >> /etc/radvd.conf
315
-	echo '    };' >> /etc/radvd.conf
316
-	echo '};' >> /etc/radvd.conf
317
-	systemctl restart radvd
318
-	if [ ! "$?" = "0" ]; then
319
-		systemctl status radvd.service
320
-		exit 4395
321
-	fi
322
-
323
-	if ! grep -q "# Mesh Networking (cjdns)" /etc/network/interfaces; then
324
-		echo '' >> /etc/network/interfaces
325
-		echo '# Mesh Networking (cjdns)' >> /etc/network/interfaces
326
-		echo 'iface eth0 inet6 static' >> /etc/network/interfaces
327
-		echo '    pre-up modprobe ipv6' >> /etc/network/interfaces
328
-		echo '    address fdfc:0000:0000:0000:0000:0000:0000:0001' >> /etc/network/interfaces
329
-		echo '    netmask 64' >> /etc/network/interfaces
330
-		service network-manager restart
331
-		if [ ! "$?" = "0" ]; then
332
-			systemctl status networking.service
333
-			exit 6949
334
-		fi
335
-	fi
336
-
337
-	ip6tables -A INPUT -p udp --dport $CJDNS_PORT -j ACCEPT
338
-	ip6tables -A INPUT -p tcp --dport $CJDNS_PORT -j ACCEPT
339
-
340
-	function_ckeck save_firewall_settings
341
-	save_firewall_settings
342
-
343
-	if ! grep -q $"Mesh Networking (cjdns)" /home/$MY_USERNAME/README; then
344
-		CURRENT_IP_ADDRESS=$(ip addr show | grep "inet " | sed -n 2p | awk -F ' ' '{print $2}' | awk -F '/' '{print $1}')
345
-
346
-		echo '' >> /home/$MY_USERNAME/README
347
-		echo '' >> /home/$MY_USERNAME/README
348
-		echo $'Mesh Networking (cjdns)' >> /home/$MY_USERNAME/README
349
-		echo '=======================' >> /home/$MY_USERNAME/README
350
-		echo $"cjdns IPv6 address: $CJDNS_IPV6" >> /home/$MY_USERNAME/README
351
-		echo $"cjdns public key: $CJDNS_PUBLIC_KEY" >> /home/$MY_USERNAME/README
352
-		echo $"cjdns private key: $CJDNS_PRIVATE_KEY" >> /home/$MY_USERNAME/README
353
-		echo $"cjdns password: $CJDNS_PASSWORD" >> /home/$MY_USERNAME/README
354
-		echo $"cjdns port: $CJDNS_PORT" >> /home/$MY_USERNAME/README
355
-		echo '' >> /home/$MY_USERNAME/README
356
-		echo $"Forward port $CJDNS_PORT from your internet router to the ${PROJECT_NAME}" >> /home/$MY_USERNAME/README
357
-		echo '' >> /home/$MY_USERNAME/README
358
-		echo $'Below is an example of your connection credentials' >> /home/$MY_USERNAME/README
359
-		echo $'that you can give to other people so they can connect' >> /home/$MY_USERNAME/README
360
-		echo $'to you using your default password' >> /home/$MY_USERNAME/README
361
-		echo $'Adding a unique password for each user is advisable' >> /home/$MY_USERNAME/README
362
-		echo $'so that leaks can be isolated.' >> /home/$MY_USERNAME/README
363
-		echo '' >> /home/$MY_USERNAME/README
364
-		echo "\"$CURRENT_IP_ADDRESS:$CJDNS_PORT\":{\"password\":\"$CJDNS_PASSWORD\",\"publicKey\":\"$CJDNS_PUBLIC_KEY\"}" >> /home/$MY_USERNAME/README
365
-		echo '' >> /home/$MY_USERNAME/README
366
-		echo $'More is not better. 3-5 cjdns peers is good. 30 peers is bad.' >> /home/$MY_USERNAME/README
367
-		echo '' >> /home/$MY_USERNAME/README
368
-		echo $'NEVER USE A PUBLIC PEER. These degrade the network and make it centralized.' >> /home/$MY_USERNAME/README
369
-		echo $'Each node can handle many peers, but no node can handle the entire internet.' >> /home/$MY_USERNAME/README
370
-		echo $'As this network grows any public peer will simply become saturated and' >> /home/$MY_USERNAME/README
371
-		echo $'useless causing issues for the entire network.' >> /home/$MY_USERNAME/README
372
-		echo $'Please report anyone offering you a public peer as they are promoting shared' >> /home/$MY_USERNAME/README
373
-		echo $'passwords which could lead to people pretending to be you. A peering pass' >> /home/$MY_USERNAME/README
374
-		echo $'should not contain someone elses nickname or info but should contain yours' >> /home/$MY_USERNAME/README
375
-		echo $'to ensure it is not shared. It also helps when editing the conf to know who' >> /home/$MY_USERNAME/README
376
-		echo $'each password is for.' >> /home/$MY_USERNAME/README
377
-		echo '' >> /home/$MY_USERNAME/README
378
-		echo $'Possible cjdns destinations of interest:' >> /home/$MY_USERNAME/README
379
-		echo '    http://transitiontech.ca/faq' >> /home/$MY_USERNAME/README
380
-		echo '    http://cjdns.ca/hypeirc.txt' >> /home/$MY_USERNAME/README
381
-		chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
382
-		chmod 600 /home/$MY_USERNAME/README
383
-	fi
384
-
385
-	echo 'mesh_cjdns' >> $COMPLETION_FILE
108
+    if [[ $ENABLE_CJDNS != "yes" ]]; then
109
+        return
110
+    fi
111
+
112
+    # update to the next commit
113
+    function_check set_repo_commit
114
+    set_repo_commit /etc/cjdns "cjdns commit" "$CJDNS_COMMIT" $CJDNS_REPO
115
+
116
+    if grep -Fxq "mesh_cjdns" $COMPLETION_FILE; then
117
+        return
118
+    fi
119
+
120
+    apt-get -y install nodejs git build-essential nmap
121
+
122
+    # if a README exists then obtain the cjdns parameters
123
+    function_check get_cjdns_ipv6_address
124
+    get_cjdns_ipv6_address
125
+
126
+    function_check get_cjdns_public_key
127
+    get_cjdns_public_key
128
+
129
+    function_check get_cjdns_private_key
130
+    get_cjdns_private_key
131
+
132
+    function_check get_cjdns_port
133
+    get_cjdns_port
134
+
135
+    function_check get_cjdns_password
136
+    get_cjdns_password
137
+
138
+    # special compile settings for running ./do on the Beaglebone Black
139
+    if [[ $INSTALLING_ON_BBB == "yes" ]]; then
140
+        CFLAGS="-O2 -march=armv7-a -mtune=cortex-a8 -mfpu=neon -ftree-vectorize -ffast-math -mfloat-abi=hard -marm -Wno-error=maybe-uninitialized"
141
+        export LDFLAGS="$CFLAGS"
142
+    fi
143
+
144
+    if [ ! -d /etc/cjdns ]; then
145
+        function_check git_pull
146
+        git_clone $CJDNS_REPO /etc/cjdns
147
+        cd /etc/cjdns
148
+
149
+        git checkout $CJDNS_COMMIT -b $CJDNS_COMMIT
150
+        if ! grep -q "cjdns commit" $COMPLETION_FILE; then
151
+            echo "cjdns commit:$CJDNS_COMMIT" >> $COMPLETION_FILE
152
+        else
153
+            sed -i "s/cjdns commit.*/cjdns commit:$CJDNS_COMMIT/g" $COMPLETION_FILE
154
+        fi
155
+
156
+        ./do
157
+        if [ ! "$?" = "0" ]; then
158
+            exit 7439
159
+        fi
160
+        # create a configuration
161
+        if [ ! -f /etc/cjdns/cjdroute.conf ]; then
162
+            ./cjdroute --genconf > /etc/cjdns/cjdroute.conf
163
+            if [ ! "$?" = "0" ]; then
164
+                exit 5922
165
+            fi
166
+        fi
167
+        # create a user to run as
168
+        useradd cjdns
169
+    else
170
+        cd /etc/cjdns
171
+        function_check git_pull
172
+        git_pull $CJDNS_REPO
173
+        ./do
174
+        if [ ! "$?" = "0" ]; then
175
+            exit 9926
176
+        fi
177
+    fi
178
+
179
+    # set permissions
180
+    chown -R cjdns:cjdns /etc/cjdns
181
+    chmod 600 /etc/cjdns/cjdroute.conf
182
+
183
+    /sbin/ip tuntap add mode tun user cjdns dev cjdroute0
184
+
185
+    # insert values into the configuration file
186
+    if [ $CJDNS_PRIVATE_KEY ]; then
187
+        sed -i "s/\"privateKey\":.*/\"privateKey\": \"$CJDNS_PRIVATE_KEY\",/g" /etc/cjdns/cjdroute.conf
188
+    else
189
+        CJDNS_PRIVATE_KEY=$(cat /etc/cjdns/cjdroute.conf | grep '"privateKey"' | awk -F '"' '{print $4}' | sed -n 1p)
190
+    fi
191
+    if [ $CJDNS_PUBLIC_KEY ]; then
192
+        sed -i "s/\"publicKey\":.*/\"publicKey\": \"$CJDNS_PUBLIC_KEY\",/g" /etc/cjdns/cjdroute.conf
193
+    else
194
+        CJDNS_PUBLIC_KEY=$(cat /etc/cjdns/cjdroute.conf | grep '"publicKey"' | awk -F '"' '{print $4}' | sed -n 1p)
195
+    fi
196
+    if [ $CJDNS_IPV6 ]; then
197
+        sed -i "s/\"ipv6\":.*/\"ipv6\": \"$CJDNS_IPV6\",/g" /etc/cjdns/cjdroute.conf
198
+    else
199
+        CJDNS_IPV6=$(cat /etc/cjdns/cjdroute.conf | grep '"ipv6"' | awk -F '"' '{print $4}' | sed -n 1p)
200
+    fi
201
+    if [ $CJDNS_PASSWORD ]; then
202
+        sed -i "0,/{\"password\":.*/s//{\"password\": \"$CJDNS_PASSWORD\"}/g" /etc/cjdns/cjdroute.conf
203
+    else
204
+        CJDNS_PASSWORD=$(cat /etc/cjdns/cjdroute.conf | grep '"password"' | awk -F '"' '{print $4}' | sed -n 1p)
205
+    fi
206
+    if [ $CJDNS_PORT ]; then
207
+        sed -i "s/\"bind\": \"0.0.0.0:.*/\"bind\": \"0.0.0.0:$CJDNS_PORT\",/g" /etc/cjdns/cjdroute.conf
208
+    else
209
+        CJDNS_PORT=$(cat /etc/cjdns/cjdroute.conf | grep '"bind": "0.0.0.0:' | awk -F '"' '{print $4}' | awk -F ':' '{print $2}' | sed -n 1p)
210
+    fi
211
+
212
+    function_check enable_ipv6
213
+    enable_ipv6
214
+
215
+    echo '#!/bin/sh -e' > /etc/init.d/cjdns
216
+    echo '### BEGIN INIT INFO' >> /etc/init.d/cjdns
217
+    echo '# hyperboria.sh - An init script (/etc/init.d/) for cjdns' >> /etc/init.d/cjdns
218
+    echo '# Provides:          cjdroute' >> /etc/init.d/cjdns
219
+    echo '# Required-Start:    $remote_fs $network' >> /etc/init.d/cjdns
220
+    echo '# Required-Stop:     $remote_fs $network' >> /etc/init.d/cjdns
221
+    echo '# Default-Start:     2 3 4 5' >> /etc/init.d/cjdns
222
+    echo '# Default-Stop:      0 1 6' >> /etc/init.d/cjdns
223
+    echo '# Short-Description: Cjdns router' >> /etc/init.d/cjdns
224
+    echo '# Description:       A routing engine designed for security, scalability, speed and ease of use.' >> /etc/init.d/cjdns
225
+    echo '# cjdns git repo:    https://github.com/cjdelisle/cjdns/' >> /etc/init.d/cjdns
226
+    echo '### END INIT INFO' >> /etc/init.d/cjdns
227
+    echo '' >> /etc/init.d/cjdns
228
+    echo 'PROG="cjdroute"' >> /etc/init.d/cjdns
229
+    echo 'GIT_PATH="/etc/cjdns"' >> /etc/init.d/cjdns
230
+    echo 'PROG_PATH="/etc/cjdns"' >> /etc/init.d/cjdns
231
+    echo 'CJDNS_CONFIG="cjdroute.conf"' >> /etc/init.d/cjdns
232
+    echo 'CJDNS_USER="cjdns"' >> /etc/init.d/cjdns
233
+    echo "CJDNS_IP='$CJDNS_IPV6'" >> /etc/init.d/cjdns
234
+    echo '' >> /etc/init.d/cjdns
235
+    echo 'start() {' >> /etc/init.d/cjdns
236
+    echo '     # Start it up with the user cjdns' >> /etc/init.d/cjdns
237
+    echo '     if [ $(pgrep cjdroute | wc -l) != 0 ];' >> /etc/init.d/cjdns
238
+    echo '     then' >> /etc/init.d/cjdns
239
+    echo '         echo "cjdroute is already running. Doing nothing..."' >> /etc/init.d/cjdns
240
+    echo '     else' >> /etc/init.d/cjdns
241
+    echo '         echo " * Starting cjdroute"' >> /etc/init.d/cjdns
242
+    echo '         su -c "$PROG_PATH/$PROG < $PROG_PATH/$CJDNS_CONFIG" - $CJDNS_USER' >> /etc/init.d/cjdns
243
+    echo '         /sbin/ip addr add $CJDNS_IP/8 dev tun0' >> /etc/init.d/cjdns
244
+    echo '         /sbin/ip link set mtu 1312 dev tun0' >> /etc/init.d/cjdns
245
+    echo '         /sbin/ip link set tun0 up' >> /etc/init.d/cjdns
246
+    echo '         /sbin/ip tuntap add mode tun user cjdns dev tun0' >> /etc/init.d/cjdns
247
+    echo '     fi' >> /etc/init.d/cjdns
248
+    echo '}' >> /etc/init.d/cjdns
249
+    echo '' >> /etc/init.d/cjdns
250
+    echo 'stop() {' >> /etc/init.d/cjdns
251
+    echo '' >> /etc/init.d/cjdns
252
+    echo '     if [ $(pgrep cjdroute | wc -l) != 2 ];' >> /etc/init.d/cjdns
253
+    echo '     then' >> /etc/init.d/cjdns
254
+    echo '         echo "cjdns isnt running."' >> /etc/init.d/cjdns
255
+    echo '     else' >> /etc/init.d/cjdns
256
+    echo '         echo "Killing cjdroute"' >> /etc/init.d/cjdns
257
+    echo '         killall cjdroute' >> /etc/init.d/cjdns
258
+    echo '     fi' >> /etc/init.d/cjdns
259
+    echo '}' >> /etc/init.d/cjdns
260
+    echo '' >> /etc/init.d/cjdns
261
+    echo 'status() {' >> /etc/init.d/cjdns
262
+    echo '     if [ $(pgrep cjdroute | wc -l) != 0 ];' >> /etc/init.d/cjdns
263
+    echo '     then' >> /etc/init.d/cjdns
264
+    echo '         echo "Cjdns is running"' >> /etc/init.d/cjdns
265
+    echo '     else' >> /etc/init.d/cjdns
266
+    echo '         echo "Cjdns is not running"' >> /etc/init.d/cjdns
267
+    echo '     fi' >> /etc/init.d/cjdns
268
+    echo '}' >> /etc/init.d/cjdns
269
+    echo '' >> /etc/init.d/cjdns
270
+    echo ' update() {' >> /etc/init.d/cjdns
271
+    echo '     cd $GIT_PATH' >> /etc/init.d/cjdns
272
+    echo '     echo "Updating..."' >> /etc/init.d/cjdns
273
+    echo '     git pull' >> /etc/init.d/cjdns
274
+    echo '     ./do' >> /etc/init.d/cjdns
275
+    echo '}' >> /etc/init.d/cjdns
276
+    echo '' >> /etc/init.d/cjdns
277
+    echo '## Check to see if we are running as root first.' >> /etc/init.d/cjdns
278
+    echo 'if [ "$(id -u)" != "0" ]; then' >> /etc/init.d/cjdns
279
+    echo '    echo "This script must be run as root" 1>&2' >> /etc/init.d/cjdns
280
+    echo '    exit 1' >> /etc/init.d/cjdns
281
+    echo 'fi' >> /etc/init.d/cjdns
282
+    echo '' >> /etc/init.d/cjdns
283
+    echo 'case $1 in' >> /etc/init.d/cjdns
284
+    echo '     start)' >> /etc/init.d/cjdns
285
+    echo '         start' >> /etc/init.d/cjdns
286
+    echo '         exit 0' >> /etc/init.d/cjdns
287
+    echo '     ;;' >> /etc/init.d/cjdns
288
+    echo '     stop)' >> /etc/init.d/cjdns
289
+    echo '         stop' >> /etc/init.d/cjdns
290
+    echo '         exit 0' >> /etc/init.d/cjdns
291
+    echo '     ;;' >> /etc/init.d/cjdns
292
+    echo '     reload|restart|force-reload)' >> /etc/init.d/cjdns
293
+    echo '         stop' >> /etc/init.d/cjdns
294
+    echo '         sleep 1' >> /etc/init.d/cjdns
295
+    echo '         start' >> /etc/init.d/cjdns
296
+    echo '         exit 0' >> /etc/init.d/cjdns
297
+    echo '     ;;' >> /etc/init.d/cjdns
298
+    echo '     status)' >> /etc/init.d/cjdns
299
+    echo '         status' >> /etc/init.d/cjdns
300
+    echo '         exit 0' >> /etc/init.d/cjdns
301
+    echo '     ;;' >> /etc/init.d/cjdns
302
+    echo '     update|upgrade)' >> /etc/init.d/cjdns
303
+    echo '         update' >> /etc/init.d/cjdns
304
+    echo '         stop' >> /etc/init.d/cjdns
305
+    echo '         sleep 2' >> /etc/init.d/cjdns
306
+    echo '         start' >> /etc/init.d/cjdns
307
+    echo '         exit 0' >> /etc/init.d/cjdns
308
+    echo '     ;;' >> /etc/init.d/cjdns
309
+    echo '     **)' >> /etc/init.d/cjdns
310
+    echo '         echo "Usage: $0 (start|stop|restart|status|update)" 1>&2' >> /etc/init.d/cjdns
311
+    echo '         exit 1' >> /etc/init.d/cjdns
312
+    echo '     ;;' >> /etc/init.d/cjdns
313
+    echo 'esac' >> /etc/init.d/cjdns
314
+    chmod +x /etc/init.d/cjdns
315
+    update-rc.d cjdns defaults
316
+    service cjdns start
317
+    if [ ! "$?" = "0" ]; then
318
+        systemctl status cjdns.service
319
+        exit 8260
320
+    fi
321
+
322
+    apt-get -y install radvd
323
+    echo 'interface eth0' > /etc/radvd.conf
324
+    echo '{' >> /etc/radvd.conf
325
+    echo '    AdvSendAdvert on;' >> /etc/radvd.conf
326
+    echo '    prefix fdfc::1/64' >> /etc/radvd.conf
327
+    echo '    {' >> /etc/radvd.conf
328
+    echo '        AdvRouterAddr on;' >> /etc/radvd.conf
329
+    echo '    };' >> /etc/radvd.conf
330
+    echo '};' >> /etc/radvd.conf
331
+    systemctl restart radvd
332
+    if [ ! "$?" = "0" ]; then
333
+        systemctl status radvd.service
334
+        exit 4395
335
+    fi
336
+
337
+    if ! grep -q "# Mesh Networking (cjdns)" /etc/network/interfaces; then
338
+        echo '' >> /etc/network/interfaces
339
+        echo '# Mesh Networking (cjdns)' >> /etc/network/interfaces
340
+        echo 'iface eth0 inet6 static' >> /etc/network/interfaces
341
+        echo '    pre-up modprobe ipv6' >> /etc/network/interfaces
342
+        echo '    address fdfc:0000:0000:0000:0000:0000:0000:0001' >> /etc/network/interfaces
343
+        echo '    netmask 64' >> /etc/network/interfaces
344
+        service network-manager restart
345
+        if [ ! "$?" = "0" ]; then
346
+            systemctl status networking.service
347
+            exit 6949
348
+        fi
349
+    fi
350
+
351
+    ip6tables -A INPUT -p udp --dport $CJDNS_PORT -j ACCEPT
352
+    ip6tables -A INPUT -p tcp --dport $CJDNS_PORT -j ACCEPT
353
+
354
+    function_ckeck save_firewall_settings
355
+    save_firewall_settings
356
+
357
+    if ! grep -q $"Mesh Networking (cjdns)" /home/$MY_USERNAME/README; then
358
+        CURRENT_IP_ADDRESS=$(ip addr show | grep "inet " | sed -n 2p | awk -F ' ' '{print $2}' | awk -F '/' '{print $1}')
359
+
360
+        echo '' >> /home/$MY_USERNAME/README
361
+        echo '' >> /home/$MY_USERNAME/README
362
+        echo $'Mesh Networking (cjdns)' >> /home/$MY_USERNAME/README
363
+        echo '=======================' >> /home/$MY_USERNAME/README
364
+        echo $"cjdns IPv6 address: $CJDNS_IPV6" >> /home/$MY_USERNAME/README
365
+        echo $"cjdns public key: $CJDNS_PUBLIC_KEY" >> /home/$MY_USERNAME/README
366
+        echo $"cjdns private key: $CJDNS_PRIVATE_KEY" >> /home/$MY_USERNAME/README
367
+        echo $"cjdns password: $CJDNS_PASSWORD" >> /home/$MY_USERNAME/README
368
+        echo $"cjdns port: $CJDNS_PORT" >> /home/$MY_USERNAME/README
369
+        echo '' >> /home/$MY_USERNAME/README
370
+        echo $"Forward port $CJDNS_PORT from your internet router to the ${PROJECT_NAME}" >> /home/$MY_USERNAME/README
371
+        echo '' >> /home/$MY_USERNAME/README
372
+        echo $'Below is an example of your connection credentials' >> /home/$MY_USERNAME/README
373
+        echo $'that you can give to other people so they can connect' >> /home/$MY_USERNAME/README
374
+        echo $'to you using your default password' >> /home/$MY_USERNAME/README
375
+        echo $'Adding a unique password for each user is advisable' >> /home/$MY_USERNAME/README
376
+        echo $'so that leaks can be isolated.' >> /home/$MY_USERNAME/README
377
+        echo '' >> /home/$MY_USERNAME/README
378
+        echo "\"$CURRENT_IP_ADDRESS:$CJDNS_PORT\":{\"password\":\"$CJDNS_PASSWORD\",\"publicKey\":\"$CJDNS_PUBLIC_KEY\"}" >> /home/$MY_USERNAME/README
379
+        echo '' >> /home/$MY_USERNAME/README
380
+        echo $'More is not better. 3-5 cjdns peers is good. 30 peers is bad.' >> /home/$MY_USERNAME/README
381
+        echo '' >> /home/$MY_USERNAME/README
382
+        echo $'NEVER USE A PUBLIC PEER. These degrade the network and make it centralized.' >> /home/$MY_USERNAME/README
383
+        echo $'Each node can handle many peers, but no node can handle the entire internet.' >> /home/$MY_USERNAME/README
384
+        echo $'As this network grows any public peer will simply become saturated and' >> /home/$MY_USERNAME/README
385
+        echo $'useless causing issues for the entire network.' >> /home/$MY_USERNAME/README
386
+        echo $'Please report anyone offering you a public peer as they are promoting shared' >> /home/$MY_USERNAME/README
387
+        echo $'passwords which could lead to people pretending to be you. A peering pass' >> /home/$MY_USERNAME/README
388
+        echo $'should not contain someone elses nickname or info but should contain yours' >> /home/$MY_USERNAME/README
389
+        echo $'to ensure it is not shared. It also helps when editing the conf to know who' >> /home/$MY_USERNAME/README
390
+        echo $'each password is for.' >> /home/$MY_USERNAME/README
391
+        echo '' >> /home/$MY_USERNAME/README
392
+        echo $'Possible cjdns destinations of interest:' >> /home/$MY_USERNAME/README
393
+        echo '    http://transitiontech.ca/faq' >> /home/$MY_USERNAME/README
394
+        echo '    http://cjdns.ca/hypeirc.txt' >> /home/$MY_USERNAME/README
395
+        chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/README
396
+        chmod 600 /home/$MY_USERNAME/README
397
+    fi
398
+
399
+    function_check configure_firewall_for_cjdns
400
+    configure_firewall_for_cjdns
401
+
402
+    echo 'mesh_cjdns' >> $COMPLETION_FILE
386 403
 }
387 404
 
388 405
 function mesh_cjdns_tools {
389
-	if grep -Fxq "mesh_cjdns_tools" $COMPLETION_FILE; then
390
-		return
391
-	fi
392
-	if [[ $ENABLE_CJDNS != "yes" ]]; then
393
-		return
394
-	fi
395
-	if [ ! -d /etc/cjdns ]; then
396
-		mesh_cjdns
397
-	fi
398
-
399
-	function_check select_go_version
400
-	select_go_version
401
-
402
-	apt-get -y install golang mercurial
403
-	if [ ! -f ~/.bashrc ]; then
404
-		touch ~/.bashrc
405
-	fi
406
-
407
-	if [ ! -d /home/git ]; then
408
-		# add a gogs user account
409
-		adduser --disabled-login --gecos 'Gogs' git
410
-
411
-		# install Go
412
-		if ! grep -q "export GOPATH=" ~/.bashrc; then
413
-			echo "export GOPATH=$GOPATH" >> ~/.bashrc
414
-		fi
415
-		systemctl set-environment GOPATH=$GOPATH
416
-		if ! grep -q "systemctl set-environment GOPATH=" ~/.bashrc; then
417
-			echo "systemctl set-environment GOPATH=$GOPATH" >> ~/.bashrc
418
-		fi
419
-		if [ ! -d $GOPATH ]; then
420
-			mkdir -p $GOPATH
421
-		fi
422
-	fi
423
-
424
-	if ! grep -q "export GOPATH=" ~/.bashrc; then
425
-		echo "export GOPATH=$GOPATH" >> ~/.bashrc
426
-	fi
427
-	expected_go_path='export PATH=$PATH:'${GOPATH}'/bin'
428
-	export PATH=$PATH:${GOPATH}/bin
429
-	if ! grep -q "$expected_go_path" ~/.bashrc; then
430
-		echo "$expected_go_path" >> ~/.bashrc
431
-	fi
432
-	export PATH=$PATH:$GOPATH/bin
433
-	CJDCMD_REPO2=$(echo "$CJDCMD_REPO" | sed 's|https://||g')
434
-	go get $CJDCMD_REPO2
435
-	if [ ! -f $GOPATH/bin/cjdcmd ]; then
436
-		echo $'cjdcmd was not compiled. Check your golang installation'
437
-		exit 7439
438
-	fi
439
-	cp $GOPATH/bin/cjdcmd /usr/bin
440
-
441
-	# initialise from the cjdns config
442
-	/usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf
443
-
444
-	echo 'mesh_cjdns_tools' >> $COMPLETION_FILE
406
+    if grep -Fxq "mesh_cjdns_tools" $COMPLETION_FILE; then
407
+        return
408
+    fi
409
+    if [[ $ENABLE_CJDNS != "yes" ]]; then
410
+        return
411
+    fi
412
+    if [ ! -d /etc/cjdns ]; then
413
+        mesh_cjdns
414
+    fi
415
+
416
+    function_check select_go_version
417
+    select_go_version
418
+
419
+    apt-get -y install golang mercurial
420
+    if [ ! -f ~/.bashrc ]; then
421
+        touch ~/.bashrc
422
+    fi
423
+
424
+    if [ ! -d /home/git ]; then
425
+        # add a gogs user account
426
+        adduser --disabled-login --gecos 'Gogs' git
427
+
428
+        # install Go
429
+        if ! grep -q "export GOPATH=" ~/.bashrc; then
430
+            echo "export GOPATH=$GOPATH" >> ~/.bashrc
431
+        fi
432
+        systemctl set-environment GOPATH=$GOPATH
433
+        if ! grep -q "systemctl set-environment GOPATH=" ~/.bashrc; then
434
+            echo "systemctl set-environment GOPATH=$GOPATH" >> ~/.bashrc
435
+        fi
436
+        if [ ! -d $GOPATH ]; then
437
+            mkdir -p $GOPATH
438
+        fi
439
+    fi
440
+
441
+    if ! grep -q "export GOPATH=" ~/.bashrc; then
442
+        echo "export GOPATH=$GOPATH" >> ~/.bashrc
443
+    fi
444
+    expected_go_path='export PATH=$PATH:'${GOPATH}'/bin'
445
+    export PATH=$PATH:${GOPATH}/bin
446
+    if ! grep -q "$expected_go_path" ~/.bashrc; then
447
+        echo "$expected_go_path" >> ~/.bashrc
448
+    fi
449
+    export PATH=$PATH:$GOPATH/bin
450
+    CJDCMD_REPO2=$(echo "$CJDCMD_REPO" | sed 's|https://||g')
451
+    go get $CJDCMD_REPO2
452
+    if [ ! -f $GOPATH/bin/cjdcmd ]; then
453
+        echo $'cjdcmd was not compiled. Check your golang installation'
454
+        exit 7439
455
+    fi
456
+    cp $GOPATH/bin/cjdcmd /usr/bin
457
+
458
+    # initialise from the cjdns config
459
+    /usr/bin/cjdcmd cjdnsadmin -file /etc/cjdns/cjdroute.conf
460
+
461
+    echo 'mesh_cjdns_tools' >> $COMPLETION_FILE
445 462
 }
446 463
 
447 464
 # NOTE: deliberately no exit 0

+ 21
- 0
src/freedombone-app-dlna View File

@@ -28,6 +28,27 @@
28 28
 # You should have received a copy of the GNU Affero General Public License
29 29
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
30 30
 
31
+function configure_firewall_for_dlna {
32
+	if grep -Fxq "configure_firewall_for_dlna" $COMPLETION_FILE; then
33
+		return
34
+	fi
35
+	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
36
+		# docker does its own firewalling
37
+		return
38
+	fi
39
+	if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" ]]; then
40
+		return
41
+	fi
42
+	iptables -A INPUT -p udp --dport 1900 -j ACCEPT
43
+	iptables -A INPUT -p tcp --dport 8200 -j ACCEPT
44
+	function_check save_firewall_settings
45
+	save_firewall_settings
46
+
47
+	OPEN_PORTS+=('DLNA     1900')
48
+	OPEN_PORTS+=('DLNA     8200')
49
+	echo 'configure_firewall_for_dlna' >> $COMPLETION_FILE
50
+}
51
+
31 52
 function install_dlna_server {
32 53
 	if grep -Fxq "install_dlna_server" $COMPLETION_FILE; then
33 54
 		return

+ 28
- 0
src/freedombone-app-email View File

@@ -78,6 +78,34 @@ GPGIT_COMMIT='583dc76119f19420f8a33f606744faa7c8922738'
78 78
 # refresh gpg keys every few hours
79 79
 REFRESH_GPG_KEYS_HOURS=2
80 80
 
81
+function configure_firewall_for_email {
82
+	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" || $SYSTEM_TYPE == "$VARIANT_NONMAILBOX" ]]; then
83
+		return
84
+	fi
85
+	if grep -Fxq "configure_firewall_for_email" $COMPLETION_FILE; then
86
+		return
87
+	fi
88
+	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
89
+		# docker does its own firewalling
90
+		return
91
+	fi
92
+	if [[ $ONION_ONLY != "no" ]]; then
93
+		return
94
+	fi
95
+	iptables -A INPUT -p tcp --dport 25 -j ACCEPT
96
+	iptables -A INPUT -p tcp --dport 587 -j ACCEPT
97
+	iptables -A INPUT -p tcp --dport 465 -j ACCEPT
98
+	iptables -A INPUT -p tcp --dport 993 -j ACCEPT
99
+	function_check save_firewall_settings
100
+	save_firewall_settings
101
+
102
+	OPEN_PORTS+=('Email    25')
103
+	OPEN_PORTS+=('Email    587')
104
+	OPEN_PORTS+=('Email    465')
105
+	OPEN_PORTS+=('Email    993')
106
+	echo 'configure_firewall_for_email' >> $COMPLETION_FILE
107
+}
108
+
81 109
 function encrypt_incoming_email {
82 110
 	# encrypts incoming mail using your GPG public key
83 111
 	# so even if an attacker gains access to the data at rest they still need

+ 21
- 0
src/freedombone-app-ipfs View File

@@ -32,6 +32,24 @@ IPFS_GO_REPO="https://github.com/ipfs/go-ipfs"
32 32
 IPFS_COMMIT='20b06a4cbce8884f5b194da6e98cb11f2c77f166'
33 33
 IPFS_PORT=4001
34 34
 
35
+function configure_firewall_for_ipfs {
36
+	if [[ $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then
37
+		return
38
+	fi
39
+	if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then
40
+		return
41
+	fi
42
+	if [[ $ONION_ONLY != "no" ]]; then
43
+		return
44
+	fi
45
+	iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT
46
+	function_check save_firewall_settings
47
+	save_firewall_settings
48
+
49
+	OPEN_PORTS+=("IPFS     $IPFS_PORT")
50
+	echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE
51
+}
52
+
35 53
 function install_ipfs {
36 54
 	if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" ]]; then
37 55
 		return
@@ -163,5 +181,8 @@ function install_ipfs {
163 181
 		rm /tmp/ipfsid
164 182
 	fi
165 183
 
184
+	function_check configure_firewall_for_ipfs
185
+	configure_firewall_for_ipfs
186
+
166 187
 	echo 'install_ipfs' >> $COMPLETION_FILE
167 188
 }

+ 23
- 0
src/freedombone-app-irc View File

@@ -34,6 +34,29 @@ IRC_ONION_PORT=6697
34 34
 # An optional password to log into IRC. This applies to all users
35 35
 IRC_PASSWORD=
36 36
 
37
+function configure_firewall_for_irc {
38
+	if [ ! -d /etc/ngircd ]; then
39
+		return
40
+	fi
41
+	if grep -Fxq "configure_firewall_for_irc" $COMPLETION_FILE; then
42
+		return
43
+	fi
44
+	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
45
+		# docker does its own firewalling
46
+		return
47
+	fi
48
+	if [[ $ONION_ONLY != "no" ]]; then
49
+		return
50
+	fi
51
+	iptables -A INPUT -p tcp --dport $IRC_PORT  -j ACCEPT
52
+	iptables -I INPUT -p tcp --dport 1024:65535 --sport $IRC_PORT -j ACCEPT
53
+	function_check save_firewall_settings
54
+	save_firewall_settings
55
+
56
+	OPEN_PORTS+=("IRC      $IRC_PORT")
57
+	echo 'configure_firewall_for_irc' >> $COMPLETION_FILE
58
+}
59
+
37 60
 function install_irc_server {
38 61
 	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
39 62
 		return

+ 19
- 0
src/freedombone-app-mumble View File

@@ -53,6 +53,25 @@ function get_voip_server_password {
53 53
 	fi
54 54
 }
55 55
 
56
+function configure_firewall_for_voip {
57
+	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
58
+		return
59
+	fi
60
+	if grep -Fxq "configure_firewall_for_voip" $COMPLETION_FILE; then
61
+		return
62
+	fi
63
+	if [[ $ONION_ONLY != "no" ]]; then
64
+		return
65
+	fi
66
+	iptables -A INPUT -p udp --dport $VOIP_PORT -j ACCEPT
67
+	iptables -A INPUT -p tcp --dport $VOIP_PORT -j ACCEPT
68
+	function_check save_firewall_settings
69
+	save_firewall_settings
70
+
71
+	OPEN_PORTS+=("Mumble   $VOIP_PORT")
72
+	echo 'configure_firewall_for_voip' >> $COMPLETION_FILE
73
+}
74
+
56 75
 function install_mumble {
57 76
 	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
58 77
 		return

+ 44
- 0
src/freedombone-app-sip View File

@@ -35,6 +35,50 @@ VOIP_TURN_PORT=3478
35 35
 VOIP_TURN_TLS_PORT=5349
36 36
 VOIP_TURN_NONCE=
37 37
 
38
+function configure_firewall_for_voip_turn {
39
+	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
40
+		return
41
+	fi
42
+	if grep -Fxq "configure_firewall_for_voip_turn" $COMPLETION_FILE; then
43
+		return
44
+	fi
45
+	if [[ $ONION_ONLY != "no" ]]; then
46
+		return
47
+	fi
48
+	iptables -A INPUT -p udp --dport $VOIP_TURN_PORT -j ACCEPT
49
+	iptables -A INPUT -p tcp --dport $VOIP_TURN_PORT -j ACCEPT
50
+	iptables -A INPUT -p tcp --dport $VOIP_TURN_TLS_PORT -j ACCEPT
51
+	function_check save_firewall_settings
52
+	save_firewall_settings
53
+
54
+	OPEN_PORTS+=("TURN     $VOIP_TURN_PORT")
55
+	OPEN_PORTS+=("TURN TLS $VOIP_TURN_TLS_PORT")
56
+	echo 'configure_firewall_for_voip_turn' >> $COMPLETION_FILE
57
+}
58
+
59
+
60
+function configure_firewall_for_sip4 {
61
+	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
62
+		return
63
+	fi
64
+	if grep -Fxq "configure_firewall_for_sip4" $COMPLETION_FILE; then
65
+		return
66
+	fi
67
+	if [[ $ONION_ONLY != "no" ]]; then
68
+		return
69
+	fi
70
+	iptables -A INPUT -p udp --dport $SIP_PORT -j ACCEPT
71
+	iptables -A INPUT -p tcp --dport $SIP_PORT -j ACCEPT
72
+	iptables -A INPUT -p udp --dport $SIP_TLS_PORT -j ACCEPT
73
+	iptables -A INPUT -p tcp --dport $SIP_TLS_PORT -j ACCEPT
74
+	function_check save_firewall_settings
75
+	save_firewall_settings
76
+
77
+	OPEN_PORTS+=("SIP      $SIP_PORT")
78
+	OPEN_PORTS+=("SIP TLS  $SIP_TLS_PORT")
79
+	echo 'configure_firewall_for_sip4' >> $COMPLETION_FILE
80
+}
81
+
38 82
 function get_sip_server_password {
39 83
 	if [ -f /home/$MY_USERNAME/README ]; then
40 84
 		if grep -q "SIP server password" /home/$MY_USERNAME/README; then

+ 13
- 0
src/freedombone-app-syncthing View File

@@ -37,6 +37,19 @@ SYNCTHING_PORT=22000
37 37
 SYNCTHING_SHARED_DATA=/var/lib/syncthing/SyncShared
38 38
 SYNCTHING_USER_IDS_FILE='.syncthingids'
39 39
 
40
+function configure_firewall_for_syncthing {
41
+	if grep -Fxq "configure_firewall_for_syncthing" $COMPLETION_FILE; then
42
+		return
43
+	fi
44
+	iptables -A INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
45
+	iptables -A INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
46
+	function_check save_firewall_settings
47
+	save_firewall_settings
48
+
49
+	OPEN_PORTS+=("Syncthing $SYNCTHING_PORT")
50
+	echo 'configure_firewall_for_syncthing' >> $COMPLETION_FILE
51
+}
52
+
40 53
 function install_syncthing {
41 54
 	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
42 55
 		return

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

@@ -44,6 +44,25 @@ TOXIC_REPO="https://github.com/Tox/toxic"
44 44
 TOXIC_COMMIT='cf16849b374e484a33a4dffa3dfb937b59d537f2'
45 45
 TOXIC_FILE=/usr/local/bin/toxic
46 46
 
47
+function configure_firewall_for_tox {
48
+	if grep -Fxq "configure_firewall_for_tox" $COMPLETION_FILE; then
49
+		return
50
+	fi
51
+	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
52
+		# docker does its own firewalling
53
+		return
54
+	fi
55
+	if [[ $ONION_ONLY != "no" ]]; then
56
+		return
57
+	fi
58
+	iptables -A INPUT -p tcp --dport $TOX_PORT -j ACCEPT
59
+	function_check save_firewall_settings
60
+	save_firewall_settings
61
+
62
+	OPEN_PORTS+=("Tox      $TOX_PORT")
63
+	echo 'configure_firewall_for_tox' >> $COMPLETION_FILE
64
+}
65
+
47 66
 function tox_avahi {
48 67
 	if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
49 68
 		return

+ 26
- 0
src/freedombone-app-xmpp View File

@@ -35,6 +35,32 @@ XMPP_PASSWORD=
35 35
 XMPP_CIPHERS='"EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA256:EECDH:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA128-SHA:AES128-SHA"'
36 36
 XMPP_ECC_CURVE='"secp384r1"'
37 37
 
38
+function configure_firewall_for_xmpp {
39
+	if [ ! -d /etc/prosody ]; then
40
+		return
41
+	fi
42
+	if grep -Fxq "configure_firewall_for_xmpp" $COMPLETION_FILE; then
43
+		return
44
+	fi
45
+	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
46
+		# docker does its own firewalling
47
+		return
48
+	fi
49
+	if [[ $ONION_ONLY != "no" ]]; then
50
+		return
51
+	fi
52
+	iptables -A INPUT -p tcp --dport 5222:5223 -j ACCEPT
53
+	iptables -A INPUT -p tcp --dport 5269 -j ACCEPT
54
+	iptables -A INPUT -p tcp --dport 5280:5281 -j ACCEPT
55
+	function_check save_firewall_settings
56
+	save_firewall_settings
57
+
58
+	OPEN_PORTS+=('XMPP     5222-5223')
59
+	OPEN_PORTS+=('XMPP     5269')
60
+	OPEN_PORTS+=('XMPP     5280-5281')
61
+	echo 'configure_firewall_for_xmpp' >> $COMPLETION_FILE
62
+}
63
+
38 64
 function update_prosody_modules {
39 65
 	if [ ! -d $INSTALL_DIR/prosody-modules ]; then
40 66
 		return

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

@@ -45,6 +45,26 @@ ZERONET_DEFAULT_MAIL_TAGLINE="Mail for the Mesh"
45 45
 ZERONET_ID_REPO="https://github.com/HelloZeroNet/ZeroID"
46 46
 ZERONET_ID_COMMIT='ccf14fdc96fa9cdb2ddd8a7ab283a8e17a4f234b'
47 47
 
48
+function configure_firewall_for_zeronet {
49
+	if grep -Fxq "configure_firewall_for_zeronet" $COMPLETION_FILE; then
50
+		return
51
+	fi
52
+	if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
53
+		return
54
+	fi
55
+	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT
56
+	iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT
57
+	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT
58
+	iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $TRACKER_PORT -j ACCEPT
59
+	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport 1900 -j ACCEPT
60
+	function_check save_firewall_settings
61
+	save_firewall_settings
62
+
63
+	OPEN_PORTS+=("ZeroNet  $ZERONET_PORT")
64
+	OPEN_PORTS+=("Tracker  $TRACKER_PORT")
65
+	echo 'configure_firewall_for_zeronet' >> $COMPLETION_FILE
66
+}
67
+
48 68
 function install_zeronet_blog {
49 69
 	if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
50 70
 		return

+ 0
- 273
src/freedombone-utils-firewall View File

@@ -103,100 +103,6 @@ function configure_firewall_ping {
103 103
 	echo 'configure_firewall_ping' >> $COMPLETION_FILE
104 104
 }
105 105
 
106
-function configure_firewall_for_voip {
107
-	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
108
-		return
109
-	fi
110
-	if grep -Fxq "configure_firewall_for_voip" $COMPLETION_FILE; then
111
-		return
112
-	fi
113
-	if [[ $ONION_ONLY != "no" ]]; then
114
-		return
115
-	fi
116
-	iptables -A INPUT -p udp --dport $VOIP_PORT -j ACCEPT
117
-	iptables -A INPUT -p tcp --dport $VOIP_PORT -j ACCEPT
118
-	function_check save_firewall_settings
119
-	save_firewall_settings
120
-
121
-	OPEN_PORTS+=("Mumble   $VOIP_PORT")
122
-	echo 'configure_firewall_for_voip' >> $COMPLETION_FILE
123
-}
124
-
125
-function configure_firewall_for_syncthing {
126
-	if grep -Fxq "configure_firewall_for_syncthing" $COMPLETION_FILE; then
127
-		return
128
-	fi
129
-	iptables -A INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
130
-	iptables -A INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
131
-	function_check save_firewall_settings
132
-	save_firewall_settings
133
-
134
-	OPEN_PORTS+=("Syncthing $SYNCTHING_PORT")
135
-	echo 'configure_firewall_for_syncthing' >> $COMPLETION_FILE
136
-}
137
-
138
-function configure_firewall_for_voip_turn {
139
-	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
140
-		return
141
-	fi
142
-	if grep -Fxq "configure_firewall_for_voip_turn" $COMPLETION_FILE; then
143
-		return
144
-	fi
145
-	if [[ $ONION_ONLY != "no" ]]; then
146
-		return
147
-	fi
148
-	iptables -A INPUT -p udp --dport $VOIP_TURN_PORT -j ACCEPT
149
-	iptables -A INPUT -p tcp --dport $VOIP_TURN_PORT -j ACCEPT
150
-	iptables -A INPUT -p tcp --dport $VOIP_TURN_TLS_PORT -j ACCEPT
151
-	function_check save_firewall_settings
152
-	save_firewall_settings
153
-
154
-	OPEN_PORTS+=("TURN     $VOIP_TURN_PORT")
155
-	OPEN_PORTS+=("TURN TLS $VOIP_TURN_TLS_PORT")
156
-	echo 'configure_firewall_for_voip_turn' >> $COMPLETION_FILE
157
-}
158
-
159
-
160
-function configure_firewall_for_sip4 {
161
-	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" ]]; then
162
-		return
163
-	fi
164
-	if grep -Fxq "configure_firewall_for_sip4" $COMPLETION_FILE; then
165
-		return
166
-	fi
167
-	if [[ $ONION_ONLY != "no" ]]; then
168
-		return
169
-	fi
170
-	iptables -A INPUT -p udp --dport $SIP_PORT -j ACCEPT
171
-	iptables -A INPUT -p tcp --dport $SIP_PORT -j ACCEPT
172
-	iptables -A INPUT -p udp --dport $SIP_TLS_PORT -j ACCEPT
173
-	iptables -A INPUT -p tcp --dport $SIP_TLS_PORT -j ACCEPT
174
-	function_check save_firewall_settings
175
-	save_firewall_settings
176
-
177
-	OPEN_PORTS+=("SIP      $SIP_PORT")
178
-	OPEN_PORTS+=("SIP TLS  $SIP_TLS_PORT")
179
-	echo 'configure_firewall_for_sip4' >> $COMPLETION_FILE
180
-}
181
-
182
-function configure_firewall_for_ipfs {
183
-	if [[ $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" ]]; then
184
-		return
185
-	fi
186
-	if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then
187
-		return
188
-	fi
189
-	if [[ $ONION_ONLY != "no" ]]; then
190
-		return
191
-	fi
192
-	iptables -A INPUT -p tcp --dport $IPFS_PORT -j ACCEPT
193
-	function_check save_firewall_settings
194
-	save_firewall_settings
195
-
196
-	OPEN_PORTS+=("IPFS     $IPFS_PORT")
197
-	echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE
198
-}
199
-
200 106
 function configure_firewall_for_avahi {
201 107
 	if grep -Fxq "configure_firewall_for_avahi" $COMPLETION_FILE; then
202 108
 		return
@@ -212,89 +118,6 @@ function configure_firewall_for_avahi {
212 118
 	echo 'configure_firewall_for_avahi' >> $COMPLETION_FILE
213 119
 }
214 120
 
215
-function configure_firewall_for_cjdns {
216
-	if grep -Fxq "configure_firewall_for_cjdns" $COMPLETION_FILE; then
217
-		return
218
-	fi
219
-	if [[ $ENABLE_CJDNS != "yes" ]]; then
220
-		return
221
-	fi
222
-	ip6tables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
223
-	ip6tables -A FORWARD -i tun0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
224
-	function_check save_firewall_settings
225
-	save_firewall_settings
226
-	echo 'configure_firewall_for_cjdns' >> $COMPLETION_FILE
227
-}
228
-
229
-function configure_firewall_for_batman {
230
-	if grep -Fxq "configure_firewall_for_batman" $COMPLETION_FILE; then
231
-		return
232
-	fi
233
-	if [[ $ENABLE_BATMAN != "yes" ]]; then
234
-		return
235
-	fi
236
-
237
-	function_check save_firewall_settings
238
-	save_firewall_settings
239
-	echo 'configure_firewall_for_batman' >> $COMPLETION_FILE
240
-}
241
-
242
-function configure_firewall_for_babel {
243
-	if grep -Fxq "configure_firewall_for_babel" $COMPLETION_FILE; then
244
-		return
245
-	fi
246
-	if [[ $ENABLE_BABEL != "yes" ]]; then
247
-		return
248
-	fi
249
-	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $BABEL_PORT -j ACCEPT
250
-	function_check save_firewall_settings
251
-	save_firewall_settings
252
-
253
-	OPEN_PORTS+=("Babel    $BABEL_PORT")
254
-	echo 'configure_firewall_for_babel' >> $COMPLETION_FILE
255
-}
256
-
257
-function configure_firewall_for_zeronet {
258
-	if grep -Fxq "configure_firewall_for_zeronet" $COMPLETION_FILE; then
259
-		return
260
-	fi
261
-	if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
262
-		return
263
-	fi
264
-	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $ZERONET_PORT -j ACCEPT
265
-	iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $ZERONET_PORT -j ACCEPT
266
-	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport $TRACKER_PORT -j ACCEPT
267
-	iptables -A INPUT -i $WIFI_INTERFACE -p tcp --dport $TRACKER_PORT -j ACCEPT
268
-	iptables -A INPUT -i $WIFI_INTERFACE -p udp --dport 1900 -j ACCEPT
269
-	function_check save_firewall_settings
270
-	save_firewall_settings
271
-
272
-	OPEN_PORTS+=("ZeroNet  $ZERONET_PORT")
273
-	OPEN_PORTS+=("Tracker  $TRACKER_PORT")
274
-	echo 'configure_firewall_for_zeronet' >> $COMPLETION_FILE
275
-}
276
-
277
-function configure_firewall_for_dlna {
278
-	if grep -Fxq "configure_firewall_for_dlna" $COMPLETION_FILE; then
279
-		return
280
-	fi
281
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
282
-		# docker does its own firewalling
283
-		return
284
-	fi
285
-	if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" ]]; then
286
-		return
287
-	fi
288
-	iptables -A INPUT -p udp --dport 1900 -j ACCEPT
289
-	iptables -A INPUT -p tcp --dport 8200 -j ACCEPT
290
-	function_check save_firewall_settings
291
-	save_firewall_settings
292
-
293
-	OPEN_PORTS+=('DLNA     1900')
294
-	OPEN_PORTS+=('DLNA     8200')
295
-	echo 'configure_firewall_for_dlna' >> $COMPLETION_FILE
296
-}
297
-
298 121
 function configure_firewall_for_dns {
299 122
 	if grep -Fxq "configure_firewall_for_dns" $COMPLETION_FILE; then
300 123
 		return
@@ -309,55 +132,6 @@ function configure_firewall_for_dns {
309 132
 	echo 'configure_firewall_for_dns' >> $COMPLETION_FILE
310 133
 }
311 134
 
312
-function configure_firewall_for_xmpp {
313
-	if [ ! -d /etc/prosody ]; then
314
-		return
315
-	fi
316
-	if grep -Fxq "configure_firewall_for_xmpp" $COMPLETION_FILE; then
317
-		return
318
-	fi
319
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
320
-		# docker does its own firewalling
321
-		return
322
-	fi
323
-	if [[ $ONION_ONLY != "no" ]]; then
324
-		return
325
-	fi
326
-	iptables -A INPUT -p tcp --dport 5222:5223 -j ACCEPT
327
-	iptables -A INPUT -p tcp --dport 5269 -j ACCEPT
328
-	iptables -A INPUT -p tcp --dport 5280:5281 -j ACCEPT
329
-	function_check save_firewall_settings
330
-	save_firewall_settings
331
-
332
-	OPEN_PORTS+=('XMPP     5222-5223')
333
-	OPEN_PORTS+=('XMPP     5269')
334
-	OPEN_PORTS+=('XMPP     5280-5281')
335
-	echo 'configure_firewall_for_xmpp' >> $COMPLETION_FILE
336
-}
337
-
338
-function configure_firewall_for_irc {
339
-	if [ ! -d /etc/ngircd ]; then
340
-		return
341
-	fi
342
-	if grep -Fxq "configure_firewall_for_irc" $COMPLETION_FILE; then
343
-		return
344
-	fi
345
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
346
-		# docker does its own firewalling
347
-		return
348
-	fi
349
-	if [[ $ONION_ONLY != "no" ]]; then
350
-		return
351
-	fi
352
-	iptables -A INPUT -p tcp --dport $IRC_PORT  -j ACCEPT
353
-	iptables -I INPUT -p tcp --dport 1024:65535 --sport $IRC_PORT -j ACCEPT
354
-	function_check save_firewall_settings
355
-	save_firewall_settings
356
-
357
-	OPEN_PORTS+=("IRC      $IRC_PORT")
358
-	echo 'configure_firewall_for_irc' >> $COMPLETION_FILE
359
-}
360
-
361 135
 function configure_firewall_for_web_access {
362 136
 	if grep -Fxq "configure_firewall_for_web_access" $COMPLETION_FILE; then
363 137
 		return
@@ -398,25 +172,6 @@ function configure_firewall_for_web_server {
398 172
 	echo 'configure_firewall_for_web_server' >> $COMPLETION_FILE
399 173
 }
400 174
 
401
-function configure_firewall_for_tox {
402
-	if grep -Fxq "configure_firewall_for_tox" $COMPLETION_FILE; then
403
-		return
404
-	fi
405
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
406
-		# docker does its own firewalling
407
-		return
408
-	fi
409
-	if [[ $ONION_ONLY != "no" ]]; then
410
-		return
411
-	fi
412
-	iptables -A INPUT -p tcp --dport $TOX_PORT -j ACCEPT
413
-	function_check save_firewall_settings
414
-	save_firewall_settings
415
-
416
-	OPEN_PORTS+=("Tox      $TOX_PORT")
417
-	echo 'configure_firewall_for_tox' >> $COMPLETION_FILE
418
-}
419
-
420 175
 function configure_firewall_for_ssh {
421 176
 	if grep -Fxq "configure_firewall_for_ssh" $COMPLETION_FILE; then
422 177
 		return
@@ -453,34 +208,6 @@ function configure_firewall_for_git {
453 208
 	echo 'configure_firewall_for_git' >> $COMPLETION_FILE
454 209
 }
455 210
 
456
-function configure_firewall_for_email {
457
-	if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" || $SYSTEM_TYPE == "$VARIANT_NONMAILBOX" ]]; then
458
-		return
459
-	fi
460
-	if grep -Fxq "configure_firewall_for_email" $COMPLETION_FILE; then
461
-		return
462
-	fi
463
-	if [[ $INSTALLED_WITHIN_DOCKER == "yes" ]]; then
464
-		# docker does its own firewalling
465
-		return
466
-	fi
467
-	if [[ $ONION_ONLY != "no" ]]; then
468
-		return
469
-	fi
470
-	iptables -A INPUT -p tcp --dport 25 -j ACCEPT
471
-	iptables -A INPUT -p tcp --dport 587 -j ACCEPT
472
-	iptables -A INPUT -p tcp --dport 465 -j ACCEPT
473
-	iptables -A INPUT -p tcp --dport 993 -j ACCEPT
474
-	function_check save_firewall_settings
475
-	save_firewall_settings
476
-
477
-	OPEN_PORTS+=('Email    25')
478
-	OPEN_PORTS+=('Email    587')
479
-	OPEN_PORTS+=('Email    465')
480
-	OPEN_PORTS+=('Email    993')
481
-	echo 'configure_firewall_for_email' >> $COMPLETION_FILE
482
-}
483
-
484 211
 function configure_internet_protocol {
485 212
 	if grep -Fxq "configure_internet_protocol" $COMPLETION_FILE; then
486 213
 		return