freedombonee/src/freedombone-meshweb

80 lines
2.1 KiB
Plaintext
Raw Normal View History

2015-08-30 12:50:50 +02:00
#!/bin/bash
2016-02-13 23:09:27 +01:00
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Web interface for the mesh
#
# License
# =======
#
# Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2015-08-30 12:50:50 +02:00
2015-11-27 12:42:16 +01:00
PROJECT_NAME='freedombone'
2015-11-27 17:52:23 +01:00
export TEXTDOMAIN=${PROJECT_NAME}-meshweb
2015-11-27 12:42:16 +01:00
export TEXTDOMAINDIR="/usr/share/locale"
2016-06-26 00:46:05 +02:00
MESH_INSTALL_DIR=/var/lib
PEERS_FILE=/tmp/meshwebstart
2015-08-30 12:50:50 +02:00
2016-06-26 00:46:05 +02:00
if [ -d $MESH_INSTALL_DIR/zeronet ]; then
ZERONET_DIR=$MESH_INSTALL_DIR/zeronet
2016-06-25 17:51:04 +02:00
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
2015-11-27 16:29:43 +01:00
echo $'No peers were found'
2015-08-30 12:50:50 +02:00
exit 0
fi
# count the peers
2015-08-30 12:50:50 +02:00
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
# enough peers
2015-08-30 12:50:50 +02:00
if [ ${ctr} -lt "1" ]; then
2015-11-27 16:29:43 +01:00
echo $'No peers were found'
2015-08-30 12:50:50 +02:00
exit 0
fi
2016-07-16 18:43:31 +02:00
ZERONET_INDEX=$MESH_INSTALL_DIR/zeronet/mesh.html
2015-09-03 13:49:24 +02:00
2015-09-03 19:50:29 +02:00
if which firefox > /dev/null; then
firefox $ZERONET_INDEX
2016-06-25 17:51:04 +02:00
elif which iceweasel > /dev/null; then
iceweasel $ZERONET_INDEX
2015-09-03 19:50:29 +02:00
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