ipfs tweaks
This commit is contained in:
parent
1c0c2a3031
commit
e0fbc044b3
|
@ -78,6 +78,32 @@ TOX_USERS_FILE=$ZERONET_INSTALL/${PROJECT_NAME}-tox-users.html
|
||||||
# whether to enable zeronet
|
# whether to enable zeronet
|
||||||
ENABLE_ZERONET=
|
ENABLE_ZERONET=
|
||||||
|
|
||||||
|
function create_avahi_service {
|
||||||
|
service_name=$1
|
||||||
|
service_type=$2
|
||||||
|
service_protocol=$3
|
||||||
|
service_port=$4
|
||||||
|
service_description="$5"
|
||||||
|
|
||||||
|
if [ ! -d /etc/avahi ]; then
|
||||||
|
echo $'create_avahi_service: avahi was not installed'
|
||||||
|
exit 52925
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
function create_ram_disk {
|
function create_ram_disk {
|
||||||
ramdisk_size_mb=$1
|
ramdisk_size_mb=$1
|
||||||
if [ ! -d /mnt/ramdisk ]; then
|
if [ ! -d /mnt/ramdisk ]; then
|
||||||
|
@ -737,6 +763,10 @@ function setup_ipfs {
|
||||||
rm -f /home/$MY_USERNAME/.ipfs-id
|
rm -f /home/$MY_USERNAME/.ipfs-id
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f /home/$MY_USERNAME/.ipfs-users ]; then
|
||||||
|
rm -f /home/$MY_USERNAME/.ipfs-users
|
||||||
|
fi
|
||||||
|
|
||||||
su -c "$IPFS_COMMAND init -b $IPFS_KEY_LENGTH" - $MY_USERNAME
|
su -c "$IPFS_COMMAND init -b $IPFS_KEY_LENGTH" - $MY_USERNAME
|
||||||
if [ ! -d /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
|
||||||
|
@ -757,6 +787,9 @@ function setup_ipfs {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TOX_ID=$(su -c 'toxid' - $MY_USERNAME)
|
||||||
|
create_avahi_service ipfs "ipfs" udp $IPFS_PORT "$IPFS_PEER_ID:$TOX_ID"
|
||||||
|
|
||||||
echo 'IPFS installed with ID $IPFS_PEER_ID' >> $INSTALL_LOG
|
echo 'IPFS installed with ID $IPFS_PEER_ID' >> $INSTALL_LOG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ ZERONET_CONFIG=$ZERONET_INSTALL/bootstrap
|
||||||
IPFS_PORT=4001
|
IPFS_PORT=4001
|
||||||
IPFS_PATH=/usr/bin
|
IPFS_PATH=/usr/bin
|
||||||
IPFS_COMMAND=$IPFS_PATH/ipfs
|
IPFS_COMMAND=$IPFS_PATH/ipfs
|
||||||
|
IPFS_USERS_FILE=/home/$MY_USERNAME/.ipfs-users
|
||||||
|
|
||||||
MY_BLOG_STR=$"My Blog"
|
MY_BLOG_STR=$"My Blog"
|
||||||
MY_MAIL_STR=$"My Mail"
|
MY_MAIL_STR=$"My Mail"
|
||||||
|
@ -89,11 +90,15 @@ function ipfs_bootstrap {
|
||||||
state=0
|
state=0
|
||||||
address=""
|
address=""
|
||||||
peer=""
|
peer=""
|
||||||
|
echo -n '' > $IPFS_USERS_FILE
|
||||||
while IFS='' read -r line || [[ -n "$line" ]]; do
|
while IFS='' read -r line || [[ -n "$line" ]]; do
|
||||||
if [ ${state} -eq "3" ]; then
|
if [ ${state} -eq "3" ]; then
|
||||||
if [[ $line == *"txt ="* ]]; then
|
if [[ $line == *"txt ="* ]]; then
|
||||||
ipfs_peer_id=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | awk -F '"' '{print $2}')
|
ipfs_txt=$(echo "$line" | awk -F '[' '{print $2}' | awk -F ']' '{print $1}' | awk -F '"' '{print $2}')
|
||||||
|
ipfs_peer_id=$(echo "$ipfs_txt" | awk -F ':' '{print $1}')
|
||||||
|
ipfs_tox_id=$(echo "$ipfs_txt" | awk -F ':' '{print $2}')
|
||||||
$IPFS_COMMAND bootstrap add /ip4/${address}/tcp/${IPFS_PORT}/ipfs/${ipfs_peer_id}
|
$IPFS_COMMAND bootstrap add /ip4/${address}/tcp/${IPFS_PORT}/ipfs/${ipfs_peer_id}
|
||||||
|
echo "$ipfs_tox_id $ipfs_peer_id" >> $IPFS_USERS_FILE
|
||||||
state=0
|
state=0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue