Browse Source

Make zeronet an optional part of the mesh install

Bob Mottram 8 years ago
parent
commit
a8921ceaf2
No account linked to committer's email
3 changed files with 65 additions and 38 deletions
  1. 6
    1
      src/freedombone-image-customise
  2. 29
    13
      src/freedombone-image-mesh
  3. 30
    24
      src/zeronetavahi

+ 6
- 1
src/freedombone-image-customise View File

@@ -113,6 +113,9 @@ KEYBOARD_MAP='gb'
113 113
 MESH_TITLE=$"Freedombone Mesh"
114 114
 MESH_SET_USERNAME=$"Welcome to the Freedombone mesh.\n\nThe first thing you will need to do is set a username so that other peers can find you."
115 115
 
116
+# Whether to enable zeronet on the mesh
117
+ENABLE_ZERONET=
118
+
116 119
 enable_eatmydata_override() {
117 120
     chroot $rootdir apt-get install --no-install-recommends -y eatmydata
118 121
     if [ -x $rootdir/usr/bin/eatmydata ] && \
@@ -543,7 +546,9 @@ initialise_mesh() {
543 546
     install_tomb
544 547
     install_tox
545 548
     install_web_server
546
-    install_zeronet
549
+    if [ $ENABLE_ZERONET ]; then
550
+        install_zeronet
551
+    fi
547 552
 
548 553
     MESH_SERVICE='mesh-setup.service'
549 554
     MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE

+ 29
- 13
src/freedombone-image-mesh View File

@@ -73,6 +73,9 @@ MESH_INSTALL_DIR=/var/lib
73 73
 ZERONET_INSTALL=$MESH_INSTALL_DIR/zeronet
74 74
 TOX_USERS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-tox-users.html
75 75
 
76
+# whether to enable zeronet
77
+ENABLE_ZERONET=
78
+
76 79
 function create_ram_disk {
77 80
     ramdisk_size_mb=$1
78 81
     if [ ! -d /mnt/ramdisk ]; then
@@ -467,10 +470,19 @@ function configure_toxcore {
467 470
 }
468 471
 
469 472
 function create_tox_user {
470
-    if [ ! -f /home/${MY_USERNAME}/.config/tox/data.tox ]; then
471
-        toxid -u $MY_USERNAME -n data
472
-        chown -R ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/.config/tox
473
+    # remove any existing user
474
+    if [ -f /home/${MY_USERNAME}/.config/tox/data.tox ]; then
475
+        rm -f /home/${MY_USERNAME}/.config/tox/data*
476
+    fi
477
+    if [ -d /home/${MY_USERNAME}/.config/tox/avatars ]; then
478
+        rm -rf /home/${MY_USERNAME}/.config/tox/avatars
473 479
     fi
480
+    if [ ! -f /home/${MY_USERNAME}/.first_boot ]; then
481
+        touch /home/${MY_USERNAME}/.first_boot
482
+    fi
483
+
484
+    toxid -u $MY_USERNAME -n data
485
+    chown -R ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/.config/tox
474 486
 
475 487
     if [ ! -d /home/$MY_USERNAME/Desktop ]; then
476 488
         return
@@ -615,7 +627,9 @@ function mesh_restart_daemons {
615 627
     systemctl restart avahi-daemon
616 628
     systemctl restart ssh
617 629
     systemctl restart tox-bootstrapd
618
-    systemctl restart zeronet
630
+    if [ $ENABLE_ZERONET ]; then
631
+        systemctl restart zeronet
632
+    fi
619 633
     echo $'Daemons restarted' >> $INSTALL_LOG
620 634
 }
621 635
 
@@ -800,13 +814,15 @@ if [ -f $MESH_INSTALL_SETUP ]; then
800 814
     setup_amnesic_data
801 815
     change_avahi_name
802 816
     regenerate_ssh_host_keys
803
-    configure_zeronet_blog
804
-    configure_zeronet_mail
805
-    configure_zeronet_forum
806
-    configure_zeronet_id
817
+    if [ $ENABLE_ZERONET ]; then
818
+        configure_zeronet_blog
819
+        configure_zeronet_mail
820
+        configure_zeronet_forum
821
+        configure_zeronet_id
822
+        configure_zeronet
823
+    fi
807 824
     configure_toxcore
808 825
     create_tox_user
809
-    configure_zeronet
810 826
     disable_password_logins
811 827
     mesh_amnesic
812 828
 
@@ -821,10 +837,10 @@ if [ -f $MESH_INSTALL_SETUP ]; then
821 837
     if [ ! -f $MESH_INSTALL_COMPLETED ]; then
822 838
         echo $'Mesh node setup complete' >> $INSTALL_LOG
823 839
         touch $MESH_INSTALL_COMPLETED
824
-		if [ -d /home/$MY_USERNAME/Desktop ]; then
825
-			touch $FIRST_BOOT
826
-			chown ${MY_USERNAME}:${MY_USERNAME} $FIRST_BOOT
827
-		fi
840
+        if [ -d /home/$MY_USERNAME/Desktop ]; then
841
+            touch $FIRST_BOOT
842
+            chown ${MY_USERNAME}:${MY_USERNAME} $FIRST_BOOT
843
+        fi
828 844
         reboot
829 845
     fi
830 846
 fi

+ 30
- 24
src/zeronetavahi View File

@@ -68,6 +68,7 @@ ID_STR=$"ID Services"
68 68
 NO_USERS_STR=$"No users found"
69 69
 
70 70
 # service names advertised by avahi
71
+ENABLE_ZERONET=
71 72
 ZERONET_BLOG_STR="ZeroNet Blog"
72 73
 ZERONET_MAIL_STR="ZeroNet Mail"
73 74
 ZERONET_FORUM_STR="ZeroNet Forum"
@@ -461,37 +462,42 @@ if [ ! -d /etc/avahi ]; then
461 462
 fi
462 463
 
463 464
 avahi_extract_info
464
-zeronet_detect
465
-zeronet_detect_id
466
-zeronet_detect_blog
467
-zeronet_detect_mail
468
-zeronet_detect_fora
465
+if [ $ENABLE_ZERONET ]; then
466
+    zeronet_detect
467
+    zeronet_detect_id
468
+    zeronet_detect_blog
469
+    zeronet_detect_mail
470
+    zeronet_detect_fora
471
+    zeronet_update_config
472
+fi
473
+
469 474
 ipfs_bootstrap
470 475
 detect_tox_users
471 476
 avahi_remove_info
472
-zeronet_update_config
473 477
 
474 478
 # make some html headers and footers
475
-create_header $ID_FILE $ID_STR
476
-create_header $BLOGS_FILE $BLOGS_STR
477
-create_header $MAIL_FILE $MAIL_STR
478
-create_header $FORUM_FILE $FORA_STR
479
+if [ $ENABLE_ZERONET ]; then
480
+    create_header $ID_FILE $ID_STR
481
+    create_header $BLOGS_FILE $BLOGS_STR
482
+    create_header $MAIL_FILE $MAIL_STR
483
+    create_header $FORUM_FILE $FORA_STR
484
+    create_footer $ID_FILE
485
+    create_footer $BLOGS_FILE
486
+    create_footer $MAIL_FILE
487
+    create_footer $FORUM_FILE
488
+
489
+    # make the index page
490
+    create_index
491
+
492
+    assemble_web_page ${ID_FILE} $ZERONET_INSTALL
493
+    assemble_web_page ${BLOGS_FILE} $ZERONET_INSTALL
494
+    assemble_web_page ${MAIL_FILE} $ZERONET_INSTALL
495
+    assemble_web_page ${FORUM_FILE} $ZERONET_INSTALL
496
+    chown -R zeronet:zeronet $ZERONET_INSTALL
497
+fi
498
+
479 499
 create_header $TOX_USERS_FILE $"Tox Users"
480
-create_footer $ID_FILE
481
-create_footer $BLOGS_FILE
482
-create_footer $MAIL_FILE
483
-create_footer $FORUM_FILE
484 500
 create_footer $TOX_USERS_FILE
485
-
486
-# make the index page
487
-create_index
488
-
489
-assemble_web_page ${ID_FILE} $ZERONET_INSTALL
490
-assemble_web_page ${BLOGS_FILE} $ZERONET_INSTALL
491
-assemble_web_page ${MAIL_FILE} $ZERONET_INSTALL
492
-assemble_web_page ${FORUM_FILE} $ZERONET_INSTALL
493 501
 assemble_web_page ${TOX_USERS_FILE} $ZERONET_INSTALL
494 502
 
495
-chown -R zeronet:zeronet $ZERONET_INSTALL
496
-
497 503
 exit 0