|
@@ -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
|