Просмотр исходного кода

Make zeronet an optional part of the mesh install

Bob Mottram 8 лет назад
Родитель
Сommit
a8921ceaf2
Аккаунт пользователя с таким Email не найден
3 измененных файлов: 65 добавлений и 38 удалений
  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 Просмотреть файл

113
 MESH_TITLE=$"Freedombone Mesh"
113
 MESH_TITLE=$"Freedombone Mesh"
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."
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
 enable_eatmydata_override() {
119
 enable_eatmydata_override() {
117
     chroot $rootdir apt-get install --no-install-recommends -y eatmydata
120
     chroot $rootdir apt-get install --no-install-recommends -y eatmydata
118
     if [ -x $rootdir/usr/bin/eatmydata ] && \
121
     if [ -x $rootdir/usr/bin/eatmydata ] && \
543
     install_tomb
546
     install_tomb
544
     install_tox
547
     install_tox
545
     install_web_server
548
     install_web_server
546
-    install_zeronet
549
+    if [ $ENABLE_ZERONET ]; then
550
+        install_zeronet
551
+    fi
547
 
552
 
548
     MESH_SERVICE='mesh-setup.service'
553
     MESH_SERVICE='mesh-setup.service'
549
     MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE
554
     MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE

+ 29
- 13
src/freedombone-image-mesh Просмотреть файл

73
 ZERONET_INSTALL=$MESH_INSTALL_DIR/zeronet
73
 ZERONET_INSTALL=$MESH_INSTALL_DIR/zeronet
74
 TOX_USERS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-tox-users.html
74
 TOX_USERS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-tox-users.html
75
 
75
 
76
+# whether to enable zeronet
77
+ENABLE_ZERONET=
78
+
76
 function create_ram_disk {
79
 function create_ram_disk {
77
     ramdisk_size_mb=$1
80
     ramdisk_size_mb=$1
78
     if [ ! -d /mnt/ramdisk ]; then
81
     if [ ! -d /mnt/ramdisk ]; then
467
 }
470
 }
468
 
471
 
469
 function create_tox_user {
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
     fi
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
     if [ ! -d /home/$MY_USERNAME/Desktop ]; then
487
     if [ ! -d /home/$MY_USERNAME/Desktop ]; then
476
         return
488
         return
615
     systemctl restart avahi-daemon
627
     systemctl restart avahi-daemon
616
     systemctl restart ssh
628
     systemctl restart ssh
617
     systemctl restart tox-bootstrapd
629
     systemctl restart tox-bootstrapd
618
-    systemctl restart zeronet
630
+    if [ $ENABLE_ZERONET ]; then
631
+        systemctl restart zeronet
632
+    fi
619
     echo $'Daemons restarted' >> $INSTALL_LOG
633
     echo $'Daemons restarted' >> $INSTALL_LOG
620
 }
634
 }
621
 
635
 
800
     setup_amnesic_data
814
     setup_amnesic_data
801
     change_avahi_name
815
     change_avahi_name
802
     regenerate_ssh_host_keys
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
     configure_toxcore
824
     configure_toxcore
808
     create_tox_user
825
     create_tox_user
809
-    configure_zeronet
810
     disable_password_logins
826
     disable_password_logins
811
     mesh_amnesic
827
     mesh_amnesic
812
 
828
 
821
     if [ ! -f $MESH_INSTALL_COMPLETED ]; then
837
     if [ ! -f $MESH_INSTALL_COMPLETED ]; then
822
         echo $'Mesh node setup complete' >> $INSTALL_LOG
838
         echo $'Mesh node setup complete' >> $INSTALL_LOG
823
         touch $MESH_INSTALL_COMPLETED
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
         reboot
844
         reboot
829
     fi
845
     fi
830
 fi
846
 fi

+ 30
- 24
src/zeronetavahi Просмотреть файл

68
 NO_USERS_STR=$"No users found"
68
 NO_USERS_STR=$"No users found"
69
 
69
 
70
 # service names advertised by avahi
70
 # service names advertised by avahi
71
+ENABLE_ZERONET=
71
 ZERONET_BLOG_STR="ZeroNet Blog"
72
 ZERONET_BLOG_STR="ZeroNet Blog"
72
 ZERONET_MAIL_STR="ZeroNet Mail"
73
 ZERONET_MAIL_STR="ZeroNet Mail"
73
 ZERONET_FORUM_STR="ZeroNet Forum"
74
 ZERONET_FORUM_STR="ZeroNet Forum"
461
 fi
462
 fi
462
 
463
 
463
 avahi_extract_info
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
 ipfs_bootstrap
474
 ipfs_bootstrap
470
 detect_tox_users
475
 detect_tox_users
471
 avahi_remove_info
476
 avahi_remove_info
472
-zeronet_update_config
473
 
477
 
474
 # make some html headers and footers
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
 create_header $TOX_USERS_FILE $"Tox Users"
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
 create_footer $TOX_USERS_FILE
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
 assemble_web_page ${TOX_USERS_FILE} $ZERONET_INSTALL
501
 assemble_web_page ${TOX_USERS_FILE} $ZERONET_INSTALL
494
 
502
 
495
-chown -R zeronet:zeronet $ZERONET_INSTALL
496
-
497
 exit 0
503
 exit 0