2015-08-30 12:50:50 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# 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"
|
|
|
|
|
2015-08-30 13:09:32 +02:00
|
|
|
PEERS_FILE=/tmp/meshwebstart
|
|
|
|
|
2015-09-11 17:18:13 +02:00
|
|
|
ZERONET_REPO='https://github.com/HelloZeroNet/ZeroNet'
|
2015-09-02 22:41:11 +02:00
|
|
|
ZERONET_BLOG_REPO='https://github.com/HelloZeroNet/ZeroBlog'
|
2015-09-04 12:06:51 +02:00
|
|
|
ZERONET_FORUM_REPO='https://github.com/HelloZeroNet/ZeroTalk'
|
2015-08-30 12:50:50 +02:00
|
|
|
ZERONET_URL=http://127.0.0.1:43110
|
2015-09-02 23:10:12 +02:00
|
|
|
ZERONET_PORT=15441
|
2015-08-30 12:50:50 +02:00
|
|
|
TRACKER_PORT=6969
|
2015-09-02 22:41:11 +02:00
|
|
|
MY_USERNAME=$USER
|
2015-09-03 15:31:13 +02:00
|
|
|
ZERONET_DIR=/home/$MY_USERNAME/zeronet
|
2015-09-03 19:40:31 +02:00
|
|
|
UPDATED="no"
|
2015-09-03 20:55:15 +02:00
|
|
|
ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh"
|
2015-09-03 21:38:55 +02:00
|
|
|
ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group"
|
2015-09-02 22:41:11 +02:00
|
|
|
|
2015-09-30 12:53:18 +02:00
|
|
|
function install_ipfs {
|
|
|
|
if [ ! -f /home/$MY_USERNAME/go/bin/ipfs ]; then
|
|
|
|
sudo apt-get -y install golang libpam0g-dev fuse
|
|
|
|
if ! grep -q "GOPATH/bin" /home/$MY_USERNAME/.bashrc; then
|
2015-09-30 13:31:13 +02:00
|
|
|
echo "export GOPATH=/home/$MY_USERNAME/go" >> /home/$MY_USERNAME/.bashrc
|
2015-09-30 12:53:18 +02:00
|
|
|
echo 'export PATH="$GOPATH/bin:$PATH:";' >> /home/$MY_USERNAME/.bashrc
|
|
|
|
chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.bashrc
|
|
|
|
. ~/.bashrc
|
|
|
|
fi
|
|
|
|
if [ ! -d /home/$MY_USERNAME/go ]; then
|
|
|
|
mkdir /home/$MY_USERNAME/go
|
|
|
|
fi
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
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
|
|
|
|
|
2015-09-02 23:10:12 +02:00
|
|
|
if [ ! -d /etc/avahi ]; then
|
|
|
|
echo 'Avahi is not installed'
|
|
|
|
exit 736
|
|
|
|
fi
|
|
|
|
|
2015-09-04 13:27:33 +02:00
|
|
|
ZERONET_DEFAULT_BLOG_TITLE="${MY_USERNAME}'s Blog"
|
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
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:]]/}
|
|
|
|
|
2015-09-03 12:55:59 +02:00
|
|
|
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
|
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
if [ ! -d "$ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS" ]; then
|
2015-09-02 23:10:12 +02:00
|
|
|
echo "Unable to find site directory: $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS"
|
2015-09-02 22:41:11 +02:00
|
|
|
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
|
2015-09-03 15:28:31 +02:00
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
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
|
2015-09-03 20:55:15 +02:00
|
|
|
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
|
2015-09-03 15:28:31 +02:00
|
|
|
sed -i "s/Blogging platform Demo/Blogging platform/g" $ZERONET_DIR/data/$ZERONET_BLOG_ADDRESS/content.json
|
2015-09-02 22:41:11 +02:00
|
|
|
python zeronet.py siteSign $ZERONET_BLOG_ADDRESS $ZERONET_BLOG_PRIVATE_KEY
|
|
|
|
|
2015-09-02 23:10:12 +02:00
|
|
|
# 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
|
|
|
|
|
2015-09-03 13:09:09 +02:00
|
|
|
if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
|
|
|
|
mkdir -p /home/$MY_USERNAME/.config/zeronet
|
2015-09-04 23:06:43 +02:00
|
|
|
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
|
2015-09-03 13:09:09 +02:00
|
|
|
fi
|
2015-09-03 13:20:32 +02:00
|
|
|
echo "$ZERONET_URL/$ZERONET_BLOG_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/myblog
|
2015-09-03 13:09:09 +02:00
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
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_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
|
|
|
|
|
2015-09-02 23:10:12 +02:00
|
|
|
if [ ! -d /etc/avahi ]; then
|
|
|
|
echo 'Avahi is not installed'
|
|
|
|
exit 736
|
|
|
|
fi
|
|
|
|
|
2015-09-04 13:27:33 +02:00
|
|
|
ZERONET_DEFAULT_FORUM_TITLE="${MY_USERNAME}'s Forum"
|
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
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:]]/}
|
|
|
|
|
2015-09-03 12:55:59 +02:00
|
|
|
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
|
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
if [ ! -d "$ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS" ]; then
|
2015-09-02 23:10:12 +02:00
|
|
|
echo "Unable to find site directory: $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS"
|
2015-09-02 22:41:11 +02:00
|
|
|
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
|
|
|
|
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
|
2015-09-03 21:38:55 +02:00
|
|
|
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
|
2015-09-03 21:41:49 +02:00
|
|
|
sed -i "s|Demo for dynamic, decentralized content publishing.|$ZERONET_DEFAULT_FORUM_TAGLINE|g" $ZERONET_DIR/data/$ZERONET_FORUM_ADDRESS/index.html
|
2015-09-03 21:38:55 +02:00
|
|
|
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
|
2015-09-06 16:28:54 +02:00
|
|
|
python zeronet.py siteSign $ZERONET_FORUM_ADDRESS $ZERONET_FORUM_PRIVATE_KEY
|
2015-09-06 12:44:04 +02:00
|
|
|
python zeronet.py siteSign $ZERONET_FORUM_ADDRESS $ZERONET_FORUM_PRIVATE_KEY --inner_path data/users/content.json
|
2015-09-02 22:41:11 +02:00
|
|
|
|
2015-09-02 23:10:12 +02:00
|
|
|
# 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
|
|
|
|
|
2015-09-03 13:09:09 +02:00
|
|
|
if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
|
|
|
|
mkdir -p /home/$MY_USERNAME/.config/zeronet
|
2015-09-04 23:06:43 +02:00
|
|
|
chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.config
|
2015-09-03 13:09:09 +02:00
|
|
|
fi
|
2015-09-03 13:20:32 +02:00
|
|
|
echo "$ZERONET_URL/$ZERONET_FORUM_ADDRESS" > /home/$MY_USERNAME/.config/zeronet/myforum
|
2015-09-03 13:09:09 +02:00
|
|
|
|
2015-09-02 22:41:11 +02:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2015-08-31 14:01:09 +02:00
|
|
|
function install_web_server {
|
|
|
|
if [ -d /etc/nginx ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2015-09-03 19:40:31 +02:00
|
|
|
if [[ $UPDATED == "no" ]]; then
|
|
|
|
sudo apt-get update
|
|
|
|
UPDATED="yes"
|
|
|
|
fi
|
|
|
|
|
2015-08-31 14:01:09 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-08-30 12:50:50 +02:00
|
|
|
function install_zeronet {
|
2015-09-03 19:40:31 +02:00
|
|
|
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
|
2015-09-11 17:18:13 +02:00
|
|
|
#cd $ZERONET_DIR
|
|
|
|
#git checkout bashrc/bootstrap-file
|
2015-09-04 13:27:33 +02:00
|
|
|
# Hack to ensure that the file access port is opened
|
2015-09-04 12:06:51 +02:00
|
|
|
# This is because zeronet normally relies on an internet site
|
|
|
|
# to do this, but on a purely local mesh the internet isn't available
|
2015-09-12 11:30:56 +02:00
|
|
|
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
|
2015-08-30 12:50:50 +02:00
|
|
|
}
|
|
|
|
|
2015-09-30 13:16:39 +02:00
|
|
|
if [[ "$1" == "stop" ]]; then
|
|
|
|
sudo batman stop
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2015-08-30 12:50:50 +02:00
|
|
|
if [ -f /var/lib/batman ]; then
|
|
|
|
SERVER_INSTALLATION="yes"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $SERVER_INSTALLATION == "no" ]]; then
|
|
|
|
if [ ! -f /usr/bin/batman ]; then
|
|
|
|
freedombone-client
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $SERVER_INSTALLATION == "no" ]]; then
|
|
|
|
if [ ! -f /tmp/meshtype ]; then
|
2015-08-31 14:01:09 +02:00
|
|
|
install_web_server
|
2015-08-30 12:50:50 +02:00
|
|
|
install_zeronet
|
2015-09-02 22:41:11 +02:00
|
|
|
install_zeronet_blog
|
|
|
|
install_zeronet_forum
|
2015-09-30 12:53:18 +02:00
|
|
|
install_ipfs
|
2015-08-30 12:50:50 +02:00
|
|
|
sudo batman start
|
|
|
|
if [ ! "$?" = "0" ]; then
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-09-11 20:36:04 +02:00
|
|
|
avahi-browse -atl | awk -F ' ' '{print $4}' | sort -u > $PEERS_FILE
|
2015-08-30 12:50:50 +02:00
|
|
|
|
|
|
|
if [ ! -f $PEERS_FILE ]; then
|
|
|
|
echo 'No peers were found'
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
ctr=0
|
|
|
|
while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
|
|
ctr=$((ctr + 1))
|
|
|
|
done < "$PEERS_FILE"
|
|
|
|
|
2015-08-30 13:09:32 +02:00
|
|
|
rm $PEERS_FILE
|
|
|
|
|
2015-08-30 12:50:50 +02:00
|
|
|
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
|
2015-08-31 14:01:09 +02:00
|
|
|
if [ ! -d ~/.bttrack ]; then
|
|
|
|
mkdir ~/.bttrack
|
|
|
|
fi
|
2015-08-31 11:44:50 +02:00
|
|
|
bttrack --port ${TRACKER_PORT} --dfile ~/.bttrack/dstate --logfile ~/.bttrack/tracker.log --nat_check 0 --scrape_allowed full --ipv6_enabled 0 &
|
2015-08-30 12:50:50 +02:00
|
|
|
fi
|
|
|
|
|
2015-09-30 13:22:00 +02:00
|
|
|
existing_ipfs=$(ps aux | grep ipfs | wc -l)
|
|
|
|
if [ $existing_ipfs -lt "2" ]; then
|
|
|
|
ipfs daemon --mount
|
|
|
|
fi
|
|
|
|
|
2015-09-03 13:49:24 +02:00
|
|
|
ZERONET_INDEX=/home/$MY_USERNAME/mesh.html
|
|
|
|
|
2015-09-03 17:45:27 +02:00
|
|
|
cp /etc/crontab /tmp/crontab
|
|
|
|
if ! grep -q "zeronetavahi" /tmp/crontab; then
|
2015-09-14 10:20:46 +02:00
|
|
|
echo "* * * * * $MY_USERNAME cd /home/$MY_USERNAME; zeronetavahi > /dev/null" >> /tmp/crontab
|
2015-09-03 17:45:27 +02:00
|
|
|
fi
|
|
|
|
sudo cp /tmp/crontab /etc/crontab
|
2015-09-04 13:33:39 +02:00
|
|
|
|
|
|
|
sleep 8
|
2015-08-30 12:50:50 +02:00
|
|
|
zeronetavahi
|
|
|
|
|
|
|
|
existing_zeronet=$(ps aux | grep zeronet | wc -l)
|
|
|
|
if [ $existing_zeronet -lt "2" ]; then
|
2015-09-12 19:48:34 +02:00
|
|
|
python zeronet.py --ip_external $(hostname).local --trackers_file $ZERONET_DIR/bootstrap &
|
2015-08-30 12:50:50 +02:00
|
|
|
fi
|
|
|
|
|
2015-09-03 19:50:29 +02:00
|
|
|
if which firefox > /dev/null; then
|
|
|
|
firefox $ZERONET_INDEX
|
|
|
|
elif which chrome > /dev/null; then
|
|
|
|
chrome $ZERONET_INDEX
|
|
|
|
elif which chromium > /dev/null; then
|
|
|
|
chromium $ZERONET_INDEX
|
|
|
|
elif which xdg-open > /dev/null; then
|
2015-09-03 13:49:24 +02:00
|
|
|
xdg-open $ZERONET_INDEX
|
2015-08-30 12:50:50 +02:00
|
|
|
elif which gnome-open > /dev/null; then
|
2015-09-03 13:49:24 +02:00
|
|
|
gnome-open $ZERONET_INDEX
|
2015-08-30 12:50:50 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|