ipfs avahi for mesh
This commit is contained in:
parent
1d994359ec
commit
87f9e68933
|
@ -728,19 +728,19 @@ function setup_ipfs {
|
|||
IPFS_KEY_LENGTH=2048
|
||||
|
||||
su -c "$IPFS_PATH/jsipfs init -b $IPFS_KEY_LENGTH" - $MY_USERNAME
|
||||
if [ ! -d ${rootdir}/home/$MY_USERNAME/.ipfs ]; then
|
||||
if [ ! -d /home/$MY_USERNAME/.ipfs ]; then
|
||||
echo "IPFS could not be initialised for user $MY_USERNAME" >> $INSTALL_LOG
|
||||
exit 7358
|
||||
fi
|
||||
|
||||
TEMP_IPFS_ID=/tmp/ipfsid
|
||||
su -c "echo $($IPFS_PATH/jsipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > $TEMP_IPFS_ID" - $MY_USERNAME
|
||||
if [ ! -f $TEMP_IPFS_ID ]; then
|
||||
MY_IPFS_ID=/home/$MY_USERNAME/.ipfs-id
|
||||
su -c "echo $($IPFS_PATH/jsipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > $MY_IPFS_ID" - $MY_USERNAME
|
||||
if [ ! -f $MY_IPFS_ID ]; then
|
||||
echo 'No IPFS identity was created' >> $INSTALL_LOG
|
||||
exit 37895
|
||||
fi
|
||||
|
||||
IPFS_PEER_ID=$(cat $TEMP_IPFS_ID)
|
||||
IPFS_PEER_ID=$(cat $MY_IPFS_ID)
|
||||
if [ ${#IPFS_PEER_ID} -lt 10 ]; then
|
||||
echo 'Invalid IPFS peer ID' >> $INSTALL_LOG
|
||||
echo "$IPFS_PEER_ID" >> $INSTALL_LOG
|
||||
|
@ -749,7 +749,6 @@ function setup_ipfs {
|
|||
|
||||
# TODO in avahi service for ipfs replace IPFS_PEER_ID
|
||||
|
||||
rm $TEMP_IPFS_ID
|
||||
echo 'IPFS installed with ID $IPFS_PEER_ID' >> $INSTALL_LOG
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,6 @@ sed -i "s|Wifi channel:.*|Wifi channel:${CHANNEL}|g" $COMPLETION_FILE
|
|||
|
||||
ZERONET_PORT=15441
|
||||
IPFS_PORT=4001
|
||||
SYNCTHING_PORT=22000
|
||||
|
||||
# Ethernet bridge definition (bridged to bat0)
|
||||
BRIDGE=br-mesh
|
||||
|
@ -134,8 +133,7 @@ function stop {
|
|||
iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT
|
||||
iptables -D INPUT -p udp --dport $ZERONET_PORT -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT
|
||||
iptables -D INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
iptables -D INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
|
||||
iptables -D INPUT -p udp --dport $IPFS_PORT -j ACCEPT
|
||||
|
||||
systemctl restart network-manager
|
||||
}
|
||||
|
|
|
@ -458,6 +458,32 @@ function zeronet_update_config {
|
|||
fi
|
||||
}
|
||||
|
||||
function avahi_ipfs {
|
||||
MY_IPFS_ID=/home/$MESH_USERNAME/.ipfs-id
|
||||
if [ ! -f $MY_IPFS_ID ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
service_name='ipfs'
|
||||
service_type='IPFS'
|
||||
service_protocol='tcp'
|
||||
service_port=$IPFS_PORT
|
||||
service_description=$(cat $MY_IPFS_ID)
|
||||
|
||||
echo '<?xml version="1.0" standalone="no"?><!--*-nxml-*-->' > /etc/avahi/services/${service_name}.service
|
||||
echo '<!DOCTYPE service-group SYSTEM "avahi-service.dtd">' >> /etc/avahi/services/${service_name}.service
|
||||
echo '<service-group>' >> /etc/avahi/services/${service_name}.service
|
||||
echo " <name replace-wildcards=\"yes\">%h ${service_type}</name>" >> /etc/avahi/services/${service_name}.service
|
||||
echo ' <service>' >> /etc/avahi/services/${service_name}.service
|
||||
echo " <type>_${service_type}._${service_protocol}</type>" >> /etc/avahi/services/${service_name}.service
|
||||
echo " <port>${service_port}</port>" >> /etc/avahi/services/${service_name}.service
|
||||
if [ "$service_description" ]; then
|
||||
echo " <txt-record>$service_description</txt-record>" >> /tmp/zeronet-blog.service
|
||||
fi
|
||||
echo ' </service>' >> /etc/avahi/services/${service_name}.service
|
||||
echo '</service-group>' >> /etc/avahi/services/${service_name}.service
|
||||
}
|
||||
|
||||
if [ ! -d /etc/avahi ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
@ -472,6 +498,7 @@ if [ $ENABLE_ZERONET ]; then
|
|||
zeronet_update_config
|
||||
fi
|
||||
|
||||
avahi_ipfs
|
||||
ipfs_bootstrap
|
||||
#detect_tox_users
|
||||
avahi_remove_info
|
||||
|
|
Loading…
Reference in New Issue