diff --git a/src/zeronetavahi b/src/zeronetavahi
index 03b03e6e..c5b001d8 100755
--- a/src/zeronetavahi
+++ b/src/zeronetavahi
@@ -76,346 +76,379 @@ ZERONET_ID_STR="ZeroNet ID Service"
TEMPFILE_BASE=$(mktemp /tmp/zeronetavahibase.XXXXXX)
TEMPFILE=$(mktemp /tmp/zeronetavahi.XXXXXX)
-function ipfs_bootstrap {
- cat $TEMPFILE_BASE | grep "IPFS\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+# List of tox users previously seen
+PREV_TOX_USERS_FILE=/root/.prev_tox_users
- state=0
- address=""
- peer=""
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [ ${state} -eq "3" ]; then
- if [[ $line == *"txt ="* ]]; then
- ipfs_peer_id=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | awk -F '"' '{print $2}')
- ipfs bootstrap add /ip4/${address}/tcp/${IPFS_PORT}/ipfs/${ipfs_peer_id}
- state=0
- fi
- fi
- if [ ${state} -eq "2" ]; then
- if [[ $line == *"address ="* ]]; then
- address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=3
- fi
- fi
- if [ ${state} -eq "1" ]; then
- if [[ $line == *"hostname ="* ]]; then
- peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=2
- fi
- fi
- if [[ $line == *"IPFS"* && $line == "= "* ]]; then
- state=1
- fi
- done < "$TEMPFILE"
+function ipfs_bootstrap {
+ cat $TEMPFILE_BASE | grep "IPFS\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+
+ state=0
+ address=""
+ peer=""
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "3" ]; then
+ if [[ $line == *"txt ="* ]]; then
+ ipfs_peer_id=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | awk -F '"' '{print $2}')
+ ipfs bootstrap add /ip4/${address}/tcp/${IPFS_PORT}/ipfs/${ipfs_peer_id}
+ state=0
+ fi
+ fi
+ if [ ${state} -eq "2" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=3
+ fi
+ fi
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=2
+ fi
+ fi
+ if [[ $line == *"IPFS"* && $line == "= "* ]]; then
+ state=1
+ fi
+ done < "$TEMPFILE"
+}
+
+function detect_new_tox_users {
+ CURRENT_USERS_FILE=$1
+
+ if [ ! -f $CURRENT_USERS_FILE ]; then
+ return
+ fi
+
+ # Check that this is a GUI installation with a desktop
+ if [ ! -d /home/fbone/Desktop ]; then
+ return
+ fi
+
+ # Produce notifications if new users appear
+ if [ -f $PREV_TOX_USERS_FILE ]; then
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if ! grep -q "$line" $PREV_TOX_USERS_FILE; then
+ # get the nick of the user
+ toxuser="$(echo "$line" | awk -F ' ' '{print $1}')"
+
+ notify-send $"$PROJECT_NAME mesh" $"$toxuser has joined the mesh" --icon=dialog-information
+ fi
+ done < "$CURRENT_USERS_FILE"
+ fi
+
+ # Store the previous tox users list
+ cp -f $CURRENT_USERS_FILE $PREV_TOX_USERS_FILE
}
function detect_tox_users {
- # don't show the first peer field
- lstox | awk -F ' ' '{$1=""; print $0}' | sed -e 's/^[[:space:]]*//' | sort -d > $TEMPFILE
+ # don't show the first peer field
+ lstox | awk -F ' ' '{$1=""; print $0}' | sed -e 's/^[[:space:]]*//' | sort -d > $TEMPFILE
- toxctr=0
- echo '
' >> $TOX_USERS_FILE.new
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [[ $line != "Failed*" && $line != "data "* ]]; then
- echo " - $line
" >> $TOX_USERS_FILE.new
- toxctr=$((toxctr + 1))
- fi
- done < "$TEMPFILE"
- if [ $toxctr -eq "0" ]; then
- echo " - ${NO_USERS_STR}
" >> $TOX_USERS_FILE.new
- fi
- echo '' >> $TOX_USERS_FILE.new
+ detect_new_tox_users $TEMPFILE
+
+ toxctr=0
+ echo '' >> $TOX_USERS_FILE.new
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [[ $line != "Failed*" && $line != "data "* ]]; then
+ echo " - $line
" >> $TOX_USERS_FILE.new
+ toxctr=$((toxctr + 1))
+ fi
+ done < "$TEMPFILE"
+ if [ $toxctr -eq "0" ]; then
+ echo " - ${NO_USERS_STR}
" >> $TOX_USERS_FILE.new
+ fi
+ echo '' >> $TOX_USERS_FILE.new
}
function assemble_web_page {
- f="$1"
- fhome="$2"
- cat "${f}-header.html" "${f}.new" "${f}-footer.html" > "${f}.html"
- rm -f "${f}.new"
- if [ -d "${fhome}" ]; then
- sudo chown zeronet:zeronet "$f"
- fi
+ f="$1"
+ fhome="$2"
+ cat "${f}-header.html" "${f}.new" "${f}-footer.html" > "${f}.html"
+ rm -f "${f}.new"
+ if [ -d "${fhome}" ]; then
+ sudo chown zeronet:zeronet "$f"
+ fi
}
function create_index {
- blogaddress=$(cat /home/$MY_USERNAME/.config/zeronet/myblog)
- mailaddress=$(cat /home/$MY_USERNAME/.config/zeronet/mymail)
- forumaddress=$(cat /home/$MY_USERNAME/.config/zeronet/myforum)
- idaddress=$(cat /home/$MY_USERNAME/.config/zeronet/myzeroid)
- if [ -f $ZERONET_INDEX ]; then
- sed -i "s|.*${MY_BLOG_STR}.*| - ${MY_BLOG_STR}
|g" $ZERONET_INDEX
- sed -i "s|.*${MY_MAIL_STR}.*| - ${MY_MAIL_STR}
|g" $ZERONET_INDEX
- sed -i "s|.*${MY_FORUM_STR}.*| - ${MY_FORUM_STR}
|g" $ZERONET_INDEX
- sed -i "s|.*${MY_ID_STR}.*| - ${MY_ID_STR}
|g" $ZERONET_INDEX
- return
- fi
- echo '' > $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo "$WEB_PAGE_TITLE" >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo "$WEB_PAGE_TITLE
" >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo "${YOUR_SITES_STR}
" >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo " - ${MY_BLOG_STR}
" >> $ZERONET_INDEX
- echo " - ${MY_MAIL_STR}
" >> $ZERONET_INDEX
- echo " - ${MY_FORUM_STR}
" >> $ZERONET_INDEX
- echo " - ${MY_ID_STR}
" >> $ZERONET_INDEX
+ blogaddress=$(cat /home/$MY_USERNAME/.config/zeronet/myblog)
+ mailaddress=$(cat /home/$MY_USERNAME/.config/zeronet/mymail)
+ forumaddress=$(cat /home/$MY_USERNAME/.config/zeronet/myforum)
+ idaddress=$(cat /home/$MY_USERNAME/.config/zeronet/myzeroid)
+ if [ -f $ZERONET_INDEX ]; then
+ sed -i "s|.*${MY_BLOG_STR}.*| - ${MY_BLOG_STR}
|g" $ZERONET_INDEX
+ sed -i "s|.*${MY_MAIL_STR}.*| - ${MY_MAIL_STR}
|g" $ZERONET_INDEX
+ sed -i "s|.*${MY_FORUM_STR}.*| - ${MY_FORUM_STR}
|g" $ZERONET_INDEX
+ sed -i "s|.*${MY_ID_STR}.*| - ${MY_ID_STR}
|g" $ZERONET_INDEX
+ return
+ fi
+ echo '' > $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo "$WEB_PAGE_TITLE" >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo "$WEB_PAGE_TITLE
" >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo "${YOUR_SITES_STR}
" >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo " - ${MY_BLOG_STR}
" >> $ZERONET_INDEX
+ echo " - ${MY_MAIL_STR}
" >> $ZERONET_INDEX
+ echo " - ${MY_FORUM_STR}
" >> $ZERONET_INDEX
+ echo " - ${MY_ID_STR}
" >> $ZERONET_INDEX
# echo " - File Share
" >> $ZERONET_INDEX
- echo '
' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo "${ON_THE_MESH_STR}
" >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo " - ${BLOGS_STR}
" >> $ZERONET_INDEX
- echo " - ${MAIL_STR}
" >> $ZERONET_INDEX
- echo " - ${FORA_STR}
" >> $ZERONET_INDEX
- echo " - ${ID_STR}
" >> $ZERONET_INDEX
- echo " - ${TOX_STR}
" >> $ZERONET_INDEX
- echo '
' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
- echo '' >> $ZERONET_INDEX
+ echo '
' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo "${ON_THE_MESH_STR}
" >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo " - ${BLOGS_STR}
" >> $ZERONET_INDEX
+ echo " - ${MAIL_STR}
" >> $ZERONET_INDEX
+ echo " - ${FORA_STR}
" >> $ZERONET_INDEX
+ echo " - ${ID_STR}
" >> $ZERONET_INDEX
+ echo " - ${TOX_STR}
" >> $ZERONET_INDEX
+ echo '
' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
+ echo '' >> $ZERONET_INDEX
}
function create_header {
- header_file=${1}-header.html
- if [ -f $header_file ]; then
- return
- fi
- echo '' > $header_file
- echo '' >> $header_file
- echo '' >> $header_file
- echo "$WEB_PAGE_TITLE - $2" >> $header_file
- echo '' >> $header_file
- echo '' >> $header_file
- echo '' >> $header_file
- echo "$2
" >> $header_file
+ header_file=${1}-header.html
+ if [ -f $header_file ]; then
+ return
+ fi
+ echo '' > $header_file
+ echo '' >> $header_file
+ echo '' >> $header_file
+ echo "$WEB_PAGE_TITLE - $2" >> $header_file
+ echo '' >> $header_file
+ echo '' >> $header_file
+ echo '' >> $header_file
+ echo "$2
" >> $header_file
}
function create_footer {
- footer_file=${1}-footer.html
- if [ -f $footer_file ]; then
- return
- fi
- echo '' >> $footer_file
- echo '' >> $footer_file
+ footer_file=${1}-footer.html
+ if [ -f $footer_file ]; then
+ return
+ fi
+ echo '' >> $footer_file
+ echo '' >> $footer_file
}
function avahi_extract_info {
- # Create a list of bootstrap nodes
- avahi-browse -atr > $TEMPFILE_BASE
- cat $TEMPFILE_BASE | grep "hostname =\|address =\|port =" > $TEMPFILE
- if [ ! -f $TEMPFILE ]; then
- exit 1
- fi
+ # Create a list of bootstrap nodes
+ avahi-browse -atr > $TEMPFILE_BASE
+ cat $TEMPFILE_BASE | grep "hostname =\|address =\|port =" > $TEMPFILE
+ if [ ! -f $TEMPFILE ]; then
+ exit 1
+ fi
}
function zeronet_detect {
- if [ -f $ZERONET_CONFIG.new ]; then
- rm -f $ZERONET_CONFIG.new
- fi
+ if [ -f $ZERONET_CONFIG.new ]; then
+ rm -f $ZERONET_CONFIG.new
+ fi
- touch $ZERONET_CONFIG.new
+ touch $ZERONET_CONFIG.new
- state=0
- address=""
- peer=""
- tracker_ctr=0
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [ ${state} -eq "1" ]; then
- if [[ $line == *"address ="* ]]; then
- address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- tracker_url="http://$peer:$TRACKER_PORT/announce"
- if ! grep -q "$tracker_url" $ZERONET_CONFIG.new; then
- echo "$tracker_url" >> $ZERONET_CONFIG.new
- tracker_ctr=$((tracker_ctr + 1))
- fi
- state=0
- fi
- fi
- if [[ $line == *"hostname ="* ]]; then
- peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=1
- fi
- done < "$TEMPFILE"
+ state=0
+ address=""
+ peer=""
+ tracker_ctr=0
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ tracker_url="http://$peer:$TRACKER_PORT/announce"
+ if ! grep -q "$tracker_url" $ZERONET_CONFIG.new; then
+ echo "$tracker_url" >> $ZERONET_CONFIG.new
+ tracker_ctr=$((tracker_ctr + 1))
+ fi
+ state=0
+ fi
+ fi
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=1
+ fi
+ done < "$TEMPFILE"
}
function zeronet_detect_blog {
- if [ -f $BLOGS_FILE.new ]; then
- rm -f $BLOGS_FILE.new
- fi
+ if [ -f $BLOGS_FILE.new ]; then
+ rm -f $BLOGS_FILE.new
+ fi
- cat $TEMPFILE_BASE | grep "${ZERONET_BLOG_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+ cat $TEMPFILE_BASE | grep "${ZERONET_BLOG_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
- state=0
- address=""
- peer=""
- echo '' >> $BLOGS_FILE.new
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [ ${state} -eq "3" ]; then
- if [[ $line == *"txt ="* ]]; then
- blog_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- echo " - ${peer}
" >> $BLOGS_FILE.new
- state=0
- fi
- fi
- if [ ${state} -eq "2" ]; then
- if [[ $line == *"address ="* ]]; then
- address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=3
- fi
- fi
- if [ ${state} -eq "1" ]; then
- if [[ $line == *"hostname ="* ]]; then
- peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=2
- fi
- fi
- if [[ $line == *"${ZERONET_BLOG_STR}"* && $line == "= "* ]]; then
- state=1
- fi
- done < "$TEMPFILE"
- echo '
' >> $BLOGS_FILE.new
+ state=0
+ address=""
+ peer=""
+ echo '' >> $BLOGS_FILE.new
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "3" ]; then
+ if [[ $line == *"txt ="* ]]; then
+ blog_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ echo " - ${peer}
" >> $BLOGS_FILE.new
+ state=0
+ fi
+ fi
+ if [ ${state} -eq "2" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=3
+ fi
+ fi
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=2
+ fi
+ fi
+ if [[ $line == *"${ZERONET_BLOG_STR}"* && $line == "= "* ]]; then
+ state=1
+ fi
+ done < "$TEMPFILE"
+ echo '
' >> $BLOGS_FILE.new
}
function zeronet_detect_mail {
- if [ -f $MAIL_FILE.new ]; then
- rm -f $MAIL_FILE.new
- fi
+ if [ -f $MAIL_FILE.new ]; then
+ rm -f $MAIL_FILE.new
+ fi
- cat $TEMPFILE_BASE | grep "${ZERONET_MAIL_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+ cat $TEMPFILE_BASE | grep "${ZERONET_MAIL_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
- state=0
- address=""
- peer=""
- echo '' >> $MAIL_FILE.new
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [ ${state} -eq "3" ]; then
- if [[ $line == *"txt ="* ]]; then
- mail_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- echo " - ${peer}
" >> $MAIL_FILE.new
- state=0
- fi
- fi
- if [ ${state} -eq "2" ]; then
- if [[ $line == *"address ="* ]]; then
- address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=3
- fi
- fi
- if [ ${state} -eq "1" ]; then
- if [[ $line == *"hostname ="* ]]; then
- peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=2
- fi
- fi
- if [[ $line == *"${ZERONET_MAIL_STR}"* && $line == "= "* ]]; then
- state=1
- fi
- done < "$TEMPFILE"
- echo '
' >> $MAIL_FILE.new
+ state=0
+ address=""
+ peer=""
+ echo '' >> $MAIL_FILE.new
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "3" ]; then
+ if [[ $line == *"txt ="* ]]; then
+ mail_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ echo " - ${peer}
" >> $MAIL_FILE.new
+ state=0
+ fi
+ fi
+ if [ ${state} -eq "2" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=3
+ fi
+ fi
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=2
+ fi
+ fi
+ if [[ $line == *"${ZERONET_MAIL_STR}"* && $line == "= "* ]]; then
+ state=1
+ fi
+ done < "$TEMPFILE"
+ echo '
' >> $MAIL_FILE.new
}
function zeronet_detect_fora {
- if [ -f $FORUM_FILE.new ]; then
- rm -f $FORUM_FILE.new
- fi
+ if [ -f $FORUM_FILE.new ]; then
+ rm -f $FORUM_FILE.new
+ fi
- cat $TEMPFILE_BASE | grep "${ZERONET_FORUM_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+ cat $TEMPFILE_BASE | grep "${ZERONET_FORUM_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
- state=0
- address=""
- peer=""
- echo '' >> $FORUM_FILE.new
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [ ${state} -eq "3" ]; then
- if [[ $line == *"txt ="* ]]; then
- forum_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- echo " - ${peer}
" >> $FORUM_FILE.new
- state=0
- fi
- fi
- if [ ${state} -eq "2" ]; then
- if [[ $line == *"address ="* ]]; then
- address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=3
- fi
- fi
- if [ ${state} -eq "1" ]; then
- if [[ $line == *"hostname ="* ]]; then
- peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=2
- fi
- fi
- if [[ $line == *"${ZERONET_FORUM_STR}"* && $line == "= "* ]]; then
- state=1
- fi
- done < "$TEMPFILE"
- echo '' >> $FORUM_FILE.new
+ state=0
+ address=""
+ peer=""
+ echo '' >> $FORUM_FILE.new
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "3" ]; then
+ if [[ $line == *"txt ="* ]]; then
+ forum_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ echo " - ${peer}
" >> $FORUM_FILE.new
+ state=0
+ fi
+ fi
+ if [ ${state} -eq "2" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=3
+ fi
+ fi
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=2
+ fi
+ fi
+ if [[ $line == *"${ZERONET_FORUM_STR}"* && $line == "= "* ]]; then
+ state=1
+ fi
+ done < "$TEMPFILE"
+ echo '' >> $FORUM_FILE.new
}
function zeronet_detect_id {
- if [ -f $ID_FILE.new ]; then
- rm -f $ID_FILE.new
- fi
+ if [ -f $ID_FILE.new ]; then
+ rm -f $ID_FILE.new
+ fi
- cat $TEMPFILE_BASE | grep "${ZERONET_ID_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
+ cat $TEMPFILE_BASE | grep "${ZERONET_ID_STR}\|hostname =\|address =\|port =\|txt =" > $TEMPFILE
- state=0
- address=""
- peer=""
- echo '' >> $ID_FILE.new
- while IFS='' read -r line || [[ -n "$line" ]]; do
- if [ ${state} -eq "3" ]; then
- if [[ $line == *"txt ="* ]]; then
- id_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- echo " - ${peer}
" >> $ID_FILE.new
- state=0
- fi
- fi
- if [ ${state} -eq "2" ]; then
- if [[ $line == *"address ="* ]]; then
- address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=3
- fi
- fi
- if [ ${state} -eq "1" ]; then
- if [[ $line == *"hostname ="* ]]; then
- peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
- state=2
- fi
- fi
- if [[ $line == *"${ZERONET_ID_STR}"* && $line == "= "* ]]; then
- state=1
- fi
- done < "$TEMPFILE"
- echo '
' >> $ID_FILE.new
+ state=0
+ address=""
+ peer=""
+ echo '' >> $ID_FILE.new
+ while IFS='' read -r line || [[ -n "$line" ]]; do
+ if [ ${state} -eq "3" ]; then
+ if [[ $line == *"txt ="* ]]; then
+ id_url=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ echo " - ${peer}
" >> $ID_FILE.new
+ state=0
+ fi
+ fi
+ if [ ${state} -eq "2" ]; then
+ if [[ $line == *"address ="* ]]; then
+ address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=3
+ fi
+ fi
+ if [ ${state} -eq "1" ]; then
+ if [[ $line == *"hostname ="* ]]; then
+ peer=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
+ state=2
+ fi
+ fi
+ if [[ $line == *"${ZERONET_ID_STR}"* && $line == "= "* ]]; then
+ state=1
+ fi
+ done < "$TEMPFILE"
+ echo '
' >> $ID_FILE.new
}
function avahi_remove_info {
- rm -f $TEMPFILE_BASE
- rm -f $TEMPFILE
+ rm -f $TEMPFILE_BASE
+ rm -f $TEMPFILE
}
function zeronet_update_config {
- if [ ${tracker_ctr} -gt "0" ]; then
- cp -f $ZERONET_CONFIG.new $ZERONET_CONFIG
- else
- if [ -f $ZERONET_CONFIG ]; then
- rm -f $ZERONET_CONFIG
- fi
- fi
- rm -f $ZERONET_CONFIG.new
- if [ -d $ZERONET_INSTALL ]; then
- sudo chown zeronet:zeronet $ZERONET_CONFIG
- fi
+ if [ ${tracker_ctr} -gt "0" ]; then
+ cp -f $ZERONET_CONFIG.new $ZERONET_CONFIG
+ else
+ if [ -f $ZERONET_CONFIG ]; then
+ rm -f $ZERONET_CONFIG
+ fi
+ fi
+ rm -f $ZERONET_CONFIG.new
+ if [ -d $ZERONET_INSTALL ]; then
+ sudo chown zeronet:zeronet $ZERONET_CONFIG
+ fi
}
if [ ! -d /etc/avahi ]; then
- exit 0
+ exit 0
fi
avahi_extract_info