Bläddra i källkod

avahi service for mesh client

Bob Mottram 9 år sedan
förälder
incheckning
9a5ae567cf
1 ändrade filer med 22 tillägg och 0 borttagningar
  1. 22
    0
      src/freedombone-meshweb

+ 22
- 0
src/freedombone-meshweb Visa fil

20
 ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh"
20
 ZERONET_DEFAULT_BLOG_TAGLINE="Blogging on the Mesh"
21
 ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group"
21
 ZERONET_DEFAULT_FORUM_TAGLINE="A decentralized discussion group"
22
 
22
 
23
+IPFS_PORT=4001
24
+
23
 function install_ipfs {
25
 function install_ipfs {
24
   if [ ! -f /home/$MY_USERNAME/go/bin/ipfs ]; then
26
   if [ ! -f /home/$MY_USERNAME/go/bin/ipfs ]; then
25
       if [ ! -d /usr/local/go ]; then
27
       if [ ! -d /usr/local/go ]; then
68
           sudo chown $MY_USERNAME:$MY_USERNAME /dev/fuse
70
           sudo chown $MY_USERNAME:$MY_USERNAME /dev/fuse
69
       fi
71
       fi
70
   fi
72
   fi
73
+
74
+  IPFS_PEER_ID=$(ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}')
75
+  if [ ${#IPFS_PEER_ID} -lt 10 ]; then
76
+      echo 'Invalid IPFS peer ID'
77
+      echo "$IPFS_PEER_ID"
78
+      exit 74782
79
+  fi
80
+
81
+  # Add an avahi service
82
+  echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /tmp/ipfs.service
83
+  echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /tmp/ipfs.service
84
+  echo '<service-group>' >> /tmp/ipfs.service
85
+  echo '  <name replace-wildcards="yes">%h IPFS</name>' >> /tmp/ipfs.service
86
+  echo '  <service>' >> /tmp/ipfs.service
87
+  echo '    <type>_ipfs._tcp</type>' >> /tmp/ipfs.service
88
+  echo "    <port>$IPFS_PORT</port>" >> /tmp/ipfs.service
89
+  echo "    <txt-record>$IPFS_PEER_ID</txt-record>" >> /tmp/ipfs.service
90
+  echo '  </service>' >> /tmp/ipfs.service
91
+  echo '</service-group>' >> /tmp/ipfs.service
92
+  sudo cp /tmp/ipfs.service /etc/avahi/services/ipfs.service
71
 }
93
 }
72
 
94
 
73
 function install_zeronet_blog {
95
 function install_zeronet_blog {