Skip to content
Snippets Groups Projects
Commit f1734b04 authored by Bob Mottram's avatar Bob Mottram
Browse files

Starting mesh client improvements

In the new design installing things onto unknown clients isn't needed
parent 2e5a742b
No related branches found
No related tags found
No related merge requests found
......@@ -33,477 +33,13 @@ PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-meshweb
export TEXTDOMAINDIR="/usr/share/locale"
# client or server installations sounds odd for a mesh, but this
# indicates whether this is a dedicated mesh peer ("yes") or
# a 'client' such as a laptop or desktop machine with
# the freedombone-client script installed
SERVER_INSTALLATION="no"
PEERS_FILE=/tmp/meshwebstart
ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet.git'
ZERONET_COMMIT='675bd462556c541d65e2d95f91f899146a373aad'
ZERONET_BLOG_REPO='https://github.com/HelloZeroNet/ZeroBlog'
ZERONET_BLOG_COMMIT='bbb0d6c36465fed2e6df71f1aab45fcc9c6ad609'
ZERONET_MAIL_REPO='https://github.com/HelloZeroNet/ZeroMail'
ZERONET_MAIL_COMMIT='955af09d643c72b02e4983d71eca5c0c93a6c131'
ZERONET_FORUM_REPO='https://github.com/HelloZeroNet/ZeroTalk'
ZERONET_FORUM_COMMIT='e2d2c9cb1cfbfef91b244935efb5c14c2ad95faa'
ZERONET_URL=http://127.0.0.1:43110
ZERONET_PORT=15441
TRACKER_PORT=6969
MY_USERNAME=$USER
ZERONET_DIR=/home/$MY_USERNAME/zeronet
UPDATED="no"
ZERONET_DEFAULT_BLOG_TAGLINE=$"Blogging on the Mesh"
ZERONET_DEFAULT_FORUM_TAGLINE=$"A decentralized discussion group"
ZERONET_DEFAULT_MAIL_TAGLINE=$"Mail for the Mesh"
IPFS_PORT=4001
MESH_INSTALL_DIR=/var/lib
function install_ipfs {
if [ ! -f /home/$MY_USERNAME/go/bin/ipfs ]; then
if [ ! -d /usr/local/go ]; then
sudo apt-get -y install golang
fi
sudo apt-get -y install libpam0g-dev fuse
if ! grep -q "GOROOT" /home/$MY_USERNAME/.bashrc; then
if [ -d /usr/local/go ]; then
echo "export GOROOT=/usr/local/go" >> /home/$MY_USERNAME/.bashrc
fi
fi
if ! grep -q "GOPATH/bin" /home/$MY_USERNAME/.bashrc; then
echo "export GOPATH=/home/$MY_USERNAME/go" >> /home/$MY_USERNAME/.bashrc
echo 'export PATH="$GOPATH/bin:$PATH:";' >> /home/$MY_USERNAME/.bashrc
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc
fi
if [ ! -d /home/$MY_USERNAME/go ]; then
mkdir /home/$MY_USERNAME/go
fi
. /home/$MY_USERNAME/.bashrc
go get -u github.com/ipfs/go-ipfs/cmd/ipfs
if [ ! "$?" = "0" ]; then
exit 8242
fi
fi
if [ ! -d /home/$MY_USERNAME/.ipfs ]; then
ipfs init -b 4096
if [ ! -d /home/$MY_USERNAME/.ipfs ]; then
echo $"IPFS could not be initialised"
exit 7358
fi
# directories to mount to
if [ ! -d /ipfs ]; then
sudo mkdir /ipfs
sudo mkdir /ipns
sudo chown $MY_USERNAME:$MY_USERNAME /ipfs
sudo chown $MY_USERNAME:$MY_USERNAME /ipns
fi
if [ -f /etc/fuse.conf ]; then
sudo chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf
fi
if [ -f /dev/fuse ]; then
sudo chown $MY_USERNAME:$MY_USERNAME /dev/fuse
fi
fi
IPFS_PEER_ID=$(ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}')
if [ ${#IPFS_PEER_ID} -lt 10 ]; then
echo $'Invalid IPFS peer ID'
echo "$IPFS_PEER_ID"
exit 74782
fi
# Add an avahi service
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/ipfs.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/ipfs.service
echo '<service-group>' >> /tmp/ipfs.service
echo ' <name replace-wildcards="yes">%h IPFS</name>' >> /tmp/ipfs.service
echo ' <service>' >> /tmp/ipfs.service
echo ' <type>_ipfs._tcp</type>' >> /tmp/ipfs.service
echo " <port>$IPFS_PORT</port>" >> /tmp/ipfs.service
echo " <txt-record>$IPFS_PEER_ID</txt-record>" >> /tmp/ipfs.service
echo ' </service>' >> /tmp/ipfs.service
echo '</service-group>' >> /tmp/ipfs.service
sudo cp /tmp/ipfs.service /etc/avahi/services/ipfs.service
}
function install_zeronet_blog {
if [ ! -f /home/$MY_USERNAME/README ]; then
touch /home/$MY_USERNAME/README
fi
if grep -q "ZeroNet Blog address" /home/$MY_USERNAME/README; then
return
fi
if [ ! -d /etc/avahi ]; then
echo $'Avahi is not installed'
exit 736
fi
ZERONET_DEFAULT_BLOG_TITLE=$"${MY_USERNAME}'s Blog"
cd $ZERONET_DIR
python zeronet.py --batch siteCreate 2> $ZERONET_DIR/blog.txt
if [ ! -f $ZERONET_DIR/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 "$ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS" ]; then
echo $"Unable to find site directory: $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS"
exit 7638
fi
git clone $ZERONET_BLOG_REPO ZeroBlog
if [ ! -d $ZERONET_DIR/ZeroBlog ]; then
echo $'ZeroBlog repo could not be cloned'
exit 6739
fi
cd $MESH_INSTALL_DIR/zeronet/ZeroBlog
git checkout $ZERONET_BLOG_COMMIT -b $ZERONET_BLOG_COMMIT
echo $"Blog address: $ZERONET_BLOG_ADDRESS"
echo $"Blog private key: $ZERONET_BLOG_PRIVATE_KEY"
cp -r $ZERONET_DIR/ZeroBlog/* $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS
if [ ! -d $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/data ]; then
mkdir $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/data
fi
cp $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/data-default/data.json $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/data
sed -i "s/MyZeroBlog/$ZERONET_DEFAULT_BLOG_TITLE/g" $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/data/data.json
sed -i "s/My ZeroBlog./$ZERONET_DEFAULT_BLOG_TAGLINE/g" $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/data/data.json
sed -i "s/ZeroBlog Demo/$ZERONET_DEFAULT_BLOG_TITLE/g" $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/index.html
sed -i "s|<h3 class=\"description\">.*|<h3 class="description">$ZERONET_DEFAULT_BLOG_TAGLINE</h3>|g" $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/index.html
sed -i "s/Blogging platform Demo/Blogging platform/g" $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/content.json
python zeronet.py siteSign $ZERONET_BLOG_ADDRESS $ZERONET_BLOG_PRIVATE_KEY
# Add an 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
sudo 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
if ! grep -q "ZeroNet Blog address" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo $"ZeroNet Blog address: $ZERONET_BLOG_ADDRESS" >> /home/$MY_USERNAME/README
echo $"ZeroNet Blog private key: $ZERONET_BLOG_PRIVATE_KEY" >> /home/$MY_USERNAME/README
fi
echo $'Zeronet blog installed'
}
function install_zeronet_mail {
if [ ! -f /home/$MY_USERNAME/README ]; then
touch /home/$MY_USERNAME/README
fi
if grep -q "ZeroNet Mail address" /home/$MY_USERNAME/README; then
return
fi
if [ ! -d /etc/avahi ]; then
echo $'Avahi is not installed'
exit 736
fi
ZERONET_DEFAULT_MAIL_TITLE=$"${MY_USERNAME}'s Mail"
cd $MESH_INSTALL_DIR/zeronet
python zeronet.py --batch siteCreate 2> $MESH_INSTALL_DIR/zeronet/mail.txt
if [ ! -f $MESH_INSTALL_DIR/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 "$MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS" ]; then
echo $"Unable to find site directory: $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS"
exit 7638
fi
git clone $ZERONET_MAIL_REPO ZeroMail
if [ ! -d $MESH_INSTALL_DIR/zeronet/ZeroMail ]; then
echo $'ZeroMail repo could not be cloned'
exit 6739
fi
cd $MESH_INSTALL_DIR/zeronet/ZeroMail
git checkout $ZERONET_MAIL_COMMIT -b $ZERONET_MAIL_COMMIT
echo $"ZeroNet Mail address: $ZERONET_MAIL_ADDRESS"
echo $"ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY"
cp -r $MESH_INSTALL_DIR/zeronet/ZeroMail/* $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS
if [ ! -d $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data ]; then
mkdir $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data
fi
cp $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data-default/data.json $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data
sed -i "s/MyZeroMail/$ZERONET_DEFAULT_MAIL_TITLE/g" $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
sed -i "s/My ZeroMail./$ZERONET_DEFAULT_MAIL_TAGLINE/g" $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/data/data.json
sed -i "s/ZeroMail Demo/$ZERONET_DEFAULT_MAIL_TITLE/g" $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
sed -i "s|<h3 class=\"description\">.*|<h3 class=\"description\">$ZERONET_DEFAULT_MAIL_TAGLINE</h3>|g" $MESH_INSTALL_DIR/zeronet/data/$ZERONET_MAIL_ADDRESS/index.html
sed -i "s/Mailging platform Demo/Mailging platform/g" $MESH_INSTALL_DIR/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
if ! grep -q "ZeroNet Mail address" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo "ZeroNet Mail address: $ZERONET_MAIL_ADDRESS" >> /home/$MY_USERNAME/README
echo "ZeroNet Mail private key: $ZERONET_MAIL_PRIVATE_KEY" >> /home/$MY_USERNAME/README
fi
echo $'Zeronet mail installed'
}
function install_zeronet_forum {
if [ ! -f /home/$MY_USERNAME/README ]; then
touch /home/$MY_USERNAME/README
fi
if grep -q "ZeroNet Forum address" /home/$MY_USERNAME/README; then
return
fi
if [ ! -d /etc/avahi ]; then
echo $'Avahi is not installed'
exit 736
fi
ZERONET_DEFAULT_FORUM_TITLE="${MY_USERNAME}'s Forum"
cd $ZERONET_DIR
python zeronet.py --batch siteCreate 2> $ZERONET_DIR/forum.txt
if [ ! -f $ZERONET_DIR/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 "$ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS" ]; then
echo $"Unable to find site directory: $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS"
exit 7638
fi
git clone $ZERONET_FORUM_REPO ZeroTalk
if [ ! -d $ZERONET_DIR/ZeroTalk ]; then
echo $'ZeroTalk repo could not be cloned'
exit 6739
fi
cd $MESH_INSTALL_DIR/zeronet/ZeroTalk
git checkout $ZERONET_FORUM_COMMIT -b $ZERONET_FORUM_COMMIT
echo $"Forum address: $ZERONET_FORUM_ADDRESS"
echo $"Forum private key: $ZERONET_FORUM_PRIVATE_KEY"
cp -r $ZERONET_DIR/ZeroTalk/* $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS
sed -i "s/ZeroBoard/$ZERONET_DEFAULT_FORUM_TITLE/g" $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS/index.html
sed -i "s/ZeroTalk/$ZERONET_DEFAULT_FORUM_TITLE/g" $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS/index.html
sed -i "s|Demo for dynamic, decentralized content publishing.|$ZERONET_DEFAULT_FORUM_TAGLINE|g" $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS/index.html
sed -i 's/Messaging Board Demo/Messaging Board/g' $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS/content.json
sed -i "s/ZeroBoard/$ZERONET_DEFAULT_FORUM_TITLE/g" $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS/content.json
python zeronet.py siteSign $ZERONET_FORUM_ADDRESS $ZERONET_FORUM_PRIVATE_KEY
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
if ! grep -q "ZeroNet Forum address" /home/$MY_USERNAME/README; then
echo '' >> /home/$MY_USERNAME/README
echo $"ZeroNet Forum address: $ZERONET_FORUM_ADDRESS" >> /home/$MY_USERNAME/README
echo $"ZeroNet Forum private key: $ZERONET_FORUM_PRIVATE_KEY" >> /home/$MY_USERNAME/README
fi
echo $'Zeronet forum installed'
}
function install_web_server {
if [ -d /etc/nginx ]; then
return
fi
if [[ $UPDATED == "no" ]]; then
sudo apt-get update
UPDATED="yes"
fi
sudo apt-get -y remove --purge apache2
if [ -d /etc/apache2 ]; then
sudo rm -rf /etc/apache2
fi
# install nginx
sudo apt-get -y install nginx
if [ ! -d /etc/nginx ]; then
echo $'Unable to install web server'
exit 51
fi
}
function install_zeronet {
if [ -d $ZERONET_DIR ]; then
return
fi
if [[ $UPDATED == "no" ]]; then
sudo apt-get update
UPDATED="yes"
fi
sudo apt-get -y install python python-msgpack python-gevent
sudo apt-get -y install python-pip bittornado
sudo pip install msgpack-python --upgrade
git clone $ZERONET_REPO $ZERONET_DIR
if [ ! -d $ZERONET_DIR ]; then
exit 56823
fi
cd $ZERONET_DIR
git checkout $ZERONET_COMMIT -b $ZERONET_COMMIT
#cd $ZERONET_DIR
#git checkout bashrc/bootstrap-file
# Hack to ensure that the file access port is opened
# This is because zeronet normally relies on an internet site
# to do this, but on a purely local mesh the internet isn't available
sed -i 's|fileserver_port = 0|fileserver_port = config.fileserver_port\n sys.modules["main"].file_server.port_opened = True|g' $ZERONET_DIR/src/Site/Site.py
}
if [[ "$1" == "stop" ]]; then
sudo batman stop
exit 0
fi
if [ -f /var/lib/batman ]; then
SERVER_INSTALLATION="yes"
fi
if [[ $SERVER_INSTALLATION == "no" ]]; then
if [ ! -f /usr/bin/batman ]; then
${PROJECT_NAME}-client
fi
fi
PEERS_FILE=/tmp/meshwebstart
if [ -d $MESH_INSTALL_DIR/zeronet ]; then
ZERONET_DIR=$MESH_INSTALL_DIR/zeronet
fi
if [[ $SERVER_INSTALLATION == "no" ]]; then
if [ ! -f /tmp/meshtype ]; then
install_web_server
install_zeronet
install_zeronet_blog
install_zeronet_mail
install_zeronet_forum
#install_ipfs
sudo batman start
if [ ! "$?" = "0" ]; then
exit 2
fi
fi
fi
avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
if [ ! -f $PEERS_FILE ]; then
......@@ -511,56 +47,21 @@ if [ ! -f $PEERS_FILE ]; then
exit 0
fi
# count the peers
ctr=0
while IFS='' read -r line || [[ -n "$line" ]]; do
ctr=$((ctr + 1))
done < "$PEERS_FILE"
rm $PEERS_FILE
# enough peers
if [ ${ctr} -lt "1" ]; then
echo $'No peers were found'
exit 0
fi
if [ ! -d $ZERONET_DIR ]; then
echo $'zeronet was not installed'
exit 63
fi
cd $ZERONET_DIR
existing_bttrack=$(ps aux | grep bttrack | wc -l)
if [ $existing_bttrack -lt "2" ]; then
if [ ! -d ~/.bttrack ]; then
mkdir ~/.bttrack
fi
bttrack --port ${TRACKER_PORT} --dfile ~/.bttrack/dstate --logfile ~/.bttrack/tracker.log --nat_check 0 --scrape_allowed full --ipv6_enabled 0 &
fi
existing_ipfs=$(ps aux | grep ipfs | wc -l)
if [ $existing_ipfs -lt "2" ]; then
sudo umount /ipfs
sudo umount /ipns
ipfs daemon --mount &
fi
ZERONET_INDEX=/home/$MY_USERNAME/mesh.html
cp /etc/crontab /tmp/crontab
if ! grep -q "zeronetavahi" /tmp/crontab; then
echo "* * * * * $MY_USERNAME cd /home/$MY_USERNAME; zeronetavahi > /dev/null" >> /tmp/crontab
fi
sudo cp /tmp/crontab /etc/crontab
sleep 8
zeronetavahi
existing_zeronet=$(ps aux | grep zeronet | wc -l)
if [ $existing_zeronet -lt "2" ]; then
python zeronet.py --ip_external $(hostname).local --trackers_file $ZERONET_DIR/bootstrap &
fi
if which firefox > /dev/null; then
firefox $ZERONET_INDEX
elif which iceweasel > /dev/null; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment