List Tox users on the mesh

This commit is contained in:
Bob Mottram 2015-09-04 21:28:11 +01:00
parent d498247e3d
commit 8c0ce3e25f
1 changed files with 27 additions and 0 deletions

View File

@ -48,6 +48,7 @@ fi
BOOTSTRAP_FILE=$ZERONET_INSTALL/bootstrap
BLOGS_FILE=$ZERONET_INSTALL/freedombone-blogs
FORUM_FILE=$ZERONET_INSTALL/freedombone-fora
TOX_USERS_FILE=$ZERONET_INSTALL/freedombone-tox-users
ZERONET_INDEX=/home/$MY_USERNAME/mesh.html
function create_index {
@ -74,6 +75,7 @@ function create_index {
echo '<ol type="square">' >> $ZERONET_INDEX
echo " <li><a href=\"${BLOGS_FILE}.html\">Blogs</a></li>" >> $ZERONET_INDEX
echo " <li><a href=\"${FORUM_FILE}.html\">Fora</a></li>" >> $ZERONET_INDEX
echo " <li><a href=\"${TOX_USERS_FILE}.html\">Tox Users</a></li>" >> $ZERONET_INDEX
echo '</ol>' >> $ZERONET_INDEX
echo '' >> $ZERONET_INDEX
echo '</body>' >> $ZERONET_INDEX
@ -217,6 +219,22 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
done < "$TEMPFILE"
echo '<ol>' >> $FORUM_FILE.new
# detect Tox users
lstox > $TEMPFILE
toxctr=0
echo '<ol type="square">' >> $TOX_USERS_FILE.new
while IFS='' read -r line || [[ -n "$line" ]]; do
if [[ $line != "Failed*" ]]; then
echo " <li>$line</li>" >> $TOX_USERS_FILE.new
toxctr=$((toxctr + 1))
fi
done < "$TEMPFILE"
if [ $toxctr -eq "0" ]; then
echo " <li>No users found</li>" >> $TOX_USERS_FILE.new
fi
echo '<ol>' >> $TOX_USERS_FILE.new
rm -f $TEMPFILE_BASE
rm -f $TEMPFILE
@ -229,8 +247,10 @@ fi
# make some html headers and footers
create_header $BLOGS_FILE "Blogs"
create_header $FORUM_FILE "Fora"
create_header $TOX_USERS_FILE "Tox Users"
create_footer $BLOGS_FILE
create_footer $FORUM_FILE
create_footer $TOX_USERS_FILE
# make the index page
create_index
@ -249,4 +269,11 @@ if [ -d $ZERONET_USER_HOME ]; then
sudo chown zeronet:zeronet $FORUM_FILE
fi
# create a web page showing Tox users
cat ${TOX_USERS_FILE}-header.html ${TOX_USERS_FILE}.new ${TOX_USERS_FILE}-footer.html > ${TOX_USERS_FILE}.html
rm -f ${TOX_USERS_FILE}.new
if [ -d $ZERONET_USER_HOME ]; then
sudo chown zeronet:zeronet $TOX_USERS_FILE
fi
exit 0