avahi service for mesh client

This commit is contained in:
Bob Mottram 2015-09-30 18:48:19 +01:00
parent 5eddc76006
commit 9a5ae567cf
1 changed files with 22 additions and 0 deletions

View File

@ -20,6 +20,8 @@ UPDATED="no"
ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh" ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh"
ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group" ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group"
IPFS_PORT=4001
function install_ipfs { function install_ipfs {
if [ ! -f /home/$MY_USERNAME/go/bin/ipfs ]; then if [ ! -f /home/$MY_USERNAME/go/bin/ipfs ]; then
if [ ! -d /usr/local/go ]; then if [ ! -d /usr/local/go ]; then
@ -68,6 +70,26 @@ function install_ipfs {
sudo chown $MY_USERNAME:$MY_USERNAME /dev/fuse sudo chown $MY_USERNAME:$MY_USERNAME /dev/fuse
fi fi
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 { function install_zeronet_blog {