avahi service for ipfs

This commit is contained in:
Bob Mottram 2015-09-30 17:28:26 +01:00
parent 6af67d0c7e
commit 5eddc76006
1 changed files with 27 additions and 1 deletions

View File

@ -1722,7 +1722,7 @@ function install_zeronet_blog {
echo " <txt-record>$ZERONET_URL/$ZERONET_BLOG_ADDRESS</txt-record>" >> /tmp/zeronet-blog.service
echo ' </service>' >> /tmp/zeronet-blog.service
echo '</service-group>' >> /tmp/zeronet-blog.service
sudo cp /tmp/zeronet-blog.service /etc/avahi/services/zeronet-blog.service
cp /tmp/zeronet-blog.service /etc/avahi/services/zeronet-blog.service
if [ ! -d /home/$MY_USERNAME/.config/zeronet ]; then
mkdir -p /home/$MY_USERNAME/.config/zeronet
@ -10416,6 +10416,32 @@ function install_ipfs {
systemctl daemon-reload
systemctl restart ipfs
if [ -d /etc/avahi ]; then
su -c "echo $($IPFS_PATH/ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > /tmp/ipfsid" - $MY_USERNAME
if [ ! -f /tmp/ipfsid ]; then
echo 'No IPFS identity was created'
exit 37895
fi
IPFS_PEER_ID=$(cat /tmp/ipfsid)
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-*-->' > /etc/avahi/services/ipfs.service
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/ipfs.service
echo '<service-group>' >> /etc/avahi/services/ipfs.service
echo ' <name replace-wildcards="yes">%h IPFS</name>' >> /etc/avahi/services/ipfs.service
echo ' <service>' >> /etc/avahi/services/ipfs.service
echo ' <type>_ipfs._tcp</type>' >> /etc/avahi/services/ipfs.service
echo " <port>$IPFS_PORT</port>" >> /etc/avahi/services/ipfs.service
echo " <txt-record>$IPFS_PEER_ID</txt-record>" >> /etc/avahi/services/ipfs.service
echo ' </service>' >> /etc/avahi/services/ipfs.service
echo '</service-group>' >> /etc/avahi/services/ipfs.service
rm /tmp/ipfsid
fi
echo 'install_ipfs' >> $COMPLETION_FILE
}