ipfs avahi for mesh
This commit is contained in:
parent
1d994359ec
commit
87f9e68933
|
@ -728,19 +728,19 @@ function setup_ipfs {
|
||||||
IPFS_KEY_LENGTH=2048
|
IPFS_KEY_LENGTH=2048
|
||||||
|
|
||||||
su -c "$IPFS_PATH/jsipfs init -b $IPFS_KEY_LENGTH" - $MY_USERNAME
|
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
|
echo "IPFS could not be initialised for user $MY_USERNAME" >> $INSTALL_LOG
|
||||||
exit 7358
|
exit 7358
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TEMP_IPFS_ID=/tmp/ipfsid
|
MY_IPFS_ID=/home/$MY_USERNAME/.ipfs-id
|
||||||
su -c "echo $($IPFS_PATH/jsipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > $TEMP_IPFS_ID" - $MY_USERNAME
|
su -c "echo $($IPFS_PATH/jsipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > $MY_IPFS_ID" - $MY_USERNAME
|
||||||
if [ ! -f $TEMP_IPFS_ID ]; then
|
if [ ! -f $MY_IPFS_ID ]; then
|
||||||
echo 'No IPFS identity was created' >> $INSTALL_LOG
|
echo 'No IPFS identity was created' >> $INSTALL_LOG
|
||||||
exit 37895
|
exit 37895
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IPFS_PEER_ID=$(cat $TEMP_IPFS_ID)
|
IPFS_PEER_ID=$(cat $MY_IPFS_ID)
|
||||||
if [ ${#IPFS_PEER_ID} -lt 10 ]; then
|
if [ ${#IPFS_PEER_ID} -lt 10 ]; then
|
||||||
echo 'Invalid IPFS peer ID' >> $INSTALL_LOG
|
echo 'Invalid IPFS peer ID' >> $INSTALL_LOG
|
||||||
echo "$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
|
# TODO in avahi service for ipfs replace IPFS_PEER_ID
|
||||||
|
|
||||||
rm $TEMP_IPFS_ID
|
|
||||||
echo 'IPFS installed with ID $IPFS_PEER_ID' >> $INSTALL_LOG
|
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
|
ZERONET_PORT=15441
|
||||||
IPFS_PORT=4001
|
IPFS_PORT=4001
|
||||||
SYNCTHING_PORT=22000
|
|
||||||
|
|
||||||
# Ethernet bridge definition (bridged to bat0)
|
# Ethernet bridge definition (bridged to bat0)
|
||||||
BRIDGE=br-mesh
|
BRIDGE=br-mesh
|
||||||
|
@ -134,8 +133,7 @@ function stop {
|
||||||
iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT
|
iptables -D INPUT -p tcp --dport $ZERONET_PORT -j ACCEPT
|
||||||
iptables -D INPUT -p udp --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 tcp --dport $IPFS_PORT -j ACCEPT
|
||||||
iptables -D INPUT -p udp --dport $SYNCTHING_PORT -j ACCEPT
|
iptables -D INPUT -p udp --dport $IPFS_PORT -j ACCEPT
|
||||||
iptables -D INPUT -p tcp --dport $SYNCTHING_PORT -j ACCEPT
|
|
||||||
|
|
||||||
systemctl restart network-manager
|
systemctl restart network-manager
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,6 +458,32 @@ function zeronet_update_config {
|
||||||
fi
|
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
|
if [ ! -d /etc/avahi ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -472,6 +498,7 @@ if [ $ENABLE_ZERONET ]; then
|
||||||
zeronet_update_config
|
zeronet_update_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
avahi_ipfs
|
||||||
ipfs_bootstrap
|
ipfs_bootstrap
|
||||||
#detect_tox_users
|
#detect_tox_users
|
||||||
avahi_remove_info
|
avahi_remove_info
|
||||||
|
|
Loading…
Reference in New Issue