Procházet zdrojové kódy

Handle client installs of zeronet

Bob Mottram před 9 roky
rodič
revize
2d7007c191
3 změnil soubory, kde provedl 46 přidání a 8 odebrání
  1. 5
    2
      src/freedombone-client
  2. 35
    4
      src/freedombone-mesh
  3. 6
    2
      src/zeronetavahi

+ 5
- 2
src/freedombone-client Zobrazit soubor

48
 SSH_HOST_KEY_ALGORITHMS="ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-ed25519,ssh-rsa"
48
 SSH_HOST_KEY_ALGORITHMS="ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-ed25519,ssh-rsa"
49
 
49
 
50
 ZERONET_PORT=15441
50
 ZERONET_PORT=15441
51
+TRACKER_PORT=51413
51
 
52
 
52
 # see https://stribika.github.io/2015/01/04/secure-secure-shell.html
53
 # see https://stribika.github.io/2015/01/04/secure-secure-shell.html
53
 function ssh_remove_small_moduli {
54
 function ssh_remove_small_moduli {
143
   echo '        return' >> $babel_script
144
   echo '        return' >> $babel_script
144
   echo '    fi' >> $batman_script
145
   echo '    fi' >> $batman_script
145
   echo '    # install avahi' >> $babel_script
146
   echo '    # install avahi' >> $babel_script
146
-  echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd' >> $babel_script
147
+  echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd transmission-daemon' >> $babel_script
147
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
148
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
148
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
149
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
149
   echo '    if [ -f /bin/systemctl ]; then' >> $babel_script
150
   echo '    if [ -f /bin/systemctl ]; then' >> $babel_script
228
   echo '' >> $batman_script
229
   echo '' >> $batman_script
229
   echo 'if [[ $1 == "start" ]]; then' >> $batman_script
230
   echo 'if [[ $1 == "start" ]]; then' >> $batman_script
230
   echo '    # install avahi' >> $batman_script
231
   echo '    # install avahi' >> $batman_script
231
-  echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd' >> $batman_script
232
+  echo '    apt-get -y install avahi-utils avahi-autoipd avahi-daemon avahi-dnsconfd transmission-daemon' >> $batman_script
232
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
233
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
233
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
234
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
234
   echo '    sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
235
   echo '    sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
339
   echo '    iptables -A INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
340
   echo '    iptables -A INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
340
   echo "    iptables -A INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
341
   echo "    iptables -A INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
341
   echo "    iptables -A INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
342
   echo "    iptables -A INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
343
+  echo "    iptables -A INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $batman_script
342
   echo '' >> $batman_script
344
   echo '' >> $batman_script
343
   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
345
   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
344
   echo '        systemctl restart avahi-daemon' >> $batman_script
346
   echo '        systemctl restart avahi-daemon' >> $batman_script
379
   echo '    iptables -D INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
381
   echo '    iptables -D INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
380
   echo "    iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
382
   echo "    iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
381
   echo "    iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
383
   echo "    iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
384
+  echo "    iptables -D INPUT -p udp --dport $TRACKER_PORT -j ACCEPT" >> $batman_script
382
   echo '' >> $batman_script
385
   echo '' >> $batman_script
383
   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
386
   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
384
   echo '        systemctl restart network-manager' >> $batman_script
387
   echo '        systemctl restart network-manager' >> $batman_script

+ 35
- 4
src/freedombone-mesh Zobrazit soubor

46
 # the freedombone-client script installed
46
 # the freedombone-client script installed
47
 SERVER_INSTALLATION="no"
47
 SERVER_INSTALLATION="no"
48
 
48
 
49
+ZERONET_REPO='https://github.com/bashrc/ZeroNet'
50
+ZERONET_DIR=~/zeronet
51
+ZERONET_URL=http://127.0.0.1:43110
52
+
53
+function install_zeronet {
54
+  sudo apt-get -y install python python-msgpack python-gevent
55
+  sudo apt-get -y install python-pip transmission-daemon
56
+  sudo pip install msgpack-python --upgrade
57
+
58
+  git clone $ZERONET_REPO $ZERONET_DIR
59
+  if [ ! -d $ZERONET_DIR ]; then
60
+      exit 56823
61
+  fi
62
+  cd $ZERONET_DIR
63
+  git checkout bashrc/bootstrap-file
64
+}
65
+
49
 function install_toxcore {
66
 function install_toxcore {
50
     if [ -f /etc/tox-bootstrapd.conf ]; then
67
     if [ -f /etc/tox-bootstrapd.conf ]; then
51
         return
68
         return
237
     if [ ! -f /tmp/meshtype ]; then
254
     if [ ! -f /tmp/meshtype ]; then
238
         install_toxcore
255
         install_toxcore
239
         install_toxid
256
         install_toxid
257
+        install_zeronet
240
         sudo batman start
258
         sudo batman start
241
         if [ ! "$?" = "0" ]; then
259
         if [ ! "$?" = "0" ]; then
242
             exit 2
260
             exit 2
341
 
359
 
342
 echo ''
360
 echo ''
343
 echo 'Choose communication service:'
361
 echo 'Choose communication service:'
344
-echo '    1. VoIP'
345
-echo '    2. Tox Chat'
346
-echo '    3. IRC (WARNING: not secure)'
362
+echo '    1. Web'
363
+echo '    2. VoIP'
364
+echo '    3. Tox Chat'
365
+echo '    4. IRC (WARNING: not secure)'
347
 echo ''
366
 echo ''
348
 
367
 
349
 read peer_index
368
 read peer_index
356
 fi
375
 fi
357
 
376
 
358
 if [[ $peer_index == 1 ]]; then
377
 if [[ $peer_index == 1 ]]; then
378
+    cd ZERONET_DIR
379
+    zeronetavahi
380
+    python zeronet.py &
381
+    if which xdg-open > /dev/null; then
382
+        xdg-open $ZERONET_URL
383
+    elif which gnome-open > /dev/null; then
384
+        gnome-open $ZERONET_URL
385
+    fi
386
+    exit 0
387
+fi
388
+
389
+if [[ $peer_index == 2 ]]; then
359
     if [ -f $MUMBLE_PATH ]; then
390
     if [ -f $MUMBLE_PATH ]; then
360
         echo ''
391
         echo ''
361
         echo 'To setup for the first time click "Add New", then set:'
392
         echo 'To setup for the first time click "Add New", then set:'
373
         exit 5
404
         exit 5
374
     fi
405
     fi
375
 else
406
 else
376
-    if [[ $peer_index == 2 ]]; then
407
+    if [[ $peer_index == 3 ]]; then
377
         run_tox
408
         run_tox
378
     else
409
     else
379
         if [ -f $IRSSI_PATH ]; then
410
         if [ -f $IRSSI_PATH ]; then

+ 6
- 2
src/zeronetavahi Zobrazit soubor

32
 BOOTSTRAP_FILE=/opt/zeronet/bootstrap
32
 BOOTSTRAP_FILE=/opt/zeronet/bootstrap
33
 
33
 
34
 if [ ! -d /opt/zeronet ]; then
34
 if [ ! -d /opt/zeronet ]; then
35
-    exit 0
35
+    if [ -d ~/zeronet ]; then
36
+        BOOTSTRAP_FILE=~/zeronet/bootstrap
37
+    else
38
+        exit 0
39
+    fi
36
 fi
40
 fi
37
 
41
 
38
 if [ ! -d /etc/avahi ]; then
42
 if [ ! -d /etc/avahi ]; then
70
 rm -f $TEMPFILE
74
 rm -f $TEMPFILE
71
 cp -f $BOOTSTRAP_FILE.new $BOOTSTRAP_FILE
75
 cp -f $BOOTSTRAP_FILE.new $BOOTSTRAP_FILE
72
 rm -f $BOOTSTRAP_FILE.new
76
 rm -f $BOOTSTRAP_FILE.new
73
-sudo chown zeronet:zeronet /opt/zeronet/bootstrap
77
+sudo chown zeronet:zeronet $BOOTSTRAP_FILE
74
 
78
 
75
 exit 0
79
 exit 0