Make zeronet an optional part of the mesh install

This commit is contained in:
Bob Mottram 2016-08-10 21:20:19 +01:00
parent ffeb0feb10
commit a8921ceaf2
No known key found for this signature in database
GPG Key ID: 0452CC7CEA982E38
3 changed files with 65 additions and 38 deletions

View File

@ -113,6 +113,9 @@ KEYBOARD_MAP='gb'
MESH_TITLE=$"Freedombone Mesh"
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."
# Whether to enable zeronet on the mesh
ENABLE_ZERONET=
enable_eatmydata_override() {
chroot $rootdir apt-get install --no-install-recommends -y eatmydata
if [ -x $rootdir/usr/bin/eatmydata ] && \
@ -543,7 +546,9 @@ initialise_mesh() {
install_tomb
install_tox
install_web_server
install_zeronet
if [ $ENABLE_ZERONET ]; then
install_zeronet
fi
MESH_SERVICE='mesh-setup.service'
MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE

View File

@ -73,6 +73,9 @@ MESH_INSTALL_DIR=/var/lib
ZERONET_INSTALL=$MESH_INSTALL_DIR/zeronet
TOX_USERS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-tox-users.html
# whether to enable zeronet
ENABLE_ZERONET=
function create_ram_disk {
ramdisk_size_mb=$1
if [ ! -d /mnt/ramdisk ]; then
@ -467,10 +470,19 @@ function configure_toxcore {
}
function create_tox_user {
if [ ! -f /home/${MY_USERNAME}/.config/tox/data.tox ]; then
toxid -u $MY_USERNAME -n data
chown -R ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/.config/tox
# remove any existing user
if [ -f /home/${MY_USERNAME}/.config/tox/data.tox ]; then
rm -f /home/${MY_USERNAME}/.config/tox/data*
fi
if [ -d /home/${MY_USERNAME}/.config/tox/avatars ]; then
rm -rf /home/${MY_USERNAME}/.config/tox/avatars
fi
if [ ! -f /home/${MY_USERNAME}/.first_boot ]; then
touch /home/${MY_USERNAME}/.first_boot
fi
toxid -u $MY_USERNAME -n data
chown -R ${MY_USERNAME}:${MY_USERNAME} /home/${MY_USERNAME}/.config/tox
if [ ! -d /home/$MY_USERNAME/Desktop ]; then
return
@ -615,7 +627,9 @@ function mesh_restart_daemons {
systemctl restart avahi-daemon
systemctl restart ssh
systemctl restart tox-bootstrapd
systemctl restart zeronet
if [ $ENABLE_ZERONET ]; then
systemctl restart zeronet
fi
echo $'Daemons restarted' >> $INSTALL_LOG
}
@ -800,13 +814,15 @@ if [ -f $MESH_INSTALL_SETUP ]; then
setup_amnesic_data
change_avahi_name
regenerate_ssh_host_keys
configure_zeronet_blog
configure_zeronet_mail
configure_zeronet_forum
configure_zeronet_id
if [ $ENABLE_ZERONET ]; then
configure_zeronet_blog
configure_zeronet_mail
configure_zeronet_forum
configure_zeronet_id
configure_zeronet
fi
configure_toxcore
create_tox_user
configure_zeronet
disable_password_logins
mesh_amnesic
@ -821,10 +837,10 @@ if [ -f $MESH_INSTALL_SETUP ]; then
if [ ! -f $MESH_INSTALL_COMPLETED ]; then
echo $'Mesh node setup complete' >> $INSTALL_LOG
touch $MESH_INSTALL_COMPLETED
if [ -d /home/$MY_USERNAME/Desktop ]; then
touch $FIRST_BOOT
chown ${MY_USERNAME}:${MY_USERNAME} $FIRST_BOOT
fi
if [ -d /home/$MY_USERNAME/Desktop ]; then
touch $FIRST_BOOT
chown ${MY_USERNAME}:${MY_USERNAME} $FIRST_BOOT
fi
reboot
fi
fi

View File

@ -68,6 +68,7 @@ ID_STR=$"ID Services"
NO_USERS_STR=$"No users found"
# service names advertised by avahi
ENABLE_ZERONET=
ZERONET_BLOG_STR="ZeroNet Blog"
ZERONET_MAIL_STR="ZeroNet Mail"
ZERONET_FORUM_STR="ZeroNet Forum"
@ -461,37 +462,42 @@ if [ ! -d /etc/avahi ]; then
fi
avahi_extract_info
zeronet_detect
zeronet_detect_id
zeronet_detect_blog
zeronet_detect_mail
zeronet_detect_fora
if [ $ENABLE_ZERONET ]; then
zeronet_detect
zeronet_detect_id
zeronet_detect_blog
zeronet_detect_mail
zeronet_detect_fora
zeronet_update_config
fi
ipfs_bootstrap
detect_tox_users
avahi_remove_info
zeronet_update_config
# make some html headers and footers
create_header $ID_FILE $ID_STR
create_header $BLOGS_FILE $BLOGS_STR
create_header $MAIL_FILE $MAIL_STR
create_header $FORUM_FILE $FORA_STR
if [ $ENABLE_ZERONET ]; then
create_header $ID_FILE $ID_STR
create_header $BLOGS_FILE $BLOGS_STR
create_header $MAIL_FILE $MAIL_STR
create_header $FORUM_FILE $FORA_STR
create_footer $ID_FILE
create_footer $BLOGS_FILE
create_footer $MAIL_FILE
create_footer $FORUM_FILE
# make the index page
create_index
assemble_web_page ${ID_FILE} $ZERONET_INSTALL
assemble_web_page ${BLOGS_FILE} $ZERONET_INSTALL
assemble_web_page ${MAIL_FILE} $ZERONET_INSTALL
assemble_web_page ${FORUM_FILE} $ZERONET_INSTALL
chown -R zeronet:zeronet $ZERONET_INSTALL
fi
create_header $TOX_USERS_FILE $"Tox Users"
create_footer $ID_FILE
create_footer $BLOGS_FILE
create_footer $MAIL_FILE
create_footer $FORUM_FILE
create_footer $TOX_USERS_FILE
# make the index page
create_index
assemble_web_page ${ID_FILE} $ZERONET_INSTALL
assemble_web_page ${BLOGS_FILE} $ZERONET_INSTALL
assemble_web_page ${MAIL_FILE} $ZERONET_INSTALL
assemble_web_page ${FORUM_FILE} $ZERONET_INSTALL
assemble_web_page ${TOX_USERS_FILE} $ZERONET_INSTALL
chown -R zeronet:zeronet $ZERONET_INSTALL
exit 0