From 29bb1348f54f35772ea21d3a2b72db3f38b191ec Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 11 Jan 2016 11:27:08 +0000 Subject: [PATCH] Mesh router setup --- src/freedombone-image-customise | 31 ++++++++++++++++++++++++++++++- src/freedombone-image-mesh | 25 ++++++++++++++++--------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/freedombone-image-customise b/src/freedombone-image-customise index 9fcb2645..5af940ea 100755 --- a/src/freedombone-image-customise +++ b/src/freedombone-image-customise @@ -215,6 +215,8 @@ create_generic_image() { # Don't install any configuration. This will be a base system if [[ $VARIANT != "mesh" ]]; then CONFIG_FILENAME= + else + touch $rootdir/root/.initial_mesh_setup fi # The presence of this file indicates that the initial @@ -292,7 +294,7 @@ EOF echo " ${PROJECT_NAME} menuconfig-onion" >> $rootdir/root/.bashrc fi else - echo " ${PROJECT_NAME}-image-mesh" >> $rootdir/root/.bashrc + echo 'echo ""' fi echo ' if [ "$?" = "0" ]; then' >> $rootdir/root/.bashrc echo " if [ -f ~/${PROJECT_NAME}-completed.txt ]; then" >> $rootdir/root/.bashrc @@ -359,6 +361,32 @@ atheros_wifi() { fi } +initialise_mesh() { + if [[ $VARIANT != "mesh" ]]; then + return + fi + MESH_SERVICE='mesh-setup.service' + MESH_SETUP_DAEMON=$rootdir/etc/systemd/system/$MESH_SERVICE + + echo '[Unit]' > $MESH_SETUP_DAEMON + echo 'Description=Initial mesh router configuration' >> $MESH_SETUP_DAEMON + echo 'After=syslog.target' >> $MESH_SETUP_DAEMON + echo 'After=network.target' >> $MESH_SETUP_DAEMON + echo '[Service]' >> $MESH_SETUP_DAEMON + echo 'Type=simple' >> $MESH_SETUP_DAEMON + echo 'User=root' >> $MESH_SETUP_DAEMON + echo 'Group=root' >> $MESH_SETUP_DAEMON + echo 'WorkingDirectory=/root' >> $MESH_SETUP_DAEMON + echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-image-mesh > /var/log/mesh-setup.log" >> $MESH_SETUP_DAEMON + echo '' >> $MESH_SETUP_DAEMON + echo 'TimeoutSec=99999' >> $MESH_SETUP_DAEMON + echo '' >> $MESH_SETUP_DAEMON + echo '[Install]' >> $MESH_SETUP_DAEMON + echo 'WantedBy=multi-user.target' >> $MESH_SETUP_DAEMON + + chroot $rootdir systemctl enable $MESH_SERVICE +} + # Set to true/false to control if eatmydata is used during build use_eatmydata=true @@ -470,6 +498,7 @@ admin_user_sudo create_generic_image atheros_wifi continue_installation +initialise_mesh cd / echo $"info: killing leftover processes in chroot" diff --git a/src/freedombone-image-mesh b/src/freedombone-image-mesh index c046275f..d0246dc2 100755 --- a/src/freedombone-image-mesh +++ b/src/freedombone-image-mesh @@ -290,15 +290,22 @@ function configure_tox { fi } -if [ $1 ]; then - MY_USERNAME=$1 +if [ -f /root/.initial_mesh_setup ]; then + if [ $1 ]; then + MY_USERNAME=$1 + fi + + regenerate_ssh_host_keys + configure_zeronet_blog + configure_zeronet_mail + configure_zeronet_forum + configure_tox + change_avahi_name + + rm /root/.initial_mesh_setup + systemctl disable mesh-setup.service + touch /root/.mesh_setup_completed + reboot fi -regenerate_ssh_host_keys -configure_zeronet_blog -configure_zeronet_mail -configure_zeronet_forum -configure_tox -change_avahi_name - exit 0