Bläddra i källkod

Handle client installs of zeronet

Bob Mottram 9 år sedan
förälder
incheckning
2d7007c191
3 ändrade filer med 46 tillägg och 8 borttagningar
  1. 5
    2
      src/freedombone-client
  2. 35
    4
      src/freedombone-mesh
  3. 6
    2
      src/zeronetavahi

+ 5
- 2
src/freedombone-client Visa fil

@@ -48,6 +48,7 @@ SSH_KEX="curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256"
48 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 50
 ZERONET_PORT=15441
51
+TRACKER_PORT=51413
51 52
 
52 53
 # see https://stribika.github.io/2015/01/04/secure-secure-shell.html
53 54
 function ssh_remove_small_moduli {
@@ -143,7 +144,7 @@ function mesh_babel {
143 144
   echo '        return' >> $babel_script
144 145
   echo '    fi' >> $batman_script
145 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 148
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
148 149
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $babel_script
149 150
   echo '    if [ -f /bin/systemctl ]; then' >> $babel_script
@@ -228,7 +229,7 @@ function mesh_batman {
228 229
   echo '' >> $batman_script
229 230
   echo 'if [[ $1 == "start" ]]; then' >> $batman_script
230 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 233
   echo '    sed -i "s|#host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
233 234
   echo '    sed -i "s|host-name=.*|host-name=$(hostname)|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
234 235
   echo '    sed -i "s|use-ipv4=.*|use-ipv4=yes|g" /etc/avahi/avahi-daemon.conf' >> $batman_script
@@ -339,6 +340,7 @@ function mesh_batman {
339 340
   echo '    iptables -A INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
340 341
   echo "    iptables -A INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
341 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 344
   echo '' >> $batman_script
343 345
   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
344 346
   echo '        systemctl restart avahi-daemon' >> $batman_script
@@ -379,6 +381,7 @@ function mesh_batman {
379 381
   echo '    iptables -D INPUT -p udp --dport 5354 -j ACCEPT' >> $batman_script
380 382
   echo "    iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT" >> $batman_script
381 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 385
   echo '' >> $batman_script
383 386
   echo '    if [ -f /bin/systemctl ]; then' >> $batman_script
384 387
   echo '        systemctl restart network-manager' >> $batman_script

+ 35
- 4
src/freedombone-mesh Visa fil

@@ -46,6 +46,23 @@ TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
46 46
 # the freedombone-client script installed
47 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 66
 function install_toxcore {
50 67
     if [ -f /etc/tox-bootstrapd.conf ]; then
51 68
         return
@@ -237,6 +254,7 @@ if [[ $SERVER_INSTALLATION == "no" ]]; then
237 254
     if [ ! -f /tmp/meshtype ]; then
238 255
         install_toxcore
239 256
         install_toxid
257
+        install_zeronet
240 258
         sudo batman start
241 259
         if [ ! "$?" = "0" ]; then
242 260
             exit 2
@@ -341,9 +359,10 @@ fi
341 359
 
342 360
 echo ''
343 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 366
 echo ''
348 367
 
349 368
 read peer_index
@@ -356,6 +375,18 @@ if [ ! $peer_index ]; then
356 375
 fi
357 376
 
358 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 390
     if [ -f $MUMBLE_PATH ]; then
360 391
         echo ''
361 392
         echo 'To setup for the first time click "Add New", then set:'
@@ -373,7 +404,7 @@ if [[ $peer_index == 1 ]]; then
373 404
         exit 5
374 405
     fi
375 406
 else
376
-    if [[ $peer_index == 2 ]]; then
407
+    if [[ $peer_index == 3 ]]; then
377 408
         run_tox
378 409
     else
379 410
         if [ -f $IRSSI_PATH ]; then

+ 6
- 2
src/zeronetavahi Visa fil

@@ -32,7 +32,11 @@ TRACKER_PORT=51413
32 32
 BOOTSTRAP_FILE=/opt/zeronet/bootstrap
33 33
 
34 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 40
 fi
37 41
 
38 42
 if [ ! -d /etc/avahi ]; then
@@ -70,6 +74,6 @@ done < "$TEMPFILE"
70 74
 rm -f $TEMPFILE
71 75
 cp -f $BOOTSTRAP_FILE.new $BOOTSTRAP_FILE
72 76
 rm -f $BOOTSTRAP_FILE.new
73
-sudo chown zeronet:zeronet /opt/zeronet/bootstrap
77
+sudo chown zeronet:zeronet $BOOTSTRAP_FILE
74 78
 
75 79
 exit 0