diff --git a/src/freedombone-image-mesh b/src/freedombone-image-mesh index ed55eee5..e6945d2d 100755 --- a/src/freedombone-image-mesh +++ b/src/freedombone-image-mesh @@ -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 } diff --git a/src/freedombone-mesh-batman b/src/freedombone-mesh-batman index 3b99417c..6baae0e4 100755 --- a/src/freedombone-mesh-batman +++ b/src/freedombone-mesh-batman @@ -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 } diff --git a/src/zeronetavahi b/src/zeronetavahi index a927d623..2a44d227 100755 --- a/src/zeronetavahi +++ b/src/zeronetavahi @@ -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 '' > /etc/avahi/services/${service_name}.service + echo '' >> /etc/avahi/services/${service_name}.service + echo '' >> /etc/avahi/services/${service_name}.service + echo " %h ${service_type}" >> /etc/avahi/services/${service_name}.service + echo ' ' >> /etc/avahi/services/${service_name}.service + echo " _${service_type}._${service_protocol}" >> /etc/avahi/services/${service_name}.service + echo " ${service_port}" >> /etc/avahi/services/${service_name}.service + if [ "$service_description" ]; then + echo " $service_description" >> /tmp/zeronet-blog.service + fi + echo ' ' >> /etc/avahi/services/${service_name}.service + echo '' >> /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