Mesh deployment

This commit is contained in:
Bob Mottram 2015-12-24 19:04:17 +00:00
parent 61ec37bbc0
commit 010f725ebf
4 changed files with 368 additions and 9 deletions

View File

@ -1923,7 +1923,7 @@ function install_zeronet_blog {
fi
if [ ! -d /etc/avahi ]; then
echo 'Avahi is not installed'
echo $'Avahi is not installed'
exit 736
fi
@ -1932,7 +1932,7 @@ function install_zeronet_blog {
cd /opt/zeronet
python zeronet.py --batch siteCreate 2> /opt/zeronet/blog.txt
if [ ! -f /opt/zeronet/blog.txt ]; then
echo 'Unable to create blog'
echo $'Unable to create blog'
exit 479
fi
blog_address=$(cat blog.txt | grep "Site address" | awk -F ':' '{print $2}')
@ -1961,7 +1961,7 @@ function install_zeronet_blog {
git clone $ZERONET_BLOG_REPO ZeroBlog
if [ ! -d /opt/zeronet/ZeroBlog ]; then
echo 'ZeroBlog repo could not be cloned'
echo $'ZeroBlog repo could not be cloned'
exit 6739
fi
cd /opt/zeronet/ZeroBlog
@ -2445,8 +2445,8 @@ function configure_avahi {
sed -i "s|#host-name=.*|host-name=$DEFAULT_DOMAIN_NAME|g" /etc/avahi/avahi-daemon.conf
else
decarray=( 1 2 3 4 5 6 7 8 9 0 )
PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
sed -i "s|#host-name=.*|host-name=mesh-$PEER_ID|g" /etc/avahi/avahi-daemon.conf
PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
fi
if [ ! -d /etc/avahi/services ]; then

View File

@ -33,6 +33,8 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-image
export TEXTDOMAINDIR="/usr/share/locale"
VARIANT='full'
# fixed username and password when the --generic option is used
GENERIC_IMAGE_USERNAME='fbone'
GENERIC_IMAGE_PASSWORD='freedombone'
@ -82,6 +84,29 @@ MINIMAL_INSTALL="yes"
# default SSH port
SSH_PORT=2222
mesh_router_setup_script() {
# create a setup script for a mesh router
mesh_script_filename=$1
echo "MY_USERNAME=${USERNAME}" > $mesh_script_filename
echo "DEFAULT_DOMAIN_NAME=${USERNAME}" >> $mesh_script_filename
echo 'SYSTEM_TYPE=mesh' >> $mesh_script_filename
echo 'INSTALLING_ON_BBB=no' >> $mesh_script_filename
echo 'USB_DRIVE=/dev/sdb1' >> $mesh_script_filename
echo 'DDNS_PROVIDER=' >> $mesh_script_filename
echo 'DDNS_USERNAME=' >> $mesh_script_filename
echo 'DDNS_PASSWORD=' >> $mesh_script_filename
echo 'DEFAULT_LANGUAGE=en_GB.UTF-8' >> $mesh_script_filename
echo 'MY_EMAIL_ADDRESS=' >> $mesh_script_filename
echo 'ENABLE_CJDNS=no' >> $mesh_script_filename
echo 'ENABLE_BATMAN=yes' >> $mesh_script_filename
echo 'ENABLE_BABEL=no' >> $mesh_script_filename
echo 'DEBIAN_REPO=' >> $mesh_script_filename
echo 'NAMESERVER1=' >> $mesh_script_filename
echo 'NAMESERVER2=' >> $mesh_script_filename
echo 'BATMAN_CELLID=any' >> $mesh_script_filename
echo 'WIFI_CHANNEL=9' >> $mesh_script_filename
}
while [[ $# > 1 ]]
do
key="$1"
@ -159,6 +184,10 @@ case $key in
shift
SSH_PORT="$1"
;;
-v|--variant)
shift
VARIANT="$1"
;;
*)
# unknown option
;;
@ -179,6 +208,13 @@ if [[ $GENERIC_IMAGE == "yes" ]]; then
PASSWORD=$GENERIC_IMAGE_PASSWORD
fi
# If this is a mesh variant then create an appropriate script
if [[ $VARIANT == "mesh"* ]]; then
CONFIG_FILENAME=/tmp/${PROJECT_NAME}_mesh.cfg
mesh_router_setup_script $CONFIG_FILENAME
DEFAULT_DOMAIN_NAME=$(cat $CONFIG_FILENAME | grep 'DEFAULT_DOMAIN_NAME' | awk -F '=' '{print $2}')
fi
if [ ! $PASSWORD ]; then
# generate a random password
PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
@ -293,6 +329,11 @@ else
fi
ls -lh ${PROJECT_NAME}*.img ${PROJECT_NAME}*.sig ${PROJECT_NAME}*.bz2 ${PROJECT_NAME}*.vdi ${PROJECT_NAME}*.qcow2
# Remove the mesh script after use
if [[ $VARIANT == "mesh"* ]]; then
rm -f $CONFIG_FILENAME
fi
# record the default login credentials for later use
echo $"Username: $USERNAME
Password: $PASSWORD" > ${CURR_DIR}/${PROJECT_NAME}_login_credentials.txt

View File

@ -202,8 +202,18 @@ create_generic_image() {
if [[ $GENERIC_IMAGE == "no" ]]; then
return
fi
VARIANT="full"
if [ $CONFIG_FILENAME ]; then
if [[ "$CONFIG_FILENAME" == *"mesh.cfg"* ]]; then
VARIANT="mesh"
fi
fi
# Don't install any configuration. This will be a base system
CONFIG_FILENAME=
if [[ $VARIANT != "mesh" ]]; then
CONFIG_FILENAME=
fi
# The presence of this file indicates that the initial
# setup has not yet been completed
touch $rootdir/home/$MY_USERNAME/.initial_setup
@ -270,10 +280,14 @@ EOF
echo " git pull" >> $rootdir/root/.bashrc
echo " make install" >> $rootdir/root/.bashrc
if [[ $MINIMAL_INSTALL == "no" ]]; then
echo " ${PROJECT_NAME} menuconfigfull" >> $rootdir/root/.bashrc
if [[ $VARIANT != "mesh" ]]; then
if [[ $MINIMAL_INSTALL == "no" ]]; then
echo " ${PROJECT_NAME} menuconfigfull" >> $rootdir/root/.bashrc
else
echo " ${PROJECT_NAME} menuconfig" >> $rootdir/root/.bashrc
fi
else
echo " ${PROJECT_NAME} menuconfig" >> $rootdir/root/.bashrc
echo " ${PROJECT_NAME}-image-mesh" >> $rootdir/root/.bashrc
fi
echo ' if [ "$?" = "0" ]; then' >> $rootdir/root/.bashrc
echo " if [ -f ~/${PROJECT_NAME}-completed.txt ]; then" >> $rootdir/root/.bashrc

304
src/freedombone-image-mesh Executable file
View File

@ -0,0 +1,304 @@
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# This command is run on initial install in order to set up a mesh router
#
# License
# =======
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-image-mesh
export TEXTDOMAINDIR="/usr/share/locale"
MY_USERNAME='fbone'
function change_avahi_name {
decarray=( 1 2 3 4 5 6 7 8 9 0 )
PEER_ID=${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}${decarray[$RANDOM%10]}
sed -i "s|#host-name=.*|host-name=P$PEER_ID|g" /etc/avahi/avahi-daemon.conf
echo "New avahi name for this peer is P$PEER_ID"
toilet "mesh-$PEER_ID"
}
function regenerate_ssh_host_keys {
echo $"Regenerating ssh host keys"
rm -f /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
echo $'ssh host keys regenerated'
# remove small moduli
awk '$5 > 2000' /etc/ssh/moduli > ~/moduli
mv ~/moduli /etc/ssh/moduli
echo $'ssh small moduli removed'
}
function configure_zeronet_blog {
echo $'Updating ZeroNet Blog'
ZERONET_DEFAULT_BLOG_TITLE="${MY_USERNAME}'s Blog"
cd /opt/zeronet
python zeronet.py --batch siteCreate 2> /opt/zeronet/blog.txt
if [ ! -f /opt/zeronet/blog.txt ]; then
echo $'Unable to create blog'
exit 479
fi
blog_address=$(cat blog.txt | grep "Site address" | awk -F ':' '{print $2}')
blog_private_key=$(cat blog.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_BLOG_ADDRESS=${blog_address//[[:blank:]]/}
ZERONET_BLOG_PRIVATE_KEY=${blog_private_key//[[:blank:]]/}
if [ ${#ZERONET_BLOG_ADDRESS} -lt 20 ]; then
echo $"Address: $ZERONET_BLOG_ADDRESS"
echo $"Public key: $ZERONET_BLOG_PRIVATE_KEY"
echo $'Unable to create zeronet blog address'
exit 7358
fi
if [ ${#ZERONET_BLOG_PRIVATE_KEY} -lt 20 ]; then
echo $"Address: $ZERONET_BLOG_ADDRESS"
echo $"Public key: $ZERONET_BLOG_PRIVATE_KEY"
echo $'Unable to create zeronet blog private key'
exit 1639
fi
if [ ! -d "/opt/zeronet/data/$ZERONET_BLOG_ADDRESS" ]; then
echo $"Unable to find site directory: /opt/zeronet/data/$ZERONET_BLOG_ADDRESS"
exit 7638
fi
echo $"ZeroNet Blog address: $ZERONET_BLOG_ADDRESS"
echo $"ZeroNet Blog private key: $ZERONET_BLOG_PRIVATE_KEY"
cp -r /opt/zeronet/ZeroBlog/* /opt/zeronet/data/$ZERONET_BLOG_ADDRESS
if [ ! -d /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/data ]; then
mkdir /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/data
fi
cp /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/data-default/data.json /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/data
sed -i "s/MyZeroBlog/$ZERONET_DEFAULT_BLOG_TITLE/g" /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/data/data.json
sed -i "s/My ZeroBlog./$ZERONET_DEFAULT_BLOG_TAGLINE/g" /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/data/data.json
sed -i "s/ZeroBlog Demo/$ZERONET_DEFAULT_BLOG_TITLE/g" /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/index.html
sed -i "s|<h3 class=\"description\">.*|<h3 class=\"description\">$ZERONET_DEFAULT_BLOG_TAGLINE</h3>|g" /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/index.html
sed -i "s/Blogging platform Demo/Blogging platform/g" /opt/zeronet/data/$ZERONET_BLOG_ADDRESS/content.json
python zeronet.py siteSign $ZERONET_BLOG_ADDRESS $ZERONET_BLOG_PRIVATE_KEY
# update the avahi service
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-blog.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-blog.service
echo '<service-group>' >> /tmp/zeronet-blog.service
echo ' <name replace-wildcards="yes">%h ZeroNet Blog</name>' >> /tmp/zeronet-blog.service
echo ' <service>' >> /tmp/zeronet-blog.service
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-blog.service
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-blog.service
echo " <txt-record>$ZERONET_URL/$ZERONET_BLOG_ADDRESS</txt-record>" >> /tmp/zeronet-blog.service
echo ' </service>' >> /tmp/zeronet-blog.service
echo '</service-group>' >> /tmp/zeronet-blog.service
cp /tmp/zeronet-blog.service /etc/avahi/services/zeronet-blog.service
if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
mkdir -p /home/$MY_USERNAME/.config/zeronet
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
fi
echo "$ZERONET_URL/$ZERONET_BLOG_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/myblog
sed -i "s|ZeroNet Blog address.*|ZeroNet Blog address: $ZERONET_BLOG_ADDRESS|g" /home/$MY_USERNAME/README
sed -i "s|ZeroNet Blog private key.*|ZeroNet Blog private key: $ZERONET_BLOG_PRIVATE_KEY|g" /home/$MY_USERNAME/README
}
function configure_zeronet_mail {
echo $'Updating ZeroNet Mail'
ZERONET_DEFAULT_MAIL_TITLE="${MY_USERNAME}'s Mail"
cd /opt/zeronet
python zeronet.py --batch siteCreate 2> /opt/zeronet/mail.txt
if [ ! -f /opt/zeronet/mail.txt ]; then
echo 'Unable to create mail'
exit 479
fi
mail_address=$(cat mail.txt | grep "Site address" | awk -F ':' '{print $2}')
mail_private_key=$(cat mail.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_MAIL_ADDRESS=${mail_address//[[:blank:]]/}
ZERONET_MAIL_PRIVATE_KEY=${mail_private_key//[[:blank:]]/}
if [ ${#ZERONET_MAIL_ADDRESS} -lt 20 ]; then
echo $"Address: $ZERONET_MAIL_ADDRESS"
echo $"Public key: $ZERONET_MAIL_PRIVATE_KEY"
echo $'Unable to create zeronet mail address'
exit 7358
fi
if [ ${#ZERONET_MAIL_PRIVATE_KEY} -lt 20 ]; then
echo $"Address: $ZERONET_MAIL_ADDRESS"
echo $"Public key: $ZERONET_MAIL_PRIVATE_KEY"
echo $'Unable to create zeronet mail private key'
exit 1639
fi
if [ ! -d "/opt/zeronet/data/$ZERONET_MAIL_ADDRESS" ]; then
echo $"Unable to find site directory: /opt/zeronet/data/$ZERONET_MAIL_ADDRESS"
exit 7638
fi
echo $"ZeroNet Mail address: $ZERONET_MAIL_ADDRESS"
echo $"ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY"
cp -r /opt/zeronet/ZeroMail/* /opt/zeronet/data/$ZERONET_MAIL_ADDRESS
if [ ! -d /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data ]; then
mkdir /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data
fi
cp /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data-default/data.json /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data
sed -i "s/MyZeroMail/$ZERONET_DEFAULT_MAIL_TITLE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
sed -i "s/My ZeroMail./$ZERONET_DEFAULT_MAIL_TAGLINE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
sed -i "s/ZeroMail Demo/$ZERONET_DEFAULT_MAIL_TITLE/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
sed -i "s|<h3 class=\"description\">.*|<h3 class=\"description\">$ZERONET_DEFAULT_MAIL_TAGLINE</h3>|g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
sed -i "s/Mailging platform Demo/Mailging platform/g" /opt/zeronet/data/$ZERONET_MAIL_ADDRESS/content.json
python zeronet.py siteSign $ZERONET_MAIL_ADDRESS $ZERONET_MAIL_PRIVATE_KEY
# Add an avahi service
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-mail.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-mail.service
echo '<service-group>' >> /tmp/zeronet-mail.service
echo ' <name replace-wildcards="yes">%h ZeroNet Mail</name>' >> /tmp/zeronet-mail.service
echo ' <service>' >> /tmp/zeronet-mail.service
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-mail.service
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-mail.service
echo " <txt-record>$ZERONET_URL/$ZERONET_MAIL_ADDRESS</txt-record>" >> /tmp/zeronet-mail.service
echo ' </service>' >> /tmp/zeronet-mail.service
echo '</service-group>' >> /tmp/zeronet-mail.service
cp /tmp/zeronet-mail.service /etc/avahi/services/zeronet-mail.service
if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
mkdir -p /home/$MY_USERNAME/.config/zeronet
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
fi
echo "$ZERONET_URL/$ZERONET_MAIL_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/mymail
sed -i "s|ZeroNet Mail address.*|ZeroNet Mail address: $ZERONET_MAIL_ADDRESS|g" /home/$MY_USERNAME/README
sed -i "s|ZeroNet Mail private key.*|ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY|g" /home/$MY_USERNAME/README
}
function configure_zeronet_forum {
echo $'Updating ZeroNet Forum'
ZERONET_DEFAULT_FORUM_TITLE="${MY_USERNAME}'s Forum"
cd /opt/zeronet
python zeronet.py --batch siteCreate 2> /opt/zeronet/forum.txt
if [ ! -f /opt/zeronet/forum.txt ]; then
echo 'Unable to create forum'
exit 479
fi
forum_address=$(cat forum.txt | grep "Site address" | awk -F ':' '{print $2}')
forum_private_key=$(cat forum.txt | grep "Site private key" | awk -F ':' '{print $2}')
ZERONET_FORUM_ADDRESS=${forum_address//[[:blank:]]/}
ZERONET_FORUM_PRIVATE_KEY=${forum_private_key//[[:blank:]]/}
if [ ${#ZERONET_FORUM_ADDRESS} -lt 20 ]; then
echo $"Address: $ZERONET_FORUM_ADDRESS"
echo $"Public key: $ZERONET_FORUM_PRIVATE_KEY"
echo $'Unable to create zeronet forum address'
exit 76352
fi
if [ ${#ZERONET_FORUM_PRIVATE_KEY} -lt 20 ]; then
echo $"Address: $ZERONET_FORUM_ADDRESS"
echo $"Public key: $ZERONET_FORUM_PRIVATE_KEY"
echo $'Unable to create zeronet forum private key'
exit 87356
fi
if [ ! -d "/opt/zeronet/data/$ZERONET_FORUM_ADDRESS" ]; then
echo $"Unable to find site directory: /opt/zeronet/data/$ZERONET_FORUM_ADDRESS"
exit 7638
fi
echo $"Forum address: $ZERONET_FORUM_ADDRESS"
echo $"Forum private key: $ZERONET_FORUM_PRIVATE_KEY"
cp -r /opt/zeronet/ZeroTalk/* /opt/zeronet/data/$ZERONET_FORUM_ADDRESS
sed -i "s/ZeroBoard/$ZERONET_DEFAULT_FORUM_TITLE/g" /opt/zeronet/data/$ZERONET_FORUM_ADDRESS/index.html
sed -i "s/ZeroTalk/$ZERONET_DEFAULT_FORUM_TITLE/g" /opt/zeronet/data/$ZERONET_FORUM_ADDRESS/index.html
sed -i "s|Demo for dynamic, decentralized content publishing.|$ZERONET_DEFAULT_FORUM_TAGLINE|g" /opt/zeronet/data/$ZERONET_FORUM_ADDRESS/index.html
sed -i 's/Messaging Board Demo/Messaging Board/g' /opt/zeronet/data/$ZERONET_FORUM_ADDRESS/content.json
sed -i "s/ZeroBoard/$ZERONET_DEFAULT_FORUM_TITLE/g" /opt/zeronet/data/$ZERONET_FORUM_ADDRESS/content.json
python zeronet.py siteSign $ZERONET_FORUM_ADDRESS $ZERONET_FORUM_PRIVATE_KEY --inner_path data/users/content.json
# Add an avahi service
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/zeronet-forum.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/zeronet-forum.service
echo '<service-group>' >> /tmp/zeronet-forum.service
echo ' <name replace-wildcards="yes">%h ZeroNet Forum</name>' >> /tmp/zeronet-forum.service
echo ' <service>' >> /tmp/zeronet-forum.service
echo ' <type>_zeronet._udp</type>' >> /tmp/zeronet-forum.service
echo " <port>$ZERONET_PORT</port>" >> /tmp/zeronet-forum.service
echo " <txt-record>$ZERONET_URL/$ZERONET_FORUM_ADDRESS</txt-record>" >> /tmp/zeronet-forum.service
echo ' </service>' >> /tmp/zeronet-forum.service
echo '</service-group>' >> /tmp/zeronet-forum.service
sudo cp /tmp/zeronet-forum.service /etc/avahi/services/zeronet-forum.service
if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
mkdir -p /home/$MY_USERNAME/.config/zeronet
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
fi
echo "$ZERONET_URL/$ZERONET_FORUM_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/myforum
sed -i "s|ZeroNet Forum address.*|ZeroNet Forum address: $ZERONET_FORUM_ADDRESS|g" /home/$MY_USERNAME/README
sed -i "s|ZeroNet Forum private key.*|ZeroNet Forum private key: $ZERONET_FORUM_PRIVATE_KEY|g" /home/$MY_USERNAME/README
}
function configure_tox {
echo $'Regenerating Tox bootstrap node keys'
systemctl stop tox-bootstrapd.service
if [ -f /var/lib/tox-bootstrapd/keys ]; then
rm /var/lib/tox-bootstrapd/keys
fi
systemctl start tox-bootstrapd.service
TOX_BOOTSTRAP_ID_FILE=/var/lib/tox-bootstrapd/pubkey.txt
TOX_PUBLIC_KEY=$(cat /var/log/syslog | grep tox | grep "Public Key" | awk -F ' ' '{print $8}' | tail -1)
if [ ${#TOX_PUBLIC_KEY} -lt 30 ]; then
echo 'Could not obtain the tox node public key'
exit 6529
fi
# save the public key for later reference
echo "$TOX_PUBLIC_KEY" > $TOX_BOOTSTRAP_ID_FILE
echo $'Resetting toxic client'
if [ -d /home/$MY_USERNAME/.config/tox ]; then
rm -rf /home/$MY_USERNAME/.config/tox
su -c 'echo "n
/nick $MY_USERNAME
/exit
" | /usr/bin/toxic -d' - $MY_USERNAME
fi
}
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
exit 0